'use strict';

var _chai;

function _load_chai() {
  return _chai = require('chai');
}

var _componentOverrides;

function _load_componentOverrides() {
  return _componentOverrides = _interopRequireDefault(require('./component-overrides'));
}

var _constants;

function _load_constants() {
  return _constants = require('../../constants');
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

describe('ComponentOverrides', function () {
  describe('getIgnoredComponents', function () {
    it(`should return an empty array if it does not start with the component prefix (${(_constants || _load_constants()).OVERRIDE_COMPONENT_PREFIX})`, function () {
      var componentOverrides = new (_componentOverrides || _load_componentOverrides()).default({ dependencies: { 'david.utils.is-string': '-' } });
      var ignored = componentOverrides.getIgnoredComponents('dependencies');
      (0, (_chai || _load_chai()).expect)(ignored).to.be.an('array').that.has.lengthOf(0);
    });
    it('should return the same dependency without the prefix if it does not have any dot', function () {
      var componentOverrides = new (_componentOverrides || _load_componentOverrides()).default({
        dependencies: { [`${(_constants || _load_constants()).OVERRIDE_COMPONENT_PREFIX}david/utils/is-string`]: '-' }
      });
      var ignored = componentOverrides.getIgnoredComponents('dependencies');
      (0, (_chai || _load_chai()).expect)(ignored).to.be.an('array').that.has.lengthOf(1);
      (0, (_chai || _load_chai()).expect)(ignored[0]).to.equal('david/utils/is-string');
    });
    it('should add another result if it has one dot by replacing the dot with a slash', function () {
      var componentOverrides = new (_componentOverrides || _load_componentOverrides()).default({
        dependencies: { [`${(_constants || _load_constants()).OVERRIDE_COMPONENT_PREFIX}david.utils/is-string`]: '-' }
      });
      var ignored = componentOverrides.getIgnoredComponents('dependencies');
      (0, (_chai || _load_chai()).expect)(ignored).to.be.an('array').that.has.lengthOf(2);
      (0, (_chai || _load_chai()).expect)(ignored.sort()).to.deep.equal(['david/utils/is-string', 'david.utils/is-string'].sort());
    });
    it('should add two more results if it has more than one dot by replacing dots with slashes', function () {
      var componentOverrides = new (_componentOverrides || _load_componentOverrides()).default({
        dependencies: { [`${(_constants || _load_constants()).OVERRIDE_COMPONENT_PREFIX}david.utils.is-string`]: '-' }
      });
      var ignored = componentOverrides.getIgnoredComponents('dependencies');
      (0, (_chai || _load_chai()).expect)(ignored).to.be.an('array').that.has.lengthOf(3);
      (0, (_chai || _load_chai()).expect)(ignored.sort()).to.deep.equal(['david/utils/is-string', 'david.utils/is-string', 'david.utils.is-string'].sort());
    });
  });
});