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
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(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
|
|
|
}));
|
|
|
|
|
2021-11-22 14:49:32 +00:00
|
|
|
describe('filter() setter', () => {
|
|
|
|
it(`should set the tags property to the scope filter with an empty array`, () => {
|
|
|
|
const expectedFilter = {
|
|
|
|
tags: [{}]
|
|
|
|
};
|
|
|
|
controller.filter = null;
|
|
|
|
|
|
|
|
expect(controller.filter).toEqual(expectedFilter);
|
2018-08-22 11:29:54 +00:00
|
|
|
});
|
|
|
|
|
2021-11-22 14:49:32 +00:00
|
|
|
it(`should set the tags property to the scope filter with an array of tags`, () => {
|
|
|
|
const expectedFilter = {
|
|
|
|
description: 'My item',
|
|
|
|
tags: [{}]
|
|
|
|
};
|
|
|
|
const expectedFieldFilter = [{
|
|
|
|
info: {
|
|
|
|
label: 'description',
|
|
|
|
name: 'description',
|
|
|
|
type: null
|
|
|
|
},
|
|
|
|
name: 'description',
|
|
|
|
value: 'My item'
|
|
|
|
}];
|
|
|
|
controller.filter = {
|
|
|
|
description: 'My item'
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(controller.filter).toEqual(expectedFilter);
|
|
|
|
expect(controller.fieldFilters).toEqual(expectedFieldFilter);
|
2018-08-22 11:29:54 +00:00
|
|
|
});
|
2021-11-22 14:49:32 +00:00
|
|
|
});
|
2018-08-22 11:29:54 +00:00
|
|
|
|
2021-11-22 14:49:32 +00:00
|
|
|
describe('removeField()', () => {
|
|
|
|
it(`should remove the description property from the fieldFilters and from the scope filter`, () => {
|
|
|
|
const expectedFilter = {tags: [{}]};
|
|
|
|
controller.filter = {description: 'My item'};
|
2018-08-22 11:29:54 +00:00
|
|
|
|
2021-11-22 14:49:32 +00:00
|
|
|
controller.removeField(0, 'description');
|
2018-08-22 11:29:54 +00:00
|
|
|
|
2021-11-22 14:49:32 +00:00
|
|
|
expect(controller.filter).toEqual(expectedFilter);
|
|
|
|
expect(controller.fieldFilters).toEqual([]);
|
2018-08-22 11:29:54 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|