Skip to content

Commit

Permalink
Updated recovery key context tests for decoding recovery key
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed May 7, 2024
1 parent 2bdf984 commit 297b3fa
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions spec/unit/realtime/recovery_key_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@
describe Ably::Realtime::RecoveryKeyContext do

context 'recovery context' do
let(:recovery_context) do

it 'should encode recovery key context' do
connection_key = 'key'
msg_serial = 123
channel_serials = {
'channel1' => 'serial1',
'channel2' => 'serial2'
}
return Ably::Realtime::RecoveryKeyContext.new(connection_key, msg_serial, channel_serials)
end

it 'should encode recovery key context' do
recovery_context = Ably::Realtime::RecoveryKeyContext.new(connection_key, msg_serial, channel_serials)
encoded_recovery_key = recovery_context.to_json
expect(encoded_recovery_key).to eql "{\"connection_key\":\"key\",\"msg_serial\":123," <<
"\"channel_serials\":{\"channel1\":\"serial1\",\"channel2\":\"serial2\"}}"
expect(encoded_recovery_key).to eq "{\"connection_key\":\"key\",\"msg_serial\":123," <<
"\"channel_serials\":{\"channel1\":\"serial1\",\"channel2\":\"serial2\"}}"
end
end

it 'should decode recovery key context' do
encoded_recovery_key = "{\"connection_key\":\"key\",\"msg_serial\":123," <<
"\"channel_serials\":{\"channel1\":\"serial1\",\"channel2\":\"serial2\"}}"
decoded_recovery_key = Ably::Realtime::RecoveryKeyContext.from_json(encoded_recovery_key)
expect(decoded_recovery_key.connection_key).to eq("key")
expect(decoded_recovery_key.msg_serial).to eq(123)
end
end

0 comments on commit 297b3fa

Please sign in to comment.