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

72 lines
2.2 KiB
JavaScript
Raw Permalink Normal View History

import './index';
describe('Ticket Component vnTicketSearchPanel', () => {
let $httpBackend;
let controller;
beforeEach(ngModule('ticket'));
beforeEach(inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
controller = $componentController('vnTicketSearchPanel', {$element: null});
controller.$t = () => {};
controller.filter = {};
}));
describe('getGroupedStates()', () => {
2021-01-11 13:54:24 +00:00
it('should set an array of groupedStates with the adition of a name translation', () => {
jest.spyOn(controller, '$t').mockReturnValue('miCodigo');
const data = [
{
id: 9999,
code: 'myCode'
}
];
$httpBackend.whenGET('AlertLevels').respond(data);
controller.getGroupedStates();
$httpBackend.flush();
expect(controller.groupedStates).toEqual([{
id: 9999,
code: 'myCode',
name: 'miCodigo'
}]);
});
});
2021-01-11 13:54:24 +00:00
describe('from() setter', () => {
it('should clear the scope days when setting the from property', () => {
controller.filter.scopeDays = 1;
2023-01-16 14:18:24 +00:00
controller.from = Date.vnNew();
2021-01-11 13:54:24 +00:00
expect(controller.filter.scopeDays).toBeNull();
expect(controller.from).toBeDefined();
});
});
describe('to() setter', () => {
it('should clear the scope days when setting the to property', () => {
controller.filter.scopeDays = 1;
2023-01-16 14:18:24 +00:00
controller.to = Date.vnNew();
2021-01-11 13:54:24 +00:00
expect(controller.filter.scopeDays).toBeNull();
expect(controller.to).toBeDefined();
});
});
describe('scopeDays() setter', () => {
2021-01-11 13:54:24 +00:00
it('should clear the date range when setting the scopeDays property', () => {
2023-01-16 14:18:24 +00:00
controller.filter.from = Date.vnNew();
controller.filter.to = Date.vnNew();
controller.scopeDays = 1;
expect(controller.filter.from).toBeNull();
expect(controller.filter.to).toBeNull();
2021-01-11 13:54:24 +00:00
expect(controller.scopeDays).toBeDefined();
});
});
});