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

72 lines
2.2 KiB
JavaScript
Raw Normal View History

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 = [
{
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([{
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;
2023-01-16 14:18:24 +00:00
controller.from = Date.vnNew();
2021-05-11 07:43:15 +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-05-11 07:43:15 +00:00
expect(controller.filter.scopeDays).toBeNull();
expect(controller.to).toBeDefined();
});
});
describe('scopeDays() setter', () => {
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();
2021-05-11 07:43:15 +00:00
controller.scopeDays = 1;
expect(controller.filter.from).toBeNull();
expect(controller.filter.to).toBeNull();
expect(controller.scopeDays).toBeDefined();
});
});
});