Skip to content

Commit

Permalink
RTL14
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopereira committed Dec 14, 2016
1 parent 5728e01 commit c226d92
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Spec/RealtimeClientChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2325,6 +2325,39 @@ class RealtimeClientChannel: QuickSpec {
expect(channel.state).to(equal(ARTRealtimeChannelState.Attached))
}

// RTL14
it("If an ERROR ProtocolMessage is received for this channel then the channel should immediately transition to the FAILED state, the errorReason should be set and an error should be emitted on the channel") {
let client = ARTRealtime(options: AblyTests.commonAppSetup())
defer { client.dispose(); client.close() }
let channel = client.channels.get("foo")
waitUntil(timeout: testTimeout) { done in
channel.attach() { error in
expect(error).to(beNil())
done()
}
}

waitUntil(timeout: testTimeout) { done in
let errorProtocolMessage = AblyTests.newErrorProtocolMessage()
errorProtocolMessage.action = .Error
errorProtocolMessage.channel = "foo"

let partialDone = AblyTests.splitDone(2, done: done)

channel.once(.Failed) { stateChange in
guard let error = stateChange?.reason else {
fail("Reason error is nil"); partialDone(); return
}
expect(error).to(beIdenticalTo(errorProtocolMessage.error))
expect(channel.errorReason).to(beIdenticalTo(error))
partialDone()
}

client.transport.receive(errorProtocolMessage)
}

expect(channel.state).to(equal(ARTRealtimeChannelState.Failed))
}
}

context("crypto") {
Expand Down

0 comments on commit c226d92

Please sign in to comment.