"use strict";

var _crossDomainMessaging = require("../crossDomainMessaging");

describe('cross domain messaging', function () {
  describe('#postToParent', function () {
    it('does not error without a parent', function () {
      var messageData = {};
      var fakeWindowWithoutParent = {};
      expect(function () {
        (0, _crossDomainMessaging.postToParent)(messageData, fakeWindowWithoutParent);
      }).to.not.throw(Error);
    });
    it('calls postMessage on the parent with the data provided', function () {
      var postMessageStub = sinon.stub();
      var fakeWindowWithParent = {
        parent: {
          postMessage: postMessageStub
        }
      };
      var messageData = {
        subject: 'quizzesNext.testMe'
      };
      (0, _crossDomainMessaging.postToParent)(messageData, fakeWindowWithParent);
      expect(postMessageStub.calledWith(messageData)).to.be.true();
      postMessageStub.resetHistory();
    });
  });
});