Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sescandell committed Nov 14, 2019
1 parent f86b76f commit 9df3f03
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions server/test/lib/gateway/gateway.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,26 @@ describe('gateway', () => {
});
});
describe('gateway.forwardWebsockets', () => {
it('should forward a websocket message', async () => {
it('should forward a websocket message when connected', async () => {
const gateway = new Gateway({}, event, system, sequelize, config);
await gateway.login('[email protected]', 'warmachine123');
gateway.connected = true;
const websocketMessage = {
type: 'zwave.new-node',
payload: {},
};
gateway.forwardWebsockets(websocketMessage);
assert.calledWith(gateway.gladysGatewayClient.newEventInstance, websocketMessage.type, websocketMessage.payload);
});
it('should prevent forwarding a websocket message when not connected', async () => {
const gateway = new Gateway({}, event, system, sequelize, config);

const websocketMessage = {
type: 'zwave.new-node',
payload: {},
};
gateway.forwardWebsockets(websocketMessage);
assert.notCalled(gateway.gladysGatewayClient.newEventInstance);
});
});

describe('gateway.handleNewMessage', () => {
Expand Down

0 comments on commit 9df3f03

Please sign in to comment.