-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f86b76f
commit 9df3f03
Showing
1 changed file
with
12 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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', () => { | ||
|