Skip to content

Commit

Permalink
nit: swiftlint
Browse files Browse the repository at this point in the history
  • Loading branch information
nan-li committed Jan 27, 2025
1 parent 5f5655d commit a793cb0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public class IAMTestHelpers: NSObject {

return OS_OPERATOR_STRINGS[Int(type)]
}

@objc
public static func testDefaultMessageJson() -> [String : Any] {
public static func testDefaultMessageJson() -> [String: Any] {
return [
"id": String(format: "%@_%i", OS_TEST_MESSAGE_ID, UUID().uuidString),
"variants": [
Expand All @@ -67,22 +67,22 @@ public class IAMTestHelpers: NSObject {
"default": "should_never_be_used_by_any_test"
]
],
"triggers": [],
"triggers": []
]
}

@objc
public static func testMessageJsonWithTrigger(property: String, triggerId: String, type: Int32, value: Any) -> [String: Any] {
var testMessage = self.testDefaultMessageJson()

testMessage["triggers"] = [
[
[
"kind" : property,
"property" : property,
"operator" : OS_OPERATOR_TO_STRING(type),
"value" : value,
"id" : triggerId
"kind": property,
"property": property,
"operator": OS_OPERATOR_TO_STRING(type),
"value": value,
"id": triggerId
]
]
]
Expand All @@ -92,7 +92,7 @@ public class IAMTestHelpers: NSObject {
@objc
public static func testFetchMessagesResponse(messages: [[String: Any]]) -> [String: Any] {
return [
"in_app_messages" : messages
"in_app_messages": messages
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@ final class IAMIntegrationTests: XCTestCase {
}

override func tearDownWithError() throws { }

/**
Pausing IAMs will not evaluate messages.
*/
func testPausingIAMs_doesNotCreateMessageQueue() throws {
/* Setup */

let client = MockOneSignalClient()
OneSignalCoreImpl.setSharedClient(client)

// 1. App ID is set because there are guards against nil App ID
OneSignalConfigManager.setAppId("test-app-id")

// 2. Set up mock responses for the anonymous user, as the user needs an OSID
MockUserRequests.setDefaultCreateAnonUserResponses(with: client)

// 3. Set up mock responses for fetching IAMs
let message = IAMTestHelpers.testMessageJsonWithTrigger(property: "session_time", triggerId: "test_id1", type: 1, value: 10.0)
let response = IAMTestHelpers.testFetchMessagesResponse(messages: [message])
Expand All @@ -72,20 +72,20 @@ final class IAMIntegrationTests: XCTestCase {

// 4. Unblock the Consistency Manager to allow fetching of IAMs
ConsistencyManagerHelpers.setDefaultRywToken(id: anonUserOSID)

// 5. Pausing should prevent messages from being evaluated and shown
OneSignalInAppMessages.__paused(true)

// 6. Start the user manager to generate a user instance
OneSignalUserManagerImpl.sharedInstance.start()
OneSignalCoreMocks.waitForBackgroundThreads(seconds: 0.5)

// 7. Fetch IAMs
OneSignalInAppMessages.getFromServer(testPushSubId)
OneSignalCoreMocks.waitForBackgroundThreads(seconds: 0.5)

// Make sure no IAM is showing, and the queue has no IAMs
XCTAssertFalse(MockMessagingController.isInAppMessageShowing())
XCTAssertEqual(MockMessagingController.messageDisplayQueue().count, 0);
XCTAssertEqual(MockMessagingController.messageDisplayQueue().count, 0)
}
}

0 comments on commit a793cb0

Please sign in to comment.