import { expect } from 'chai';
import jsdom from 'jsdom';

describe('JSDOM', () => {
  it('should communicate with inner iframes', done => {
    jsdom.env({
      url: "http://bar.com/",
      done (err, window) {
        var frame = window.document.createElement('iframe');
        window.document.body.appendChild(frame);
        frame.contentWindow.addEventListener('message', e => {
          expect(e.data.message).to.equal('hello');
          done();
        });
        frame.contentWindow.postMessage({
          message: 'hello'
        }, '*');
      }
    });
  });
});