From a5b2dcf924646691465379465c77466a29caeb7c Mon Sep 17 00:00:00 2001 From: Ricardo Pereira Date: Wed, 30 Mar 2016 16:44:28 +0100 Subject: [PATCH] RSP4b3 --- Spec/RestClientPresence.swift | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Spec/RestClientPresence.swift b/Spec/RestClientPresence.swift index 5d00fa403..f69abc401 100644 --- a/Spec/RestClientPresence.swift +++ b/Spec/RestClientPresence.swift @@ -193,6 +193,51 @@ class RestClientPresence: QuickSpec { } + // RSP4 + context("history") { + + // RSP4b + context("query argument") { + + // RSP4b3 + it("limit supports up to 1000 members") { + let options = AblyTests.commonAppSetup() + let client = ARTRest(options: options) + let channel = client.channels.get("test") + + var realtime: ARTRealtime! + defer { realtime.close() } + + waitUntil(timeout: testTimeout) { done in + realtime = AblyTests.addMembersSequentiallyToChannel("test", members: 1, options: options) { + done() + }.first + } + + let query = ARTDataQuery() + expect(query.limit).to(equal(100)) + query.limit = 1 + + waitUntil(timeout: testTimeout) { done in + try! channel.presence.history(query) { membersPage, error in + expect(error).to(beNil()) + expect(membersPage!.items).to(haveCount(1)) + expect(membersPage!.hasNext).to(beFalse()) + expect(membersPage!.isLast).to(beTrue()) + done() + } + } + + query.limit = 1001 + + expect { try channel.presence.history(query) { _, _ in } }.to(throwError { (error: ErrorType) in + expect(error._code).to(equal(ARTDataQueryError.Limit.rawValue)) + }) + } + } + + } + } } }