Skip to content

Commit

Permalink
Test: should dispatch in user queue when removing an observer
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopereira committed Nov 16, 2017
1 parent 2e692f5 commit c5616b5
Showing 1 changed file with 8 additions and 33 deletions.
41 changes: 8 additions & 33 deletions Spec/RealtimeClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1328,54 +1328,29 @@ class RealtimeClient: QuickSpec {
expect(result).to(equal(expectedOrder))
}

// Possible issue of https://github.com/ably/ably-ios/issues/640
xit("should unlock queue when the timer ends") {
let options = ARTClientOptions(key: "xxxx:xxxx")
options.autoConnect = false
let client = ARTRealtime(options: options)
let channel = client.channels.get("foo")

waitUntil(timeout: testTimeout) { done in
// Schedule a timer in the `internalDispatchQueue`
let listener = client.internalEventEmitter.once { _ in }
listener.setTimer(0.2, onTimeout: {
// another lock
channel.unsubscribe()
done()
})
listener.startTimer()

// lock
channel.unsubscribe()
}
}

class AblyManager {
static let sharedClient = ARTRealtime(options: { $0.autoConnect = false; return $0 }(ARTClientOptions(key: "xxxx:xxxx")))
}

// Possible issue of https://github.com/ably/ably-ios/issues/640
xit("should dispatch in user queue") {
// Issue https://github.com/ably/ably-ios/issues/640
it("should dispatch in user queue when removing an observer") {
class Foo {
let channel = "foo"
init() {
AblyManager.sharedClient.channels.get(channel).subscribe { _ in
AblyManager.sharedClient.channels.get("foo").subscribe { _ in
// keep reference
self.update()
}
}
deinit {
close()
}
func update() {
}
func close() {
AblyManager.sharedClient.channels.get(channel).unsubscribe()
deinit {
AblyManager.sharedClient.channels.get("foo").unsubscribe()
}
}

let foo = Foo()
foo.close()
var foo: Foo? = Foo()
foo = nil
AblyManager.sharedClient.channels.get("foo").unsubscribe()
}

it("should never register any connection listeners for internal use with the public EventEmitter") {
Expand Down

0 comments on commit c5616b5

Please sign in to comment.