2018-08-22 11:29:54 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('Item', () => {
|
|
|
|
describe('Component vnItemSearchPanel', () => {
|
|
|
|
let $element;
|
|
|
|
let controller;
|
|
|
|
|
2019-09-13 14:09:14 +00:00
|
|
|
beforeEach(angular.mock.module('item', $translateProvider => {
|
|
|
|
$translateProvider.translations('en', {});
|
|
|
|
}));
|
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);
|
|
|
|
|
|
|
|
expect(result).toEqual('/api/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(`/api/ItemTags/filterItemTags/${selection.id}`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|