import './index.js'; describe('Entry Component vnEntryDescriptor', () => { let $httpParamSerializer; let controller; let $element; beforeEach(ngModule('entry')); beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope, _$httpParamSerializer_) => { $httpParamSerializer = _$httpParamSerializer_; $element = angular.element(``); controller = $componentController('vnEntryDescriptor', {$element}); controller._entry = {id: 2}; controller.vnConfig.storage = {currentUserWorkerId: 9}; controller.cardReload = ()=> { return true; }; })); describe('showEntryReport()', () => { it('should open a new window showing a delivery note PDF document', () => { const params = { clientId: controller.vnConfig.storage.currentUserWorkerId, entryId: controller.entry.id }; const serializedParams = $httpParamSerializer(params); let expectedPath = `api/report/entry-order?${serializedParams}`; jest.spyOn(window, 'open').mockReturnThis(); controller.showEntryReport(); expect(window.open).toHaveBeenCalledWith(expectedPath); }); }); });