aboutsummaryrefslogtreecommitdiff
path: root/test/shared
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-09-01 11:40:24 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-09-01 11:52:31 +0900
commitadcaf2aa48d0453f231268f5db168376c08e4e6b (patch)
treed20e4770644e504c2997cc80c17c5cae355f108e /test/shared
parent95c095f366106952d25982f12d99e4858c54cdb9 (diff)
message passing by helper functions
Diffstat (limited to 'test/shared')
-rw-r--r--test/shared/messages.test.js25
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' });
+ });
+ });
+});