UNPKG

bonsai-analyzer

Version:
43 lines (39 loc) 1.25 kB
"use strict"; 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]); }); });