bonsai-analyzer
Version:
Trim your dependency tree.
43 lines (39 loc) • 1.25 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _defaults = require("../../__test_helpers__/defaults");
var _sortModules = _interopRequireDefault(require("../sortModules"));
const indexJS = (0, _defaults.defaultExtendedModule)({
id: 1,
name: 'index.js'
});
const buttonJS = (0, _defaults.defaultExtendedModule)({
id: 2,
name: 'button.js'
});
const modalJS = (0, _defaults.defaultExtendedModule)({
id: 3,
name: 'modal.js'
});
const allModules = [indexJS, buttonJS, modalJS];
describe('sortModules', () => {
it('Should sort by name both ways', () => {
expect((0, _sortModules.default)(allModules, {
field: 'name',
direction: 'ASC'
})).toEqual([buttonJS, indexJS, modalJS]);
expect((0, _sortModules.default)(allModules, {
field: 'name',
direction: 'DESC'
})).toEqual([modalJS, indexJS, buttonJS]);
});
it('Should sort by id both ways', () => {
expect((0, _sortModules.default)(allModules, {
field: 'id',
direction: 'ASC'
})).toEqual([indexJS, buttonJS, modalJS]);
expect((0, _sortModules.default)(allModules, {
field: 'id',
direction: 'DESC'
})).toEqual([modalJS, buttonJS, indexJS]);
});
});