bit-bin
Version:
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b
77 lines (66 loc) • 2.79 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
function _chai() {
const data = require("chai");
_chai = function () {
return data;
};
return data;
}
function _componentOverrides() {
const data = _interopRequireDefault(require("./component-overrides"));
_componentOverrides = function () {
return data;
};
return data;
}
function _constants() {
const data = require("../../constants");
_constants = function () {
return data;
};
return data;
}
describe('ComponentOverrides', () => {
describe('getIgnoredComponents', () => {
it(`should return an empty array if it does not start with the component prefix (${_constants().OVERRIDE_COMPONENT_PREFIX})`, () => {
const componentOverrides = new (_componentOverrides().default)({
dependencies: {
'david.utils.is-string': '-'
}
});
const ignored = componentOverrides.getIgnoredComponents('dependencies');
(0, _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', () => {
const componentOverrides = new (_componentOverrides().default)({
dependencies: {
[`${_constants().OVERRIDE_COMPONENT_PREFIX}david/utils/is-string`]: '-'
}
});
const ignored = componentOverrides.getIgnoredComponents('dependencies');
(0, _chai().expect)(ignored).to.be.an('array').that.has.lengthOf(1);
(0, _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', () => {
const componentOverrides = new (_componentOverrides().default)({
dependencies: {
[`${_constants().OVERRIDE_COMPONENT_PREFIX}david.utils/is-string`]: '-'
}
});
const ignored = componentOverrides.getIgnoredComponents('dependencies');
(0, _chai().expect)(ignored).to.be.an('array').that.has.lengthOf(2);
(0, _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', () => {
const componentOverrides = new (_componentOverrides().default)({
dependencies: {
[`${_constants().OVERRIDE_COMPONENT_PREFIX}david.utils.is-string`]: '-'
}
});
const ignored = componentOverrides.getIgnoredComponents('dependencies');
(0, _chai().expect)(ignored).to.be.an('array').that.has.lengthOf(3);
(0, _chai().expect)(ignored.sort()).to.deep.equal(['david/utils/is-string', 'david.utils/is-string', 'david.utils.is-string'].sort());
});
});
});
;