salix/modules/entry/front/latest-buys-search-panel/index.spec.js

46 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-07-20 09:31:47 +00:00
import './index.js';
2020-08-27 13:14:30 +00:00
describe('Entry', () => {
describe('Component vnLatestBuysSearchPanel', () => {
2020-07-20 09:31:47 +00:00
let $element;
let controller;
2020-08-27 13:14:30 +00:00
beforeEach(ngModule('entry'));
2020-07-20 09:31:47 +00:00
beforeEach(angular.mock.inject($componentController => {
2020-08-27 13:14:30 +00:00
$element = angular.element(`<vn-latest-buys-search-panel></vn-latest-buys-search-panel>`);
2020-07-20 09:50:21 +00:00
controller = $componentController('vnLatestBuysSearchPanel', {$element});
2020-07-20 09:31:47 +00:00
}));
describe('getSourceTable()', () => {
it(`should return null if there's no selection`, () => {
let selection = null;
let result = controller.getSourceTable(selection);
expect(result).toBeNull();
});
it(`should return null if there's a selection but its isFree property is truthy`, () => {
let selection = {isFree: true};
let result = controller.getSourceTable(selection);
expect(result).toBeNull();
});
it(`should return the formated sourceTable concatenated to a path`, () => {
let selection = {sourceTable: 'hello guy'};
let result = controller.getSourceTable(selection);
expect(result).toEqual('Hello guys');
});
it(`should return a path if there's no sourceTable and the selection has an id`, () => {
let selection = {id: 99};
let result = controller.getSourceTable(selection);
expect(result).toEqual(`ItemTags/filterItemTags/${selection.id}`);
});
});
});
});