57 lines
1.9 KiB
JavaScript
57 lines
1.9 KiB
JavaScript
import './index.js';
|
|
|
|
describe('Item', () => {
|
|
describe('Component vnFixedPriceSearchPanel', () => {
|
|
let $element;
|
|
let controller;
|
|
|
|
beforeEach(ngModule('item'));
|
|
|
|
beforeEach(angular.mock.inject($componentController => {
|
|
$element = angular.element(`<vn-fixed-price-search-panel></vn-fixed-price-search-panel>`);
|
|
controller = $componentController('vnFixedPriceSearchPanel', {$element});
|
|
controller.model = {addFilter: () => {}};
|
|
}));
|
|
|
|
describe('removeItemFilter()', () => {
|
|
it(`should remove param from filter`, () => {
|
|
controller.filter = {tags: [], categoryFk: 1, typeFk: 1};
|
|
const expectFilter = {tags: [], categoryFk: null, typeFk: null};
|
|
|
|
controller.removeItemFilter('categoryFk');
|
|
|
|
expect(controller.filter).toEqual(expectFilter);
|
|
});
|
|
});
|
|
|
|
describe('removeTag()', () => {
|
|
it(`should remove tag from filter`, () => {
|
|
const tag = {tagFk: 1, value: 'Value'};
|
|
controller.filter = {tags: [tag]};
|
|
const expectFilter = {tags: []};
|
|
|
|
controller.removeTag(tag);
|
|
|
|
expect(controller.filter).toEqual(expectFilter);
|
|
});
|
|
});
|
|
|
|
describe('showTagInfo()', () => {
|
|
it(`should show tag value`, () => {
|
|
const tag = {value: 'Value'};
|
|
const result = controller.showTagInfo(tag);
|
|
|
|
expect(result).toEqual('Value');
|
|
});
|
|
|
|
it(`should show tag name and value`, () => {
|
|
const tag = {tagFk: 1, value: 'Value'};
|
|
controller.tags = [{id: 1, name: 'tagName'}];
|
|
const result = controller.showTagInfo(tag);
|
|
|
|
expect(result).toEqual('tagName: Value');
|
|
});
|
|
});
|
|
});
|
|
});
|