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
89 lines (80 loc) • 2.75 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
function _chai() {
const data = require("chai");
_chai = function () {
return data;
};
return data;
}
function _dists() {
const data = _interopRequireDefault(require("../../../consumer/component/sources/dists"));
_dists = function () {
return data;
};
return data;
}
describe('Dists', () => {
describe('getNodePathDir', () => {
let consumer;
before(() => {
consumer = {
config: {}
};
consumer.toAbsolutePath = src => src;
});
it('should return null when custom module resolution is not configured', () => {
consumer.config = {};
(0, _chai().expect)(_dists().default.getNodePathDir(consumer)).to.be.undefined;
});
it('when distTarget and distEntry are not configured it should return the default dist plus the customDir', () => {
consumer.config = {
_resolveModules: {
modulesDirectories: ['src']
}
};
(0, _chai().expect)(_dists().default.getNodePathDir(consumer)).to.equal('dist/src');
});
it('when distEntry equals to customDir it should return the distTarget', () => {
consumer.config = {
_distTarget: 'dist',
_distEntry: 'src',
_resolveModules: {
modulesDirectories: ['src']
}
};
(0, _chai().expect)(_dists().default.getNodePathDir(consumer)).to.equal('dist');
});
it('when distEntry starts with customDir it should return the distTarget + (customDir - distEntry)', () => {
consumer.config = {
_distTarget: 'dist',
_distEntry: 'src',
_resolveModules: {
modulesDirectories: ['src/custom']
}
};
(0, _chai().expect)(_dists().default.getNodePathDir(consumer)).to.equal('dist/custom');
});
it('when distEntry starts partially with customDir it should return the distTarget + (customDir - distEntry)', () => {
consumer.config = {
_distTarget: 'dist',
_distEntry: 'src',
_resolveModules: {
modulesDirectories: ['src2']
}
};
(0, _chai().expect)(_dists().default.getNodePathDir(consumer)).to.equal('dist/src2');
});
it('when there are many custom-dirs it should return them with a separator according to the OS', () => {
consumer.config = {
_distTarget: 'dist',
_distEntry: 'src',
_resolveModules: {
modulesDirectories: ['custom1', 'custom2']
}
};
const delimiter = process.platform === 'win32' ? ';' : ':';
(0, _chai().expect)(_dists().default.getNodePathDir(consumer)).to.equal(`dist/custom1${delimiter}dist/custom2`);
});
});
});
;