2020-11-12 12:33:33 +00:00
|
|
|
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 = () => {};
|
2021-01-11 07:48:53 +00:00
|
|
|
controller.filter = {};
|
2020-11-12 12:33:33 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
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'
|
|
|
|
}]);
|
|
|
|
});
|
|
|
|
});
|
2021-01-11 07:48:53 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|
2020-11-12 12:33:33 +00:00
|
|
|
});
|