Skip to content

Commit a5ccbd7

Browse files
feat: added test for archiving / unarchiving
1 parent a4346c6 commit a5ccbd7

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

spec/channel_spec.rb

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def loop_times(times)
289289
expect(response['members'].length).to eq 2
290290
end
291291

292-
it 'can pin and unpin channel' do
292+
it 'can pin and unpin a channel' do
293293
@channel.add_members([@random_users[0][:id]])
294294
@channel.add_members([@random_users[1][:id]])
295295

@@ -301,24 +301,57 @@ def loop_times(times)
301301

302302
# Query for pinned channel
303303
response = @client.query_channels(
304-
{ 'pinned' => true, 'cid' => @channel.cid },
304+
{ 'pinned' => true, 'cid' => @channel.@cid },
305305
nil,
306306
{ 'user_id' => @random_users[0][:id] }
307307
)
308308
expect(response['channels'].length).to eq 1
309-
expect(response['channels'][0]['channel']['cid']).to eq @channel.cid
309+
expect(response['channels'][0]['channel']['cid']).to eq @channel.@cid
310310

311311
# Unpin the channel
312312
response = @channel.unpin(@random_users[0][:id])
313313
expect(response['channel_member']).not_to have_key('pinned_at')
314314

315315
# Query for unpinned channel
316316
response = @client.query_channels(
317-
{ 'pinned' => false, 'cid' => @channel.cid },
317+
{ 'pinned' => false, 'cid' => @channel.@cid },
318318
nil,
319319
{ 'user_id' => @random_users[0][:id] }
320320
)
321321
expect(response['channels'].length).to eq 1
322-
expect(response['channels'][0]['channel']['cid']).to eq @channel.cid
322+
expect(response['channels'][0]['channel']['cid']).to eq @channel.@cid
323+
end
324+
325+
it 'can archive and unarchive a channel' do
326+
@channel.add_members([@random_users[0][:id]])
327+
@channel.add_members([@random_users[1][:id]])
328+
329+
# Pin the channel
330+
now = Time.now
331+
response = @channel.archive(@random_users[0][:id])
332+
expect(response['channel_member']['archived_at']).not_to be_nil
333+
expect(Time.parse(response['channel_member']['archived_at']).to_i).to be >= now.to_i
334+
335+
# Query for pinned channel
336+
response = @client.query_channels(
337+
{ 'archived' => true, 'cid' => @channel.@cid },
338+
nil,
339+
{ 'user_id' => @random_users[0][:id] }
340+
)
341+
expect(response['channels'].length).to eq 1
342+
expect(response['channels'][0]['channel']['cid']).to eq @channel.@cid
343+
344+
# Unpin the channel
345+
response = @channel.unarchive(@random_users[0][:id])
346+
expect(response['channel_member']).not_to have_key('archived_at')
347+
348+
# Query for unpinned channel
349+
response = @client.query_channels(
350+
{ 'archived' => false, 'cid' => @channel.@cid },
351+
nil,
352+
{ 'user_id' => @random_users[0][:id] }
353+
)
354+
expect(response['channels'].length).to eq 1
355+
expect(response['channels'][0]['channel']['cid']).to eq @channel.@cid
323356
end
324357
end

0 commit comments

Comments
 (0)