"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _featureCheck = require("../featureCheck");

var _reduxStore = _interopRequireDefault(require("../../../reduxStore"));

describe('feature check', function () {
  (0, _featureCheck.withTestFeatures)(['aFeatureThatIsSet']);
  describe('featureOn', function () {
    it('returns true if a feature is in the store', function () {
      var featureIsOn = (0, _featureCheck.featureOn)('aFeatureThatIsSet');
      expect(featureIsOn).to.be.true();
    });
    it('returns false if a feature is not in the store', function () {
      var featureIsOn = (0, _featureCheck.featureOn)('aFeatureThatIsNotSet');
      expect(featureIsOn).to.be.false();
    });
  });
  describe('ifFeature', function () {
    var returnIfOn = 'on';
    var returnIfOff = 'off';
    it('returns the second arg if a feature is in the store', function () {
      var returnedVal = (0, _featureCheck.ifFeature)('aFeatureThatIsSet', returnIfOn, returnIfOff);
      expect(returnedVal).to.be.equal(returnIfOn);
    });
    it('returns the third arg if a feature is not the store', function () {
      var returnedVal = (0, _featureCheck.ifFeature)('aFeatureThatIsNotSet', returnIfOn, returnIfOff);
      expect(returnedVal).to.be.equal(returnIfOff);
    });
  });
  describe('setting features', function () {
    var featureName = 'foobarFeature';
    it('sets features', function () {
      (0, _featureCheck.setFeatures)([featureName]);
      expect(_reduxStore.default.dispatch).to.be.calledWithMatch({
        payload: [featureName]
      });
    });
    it('unsets features', function () {
      (0, _featureCheck.unsetFeatures)([featureName]);
      expect(_reduxStore.default.dispatch).to.be.calledWithMatch({
        payload: [featureName]
      });
    });
  });
});