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
135 lines (110 loc) • 3.36 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
function path() {
const data = _interopRequireWildcard(require("path"));
path = function () {
return data;
};
return data;
}
function _chai() {
const data = require("chai");
_chai = function () {
return data;
};
return data;
}
function _bitMap() {
const data = _interopRequireDefault(require("./bit-map"));
_bitMap = function () {
return data;
};
return data;
}
function _bitId() {
const data = require("../../bit-id");
_bitId = function () {
return data;
};
return data;
}
function _constants() {
const data = require("../../constants");
_constants = function () {
return data;
};
return data;
}
function _logger() {
const data = _interopRequireDefault(require("../../logger/logger"));
_logger = function () {
return data;
};
return data;
}
const bitMapFixtureDir = path().join(__dirname, '../../../fixtures/bitmap-fixtures');
const addComponentParamsFixture = {
componentId: new (_bitId().BitId)({
name: 'is-string'
}),
files: [{
name: 'is-string.js',
relativePath: 'is-string.js',
test: false
}],
mainFile: 'is-string.js',
origin: _constants().COMPONENT_ORIGINS.AUTHORED
};
const addComponentParamsImportedFixture = {
componentId: new (_bitId().BitId)({
scope: 'my-scope',
name: 'is-string-imported',
version: '0.0.1'
}),
files: [{
name: 'is-string-imported.js',
relativePath: 'is-string-imported.js',
test: false
}],
mainFile: 'is-string-imported.js',
origin: _constants().COMPONENT_ORIGINS.IMPORTED,
rootDir: 'utils'
};
describe('BitMap', function () {
// @ts-ignore
_logger().default.debug = () => {}; // @ts-ignore
_logger().default.info = () => {};
this.timeout(0);
describe('toObject', () => {
let bitMap;
let componentMap;
before(() => {
bitMap = _bitMap().default.load(__dirname);
bitMap.addComponent(addComponentParamsFixture);
const allComponents = bitMap.toObjects();
componentMap = allComponents['is-string'];
});
it('should remove the "id" property', () => {
(0, _chai().expect)(componentMap).to.not.have.property('id');
});
it('should add "exported" property to authored components', () => {
(0, _chai().expect)(componentMap).to.have.property('exported');
(0, _chai().expect)(componentMap.exported).to.be.false;
});
it('should not add "exported" property to imported components', () => {
bitMap.addComponent(addComponentParamsImportedFixture);
const allComponents = bitMap.toObjects();
const componentMapImported = allComponents['my-scope/is-string-imported@0.0.1'];
(0, _chai().expect)(componentMapImported).to.not.have.property('exported');
});
});
describe('getAuthoredExportedComponents', () => {
it('should return an empty array when there are no authored components', () => {
const bitMap = _bitMap().default.load(path().join(bitMapFixtureDir, 'only-imported'));
const results = bitMap.getAuthoredExportedComponents();
(0, _chai().expect)(results).to.be.an('array');
(0, _chai().expect)(results).to.have.lengthOf(0);
});
});
});
;