Skip to content

Commit

Permalink
RTP10c (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopereira authored and tcard committed May 16, 2016
1 parent e141cbf commit c1e03ae
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Spec/RealtimeClientPresence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,38 @@ class RealtimeClientPresence: QuickSpec {
expect(channel.presence.leave("offline")).to(raiseException())
}

// RTP10c
it("entering without an explicit PresenceMessage#clientId should implicitly use the clientId of the current connection") {
let options = AblyTests.commonAppSetup()
options.clientId = "john"
let client = AblyTests.newRealtime(options)
defer { client.close() }
let channel = client.channels.get("test")

waitUntil(timeout: testTimeout) { done in
channel.presence.enter("online") { error in
channel.presence.leave(nil) { error in
expect(error).to(beNil())
done()
}
}
}

let transport = client.transport as! TestProxyTransport

let sent = transport.protocolMessagesSent.filter({ $0.action == .Presence })[1].presence![0]
expect(sent.action).to(equal(ARTPresenceAction.Leave))
expect(sent.clientId).to(beNil())

let received = transport.protocolMessagesReceived
.filter({ $0.action == .Presence })
.map({ $0.presence! })
.reduce([], combine: +)
.filter({ $0.action == .Leave })[0]
expect(received.action).to(equal(ARTPresenceAction.Leave))
expect(received.clientId).to(equal("john"))
}

}

// RTP8
Expand Down

0 comments on commit c1e03ae

Please sign in to comment.