aboutsummaryrefslogtreecommitdiff
path: root/test/shared/messages.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/shared/messages.test.js')
-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' });
+ });
+ });
+});