Skip to content

Commit

Permalink
Test for asserting promise from client.disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnarkhede committed Feb 10, 2020
1 parent 48c5a1a commit ebbac35
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,23 @@ describe('Chat', function() {
p = anonClient.addDevice('deviceID', 'apn');
await expect(p).to.be.rejectedWith(errorMsg);
});

it('disconnect should always return promise irrespective of wsConnection status', async function() {
const client2 = await getTestClientForUser('bob');
const chan = client2.channel('messaging', uuidv4());
await chan.watch();
let disconnect = client2.disconnect();
await expect(disconnect).to.be.fulfilled;

// Lets try disconnect second time on same client.
disconnect = client2.disconnect();
await expect(disconnect).to.be.fulfilled;

// Lets try deleting websocket connection object.
client2.wsConnection = null;
disconnect = client2.disconnect();
await expect(disconnect).to.be.fulfilled;
});
});

describe('Permissions', function() {
Expand Down

0 comments on commit ebbac35

Please sign in to comment.