2021-05-11 07:43:15 +00:00
|
|
|
import './index';
|
|
|
|
|
2021-05-12 07:12:46 +00:00
|
|
|
describe('Monitor Component vnMonitorSalesSearchPanel', () => {
|
2021-05-11 07:43:15 +00:00
|
|
|
let $httpBackend;
|
|
|
|
let controller;
|
|
|
|
|
2021-05-12 07:12:46 +00:00
|
|
|
beforeEach(ngModule('monitor'));
|
2021-05-11 07:43:15 +00:00
|
|
|
|
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
|
|
|
$httpBackend = _$httpBackend_;
|
2021-05-12 07:12:46 +00:00
|
|
|
controller = $componentController('vnMonitorSalesSearchPanel', {$element: null});
|
2021-05-11 07:43:15 +00:00
|
|
|
controller.$t = () => {};
|
|
|
|
controller.filter = {};
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('getGroupedStates()', () => {
|
|
|
|
it('should set an array of groupedStates with the adition of a name translation', () => {
|
|
|
|
jest.spyOn(controller, '$t').mockReturnValue('miCodigo');
|
|
|
|
const data = [
|
|
|
|
{
|
2021-10-15 08:49:23 +00:00
|
|
|
id: 9999,
|
2021-05-11 07:43:15 +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,
|
2021-05-11 07:43:15 +00:00
|
|
|
code: 'myCode',
|
|
|
|
name: 'miCodigo'
|
|
|
|
}]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('scopeDays() setter', () => {
|
|
|
|
it('should clear the date range when setting the scopeDays property', () => {
|
|
|
|
controller.filter.from = new Date();
|
|
|
|
controller.filter.to = new Date();
|
|
|
|
|
|
|
|
controller.scopeDays = 1;
|
|
|
|
|
|
|
|
expect(controller.filter.from).toBeNull();
|
|
|
|
expect(controller.filter.to).toBeNull();
|
|
|
|
expect(controller.scopeDays).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|