From 723809e52e23c3f4dc2aa2bb6cfa509324019f58 Mon Sep 17 00:00:00 2001 From: Ricardo Pereira Date: Sun, 20 Mar 2016 21:00:00 +0000 Subject: [PATCH 1/2] RTP16c --- Spec/RealtimeClientPresence.swift | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/Spec/RealtimeClientPresence.swift b/Spec/RealtimeClientPresence.swift index 0f6435c13..242188e62 100644 --- a/Spec/RealtimeClientPresence.swift +++ b/Spec/RealtimeClientPresence.swift @@ -404,6 +404,60 @@ class RealtimeClientPresence: QuickSpec { } } + // RTP16c + it("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 From a217393f81d8bd411b9305964d47556a0fc34397 Mon Sep 17 00:00:00 2001 From: Ricardo Pereira Date: Sun, 20 Mar 2016 21:00:37 +0000 Subject: [PATCH 2/2] RTP16c: pending --- Spec/RealtimeClientPresence.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spec/RealtimeClientPresence.swift b/Spec/RealtimeClientPresence.swift index 242188e62..fe7d88e8f 100644 --- a/Spec/RealtimeClientPresence.swift +++ b/Spec/RealtimeClientPresence.swift @@ -405,7 +405,7 @@ class RealtimeClientPresence: QuickSpec { } // RTP16c - it("should result in an error if the connection state is INITIALIZED") { + pending("should result in an error if the connection state is INITIALIZED") { let options = AblyTests.commonAppSetup() options.autoConnect = false let client = ARTRealtime(options: options)