import './index.js'; describe('InvoiceIn', () => { describe('Component serial-search-panel', () => { let controller; let $scope; beforeEach(ngModule('invoiceIn')); beforeEach(inject(($componentController, $rootScope) => { $scope = $rootScope.$new(); const $element = angular.element(''); controller = $componentController('vnInvoiceInSerialSearchPanel', {$element, $scope}); controller.model = { addFilter: jest.fn(), }; controller.invoiceInConfig = { daysAgo: 45, }; })); describe('addFilters()', () => { it('should add default daysAgo if it is not already set', () => { controller.filter = { serial: 'R', }; controller.addFilters(); expect(controller.filter.daysAgo).toEqual(controller.invoiceInConfig.daysAgo); }); it('should not add default daysAgo if it is already set', () => { controller.filter = { daysAgo: 1, serial: 'R', }; controller.addFilters(); expect(controller.filter.daysAgo).toEqual(1); }); }); }); });