import './index.js'; describe('Entry Component vnEntryDescriptor', () => { let $httpBackend; let controller; const entry = {id: 2}; beforeEach(ngModule('entry')); beforeEach(inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; controller = $componentController('vnEntryDescriptor', {$element: null}, {entry}); })); describe('showEntryReport()', () => { it('should open a new window showing a delivery note PDF document', () => { jest.spyOn(controller.vnReport, 'show'); window.open = jasmine.createSpy('open'); controller.showEntryReport(); const expectedPath = `Entries/${entry.id}/entry-order-pdf`; expect(controller.vnReport.show).toHaveBeenCalledWith(expectedPath); }); }); describe('loadData()', () => { it('should perform ask for the entry', () => { let query = `Entries/${entry.id}`; jest.spyOn(controller, 'getData'); $httpBackend.expectGET(query).respond(); controller.loadData(); $httpBackend.flush(); expect(controller.getData).toHaveBeenCalledTimes(1); expect(controller.getData).toHaveBeenCalledWith(query, jasmine.any(Object)); }); }); });