A fork of https://github.com/ueokande/vim-vixen
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
733 B
26 lines
733 B
7 years ago
|
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' });
|
||
|
});
|
||
|
});
|
||
|
});
|