Skip to content

Commit

Permalink
Check if clientId for the local device is updated after deactivtion.
Browse files Browse the repository at this point in the history
  • Loading branch information
maratal committed Dec 1, 2023
1 parent 30c7e29 commit 3cd914e
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions Test/Tests/PushActivationStateMachineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3cd914e

Please sign in to comment.