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

49 lines
1.4 KiB
JavaScript
Raw 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()', () => {
it('should set an array of groupedStates with the aditionof a name translation', () => {
jest.spyOn(controller, '$t').mockReturnValue('miCodigo');
const data = [
{
alertLevel: 9999,
code: 'myCode'
}
];
$httpBackend.whenGET('AlertLevels').respond(data);
controller.getGroupedStates();
$httpBackend.flush();
expect(controller.groupedStates).toEqual([{
alertLevel: 9999,
code: 'myCode',
name: 'miCodigo'
}]);
});
});
describe('scopeDays() setter', () => {
it('should clear the date range', () => {
controller.filter.from = new Date();
controller.filter.to = new Date();
controller.scopeDays = 1;
expect(controller.filter.from).toBeNull();
expect(controller.filter.to).toBeNull();
});
});
});