Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTP16c #318

Merged
merged 2 commits into from
Mar 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions Spec/RealtimeClientPresence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,60 @@ class RealtimeClientPresence: QuickSpec {
}
}

// RTP16c
pending("should result in an error if the connection state is INITIALIZED") {
let options = AblyTests.commonAppSetup()
options.autoConnect = false
let client = ARTRealtime(options: options)
defer { client.close() }
let channel = client.channels.get("test")
expect(client.options.queueMessages).to(beTrue())

expect(client.connection.state).to(equal(ARTRealtimeConnectionState.Initialized))

waitUntil(timeout: testTimeout) { done in
channel.presence.enterClient("user", data: nil) { error in
expect(error).toNot(beNil())
expect(channel.queuedMessages).to(haveCount(0))
done()
}
expect(channel.queuedMessages).to(haveCount(0))
}
}

// RTP16c
let cases: [ARTRealtimeConnectionState:(ARTRealtime)->()] = [
.Suspended: { client in client.onSuspended() },
.Closed: { client in client.close() },
.Failed: { client in client.onError(AblyTests.newErrorProtocolMessage()) }
]
for (connectionState, performMethod) in cases {
it("should result in an error if the connection state is \(connectionState)") {
let client = ARTRealtime(options: AblyTests.commonAppSetup())
defer { client.close() }
let channel = client.channels.get("test")
expect(client.options.queueMessages).to(beTrue())

waitUntil(timeout: testTimeout) { done in
channel.attach() { _ in
performMethod(client)
done()
}
}

expect(client.connection.state).toEventually(equal(connectionState), timeout: testTimeout)

waitUntil(timeout: testTimeout) { done in
channel.presence.enterClient("user", data: nil) { error in
expect(error).toNot(beNil())
expect(channel.queuedMessages).to(haveCount(0))
done()
}
expect(channel.queuedMessages).to(haveCount(0))
}
}
}

}

// RTP11
Expand Down