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

61 lines
2.0 KiB
JavaScript

import './index.js';
describe('Item', () => {
describe('Component vnItemSearchPanel', () => {
let $element;
let controller;
beforeEach(ngModule('item'));
beforeEach(inject($componentController => {
$element = angular.element(`<div></div>`);
controller = $componentController('vnItemSearchPanel', {$element});
}));
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);
});
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);
});
});
describe('removeField()', () => {
it(`should remove the description property from the fieldFilters and from the scope filter`, () => {
const expectedFilter = {tags: [{}]};
controller.filter = {description: 'My item'};
controller.removeField(0, 'description');
expect(controller.filter).toEqual(expectedFilter);
expect(controller.fieldFilters).toEqual([]);
});
});
});
});