2020-07-20 09:31:47 +00:00
|
|
|
import './index.js';
|
|
|
|
|
2020-08-27 13:14:30 +00:00
|
|
|
describe('Entry', () => {
|
|
|
|
describe('Component vnLatestBuysSearchPanel', () => {
|
2020-07-20 09:31:47 +00:00
|
|
|
let $element;
|
|
|
|
let controller;
|
|
|
|
|
2020-08-27 13:14:30 +00:00
|
|
|
beforeEach(ngModule('entry'));
|
2020-07-20 09:31:47 +00:00
|
|
|
|
|
|
|
beforeEach(angular.mock.inject($componentController => {
|
2020-08-27 13:14:30 +00:00
|
|
|
$element = angular.element(`<vn-latest-buys-search-panel></vn-latest-buys-search-panel>`);
|
2020-07-20 09:50:21 +00:00
|
|
|
controller = $componentController('vnLatestBuysSearchPanel', {$element});
|
2020-07-20 09:31:47 +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);
|
2020-07-20 09:31:47 +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);
|
2020-07-20 09:31:47 +00:00
|
|
|
});
|
2021-11-22 14:49:32 +00:00
|
|
|
});
|
2020-07-20 09:31:47 +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'};
|
2020-07-20 09:31:47 +00:00
|
|
|
|
2021-11-22 14:49:32 +00:00
|
|
|
controller.removeField(0, 'description');
|
2020-07-20 09:31:47 +00:00
|
|
|
|
2021-11-22 14:49:32 +00:00
|
|
|
expect(controller.filter).toEqual(expectedFilter);
|
|
|
|
expect(controller.fieldFilters).toEqual([]);
|
2020-07-20 09:31:47 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|