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()', () => {
|
2021-01-11 13:54:24 +00:00
|
|
|
it('should set an array of groupedStates with the adition of a name translation', () => {
|
2020-11-12 12:33:33 +00:00
|
|
|
jest.spyOn(controller, '$t').mockReturnValue('miCodigo');
|
|
|
|
const data = [
|
|
|
|
{
|
2021-10-15 08:49:23 +00:00
|
|
|
id: 9999,
|
2020-11-12 12:33:33 +00:00
|
|
|
code: 'myCode'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
$httpBackend.whenGET('AlertLevels').respond(data);
|
|
|
|
controller.getGroupedStates();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.groupedStates).toEqual([{
|
2021-10-15 08:49:23 +00:00
|
|
|
id: 9999,
|
2020-11-12 12:33:33 +00:00
|
|
|
code: 'myCode',
|
|
|
|
name: 'miCodigo'
|
|
|
|
}]);
|
|
|
|
});
|
|
|
|
});
|
2021-01-11 07:48:53 +00:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
controller.from = new Date();
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
controller.to = new Date();
|
|
|
|
|
|
|
|
expect(controller.filter.scopeDays).toBeNull();
|
|
|
|
expect(controller.to).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-01-11 07:48:53 +00:00
|
|
|
describe('scopeDays() setter', () => {
|
2021-01-11 13:54:24 +00:00
|
|
|
it('should clear the date range when setting the scopeDays property', () => {
|
2021-01-11 07:48:53 +00:00
|
|
|
controller.filter.from = new Date();
|
|
|
|
controller.filter.to = new Date();
|
|
|
|
|
|
|
|
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();
|
2021-01-11 07:48:53 +00:00
|
|
|
});
|
|
|
|
});
|
2020-11-12 12:33:33 +00:00
|
|
|
});
|