salix/modules/item/front/search-panel/index.spec.js

61 lines
2.0 KiB
JavaScript
Raw Normal View History

import './index.js';
describe('Item', () => {
describe('Component vnItemSearchPanel', () => {
let $element;
let controller;
beforeEach(ngModule('item'));
2020-07-23 14:46:16 +00:00
beforeEach(inject($componentController => {
$element = angular.element(`<div></div>`);
controller = $componentController('vnItemSearchPanel', {$element});
}));
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);
});
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);
});
2021-11-22 14:49:32 +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'};
2021-11-22 14:49:32 +00:00
controller.removeField(0, 'description');
2021-11-22 14:49:32 +00:00
expect(controller.filter).toEqual(expectedFilter);
expect(controller.fieldFilters).toEqual([]);
});
});
});
});