diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-02 10:08:49 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-02 10:08:49 +0900 |
commit | 044f24efb64ec52dfdb02e0e0807bc4545c4a21c (patch) | |
tree | 1cb621bd8ea538e128a7263012d3c8bc077e2e0d /test | |
parent | f1b9c6ba9d33fe1927c4855d4981d88ad73d5818 (diff) | |
parent | 02ea10a357955752dda4c72c49de2340997c9818 (diff) |
Merge branch 'error-line'
Diffstat (limited to 'test')
-rw-r--r-- | test/shared/messages.test.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/shared/messages.test.js b/test/shared/messages.test.js new file mode 100644 index 0000000..0ebaf1a --- /dev/null +++ b/test/shared/messages.test.js @@ -0,0 +1,25 @@ +import { expect } from "chai"; +import * as messages from '../../src/shared/messages'; + +describe('messages', () => { + describe('#receive', () => { + it('received a message', (done) => { + messages.receive(window, (message) => { + expect(message).to.deep.equal({ type: 'vimvixen.test' }); + done(); + }); + window.postMessage(JSON.stringify({ type: 'vimvixen.test' }), '*'); + }); + }); + + describe('#send', () => { + it('sends a message', (done) => { + window.addEventListener('message', (e) => { + let json = JSON.parse(e.data); + expect(json).to.deep.equal({ type: 'vimvixen.test' }); + done(); + }); + messages.send(window, { type: 'vimvixen.test' }); + }); + }); +}); |