61 lines
2.1 KiB
JavaScript
61 lines
2.1 KiB
JavaScript
import './index.js';
|
|
|
|
describe('Entry', () => {
|
|
describe('Component vnLatestBuysSearchPanel', () => {
|
|
let $element;
|
|
let controller;
|
|
|
|
beforeEach(ngModule('entry'));
|
|
|
|
beforeEach(angular.mock.inject($componentController => {
|
|
$element = angular.element(`<vn-latest-buys-search-panel></vn-latest-buys-search-panel>`);
|
|
controller = $componentController('vnLatestBuysSearchPanel', {$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([]);
|
|
});
|
|
});
|
|
});
|
|
});
|