diff options
| author | Erik Larkö <erik@mullvad.net> | 2017-05-28 00:44:34 +0200 |
|---|---|---|
| committer | Erik Larkö <erik@mullvad.net> | 2017-05-28 18:17:45 +0200 |
| commit | 51af2702156304fcad1f18a37710686a0267797d (patch) | |
| tree | 7ffc0c8554790f03794f29d8c78aa16d7a7f0819 | |
| parent | 60cdaa96ff099212d99457a9e2e69d7f3c827832 (diff) | |
| download | mullvadvpn-51af2702156304fcad1f18a37710686a0267797d.tar.xz mullvadvpn-51af2702156304fcad1f18a37710686a0267797d.zip | |
Add notifications test
| -rw-r--r-- | test/ipc.spec.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ipc.spec.js b/test/ipc.spec.js index 43a17b4911..ae9c5ab815 100644 --- a/test/ipc.spec.js +++ b/test/ipc.spec.js @@ -69,6 +69,26 @@ describe('The IPC server', () => { expect(e.message).to.contain('timed out'); }); }); + + it('should route notifications', (done) => { + const { ws, ipc } = setupIpc(); + + const eventListener = (event) => { + try { + expect(event).to.equal('an event!'); + done(); + } catch (ex) { + done(ex); + } + }; + + ws.on('event_subscribe', (msg) => ws.replyOk(msg.id, 1)); + ipc.on('event', eventListener) + .then(() => { + ws.reply(jsonrpc.notification('event', {subscription:1, result: 'an event!'})); + }) + .catch((e) => done(e)); + }); }); function mockWebsocket() { |
