2018-08-22 11:29:54 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('Item', () => {
|
|
|
|
describe('Component vnItemSearchPanel', () => {
|
|
|
|
let $element;
|
|
|
|
let controller;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('item'));
|
2018-08-22 11:29:54 +00:00
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(angular.mock.inject($componentController => {
|
2018-08-22 11:29:54 +00:00
|
|
|
$element = angular.element(`<div></div>`);
|
2018-12-22 10:59:26 +00:00
|
|
|
controller = $componentController('vnItemSearchPanel', {$element});
|
2018-08-22 11:29:54 +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);
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
expect(result).toEqual('Hello guys');
|
2018-08-22 11:29:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
expect(result).toEqual(`ItemTags/filterItemTags/${selection.id}`);
|
2018-08-22 11:29:54 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|