diff --git a/Test/Tests/PushActivationStateMachineTests.swift b/Test/Tests/PushActivationStateMachineTests.swift index 6c6c2a924..993f96046 100644 --- a/Test/Tests/PushActivationStateMachineTests.swift +++ b/Test/Tests/PushActivationStateMachineTests.swift @@ -136,11 +136,41 @@ class PushActivationStateMachineTests: XCTestCase { func test__016__Activation_state_machine__State_NotActivated__on_Event_CalledActivate__local_device__should_have_a_clientID_if_the_client_is_identified() { beforeEach__Activation_state_machine__State_NotActivated() - let options = ARTClientOptions(key: "xxxx:xxxx") - options.clientId = "deviceClient" - let rest = ARTRest(options: options) - rest.internal.storage = storage - XCTAssertEqual(rest.device.clientId, "deviceClient") + let options1 = ARTClientOptions(key: "xxxx:xxxx") + options1.clientId = "client1" + let rest1 = ARTRest(options: options1) + rest1.internal.storage = storage + let device1 = rest1.device + XCTAssertEqual(device1.clientId, "client1") + + let delegate = StateMachineDelegate() + stateMachine.delegate = delegate + + let testDeviceToken = "xxxx-xxxx-xxxx-xxxx-xxxx" + stateMachine.rest.device.setAndPersistAPNSDeviceToken(testDeviceToken) + defer { stateMachine.rest.device.setAndPersistAPNSDeviceToken(nil) } + + waitUntil(timeout: testTimeout) { done in + let partialDone = AblyTests.splitDone(2, done: done) + stateMachine.transitions = { event, _, _ in + if event is ARTPushActivationEventGotPushDeviceDetails { + partialDone() + stateMachine.send(ARTPushActivationEventCalledDeactivate()) + } + if event is ARTPushActivationEventCalledDeactivate { + partialDone() + } + } + stateMachine.send(ARTPushActivationEventCalledActivate()) + } + + let options2 = ARTClientOptions(key: "xxxx:xxxx") + options2.clientId = "client2" + let rest2 = ARTRest(options: options2) + rest2.internal.storage = storage + let device2 = rest2.device + XCTAssertEqual(device2.clientId, "client2") + XCTAssertTrue(device1 === device2) } // RSH3a2c @@ -601,7 +631,8 @@ class PushActivationStateMachineTests: XCTestCase { stateMachine.send(ARTPushActivationEventCalledActivate()) expect(stateMachine.current).to(beAKindOf(ARTPushActivationStateWaitingForRegistrationSync.self)) - if !fromEvent.isKind(of: ARTPushActivationEventCalledActivate.self) { XCTAssertTrue(activatedCallbackCalled) + if !fromEvent.isKind(of: ARTPushActivationEventCalledActivate.self) { + XCTAssertTrue(activatedCallbackCalled) XCTAssertEqual(stateMachine.pendingEvents.count, 0) } else { XCTAssertFalse(activatedCallbackCalled)