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});
|
2023-02-07 11:30:30 +00:00
|
|
|
controller.model = {addFilter: () => {}};
|
2020-07-20 09:31:47 +00:00
|
|
|
}));
|
|
|
|
|
2023-02-03 14:21:27 +00:00
|
|
|
describe('removeItemFilter()', () => {
|
|
|
|
it(`should remove param from filter`, () => {
|
|
|
|
controller.filter = {tags: [], categoryFk: 1, typeFk: 1};
|
|
|
|
const expectFilter = {tags: [], categoryFk: null, typeFk: null};
|
2021-11-22 14:49:32 +00:00
|
|
|
|
2023-02-03 14:21:27 +00:00
|
|
|
controller.removeItemFilter('categoryFk');
|
|
|
|
|
|
|
|
expect(controller.filter).toEqual(expectFilter);
|
2020-07-20 09:31:47 +00:00
|
|
|
});
|
2023-02-03 14:21:27 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('removeTag()', () => {
|
|
|
|
it(`should remove tag from filter`, () => {
|
|
|
|
const tag = {tagFk: 1, value: 'Value'};
|
|
|
|
controller.filter = {tags: [tag]};
|
|
|
|
const expectFilter = {tags: []};
|
2020-07-20 09:31:47 +00:00
|
|
|
|
2023-02-03 14:21:27 +00:00
|
|
|
controller.removeTag(tag);
|
|
|
|
|
|
|
|
expect(controller.filter).toEqual(expectFilter);
|
2020-07-20 09:31:47 +00:00
|
|
|
});
|
2021-11-22 14:49:32 +00:00
|
|
|
});
|
2020-07-20 09:31:47 +00:00
|
|
|
|
2023-02-03 14:21:27 +00:00
|
|
|
describe('showTagInfo()', () => {
|
|
|
|
it(`should show tag value`, () => {
|
|
|
|
const tag = {value: 'Value'};
|
|
|
|
const result = controller.showTagInfo(tag);
|
|
|
|
|
|
|
|
expect(result).toEqual('Value');
|
|
|
|
});
|
2020-07-20 09:31:47 +00:00
|
|
|
|
2023-02-03 14:21:27 +00:00
|
|
|
it(`should show tag name and value`, () => {
|
|
|
|
const tag = {tagFk: 1, value: 'Value'};
|
|
|
|
controller.tags = [{id: 1, name: 'tagName'}];
|
|
|
|
const result = controller.showTagInfo(tag);
|
2020-07-20 09:31:47 +00:00
|
|
|
|
2023-02-03 14:21:27 +00:00
|
|
|
expect(result).toEqual('tagName: Value');
|
2020-07-20 09:31:47 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|