"use strict";

var _windowChecks = require("../windowChecks");

describe('windowChecks', function () {
  var phoneQueryString = _windowChecks.media['phone-break-point'];
  var tabletQueryString = _windowChecks.media['tablet-break-point'];
  var matchingReturn = {
    matches: true
  };
  var notMatchingReturn = {
    matches: false
  };

  var windowMatching = function windowMatching(matches) {
    var matchMediaStub = sinon.stub();
    matchMediaStub.withArgs(phoneQueryString).returns(matches.phone ? matchingReturn : notMatchingReturn);
    matchMediaStub.withArgs(tabletQueryString).returns(matches.tablet ? matchingReturn : notMatchingReturn);
    return {
      matchMedia: matchMediaStub
    };
  };

  describe('onPhone', function () {
    it('returns true if window matches with phone break point query string', function () {
      var fakeWindow = windowMatching({
        phone: true
      });
      var isOnPhone = (0, _windowChecks.onPhone)(fakeWindow);
      expect(isOnPhone).to.be.true();
    });
    it('returns false if window does not match phone break point query string', function () {
      var fakeWindow = windowMatching({
        phone: false
      });
      var isOnPhone = (0, _windowChecks.onPhone)(fakeWindow);
      expect(isOnPhone).to.be.false();
    });
  });
  describe('onTablet', function () {
    it('returns true if window matches tablet query string and not phone query string', function () {
      var fakeWindow = windowMatching({
        phone: false,
        tablet: true
      });
      var isOnTablet = (0, _windowChecks.onTablet)(fakeWindow);
      expect(isOnTablet).to.be.true();
    });
    it('returns false if window matches phone query string and tablet query string', function () {
      var fakeWindow = windowMatching({
        phone: true,
        tablet: true
      });
      var isOnTablet = (0, _windowChecks.onTablet)(fakeWindow);
      expect(isOnTablet).to.be.false();
    });
    it('returns false if window matches neither phone or tablet query string', function () {
      var fakeWindow = windowMatching({
        phone: false,
        tablet: false
      });
      var isOnTablet = (0, _windowChecks.onTablet)(fakeWindow);
      expect(isOnTablet).to.be.false();
    });
  });
});