#504 client/item/src/search-panel/index.js Front unit test
This commit is contained in:
parent
c91163f7d1
commit
7db3a96adc
|
@ -0,0 +1,52 @@
|
||||||
|
import './index.js';
|
||||||
|
|
||||||
|
describe('Item', () => {
|
||||||
|
describe('Component vnItemSearchPanel', () => {
|
||||||
|
let $componentController;
|
||||||
|
let $element;
|
||||||
|
let controller;
|
||||||
|
let $httpBackend;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
angular.mock.module('item');
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_) => {
|
||||||
|
$componentController = _$componentController_;
|
||||||
|
$element = angular.element(`<div></div>`);
|
||||||
|
$httpBackend = _$httpBackend_;
|
||||||
|
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
||||||
|
controller = $componentController('vnItemSearchPanel', {$element: $element});
|
||||||
|
}));
|
||||||
|
|
||||||
|
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}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue