diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-01 11:40:24 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-01 11:52:31 +0900 |
commit | adcaf2aa48d0453f231268f5db168376c08e4e6b (patch) | |
tree | d20e4770644e504c2997cc80c17c5cae355f108e /test/shared/messages.test.js | |
parent | 95c095f366106952d25982f12d99e4858c54cdb9 (diff) |
message passing by helper functions
Diffstat (limited to 'test/shared/messages.test.js')
-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' }); + }); + }); +}); |