import './index'; describe('Ticket', () => { describe('Component vnTicketExpedition', () => { let controller; let $scope; let $httpBackend; let $window; beforeEach(ngModule('ticket')); beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$window_) => { $window = _$window_; $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.model = { refresh: () => {} }; controller = $componentController('vnTicketExpedition', {$element: null, $scope}); })); describe('onDialogAccept()', () => { it('should perform a DELETE query', () => { jest.spyOn($scope.model, 'refresh'); const id = 1; $httpBackend.expectDELETE(`Expeditions/${id}`).respond(200); controller.onDialogAccept(id); $httpBackend.flush(); expect($scope.model.refresh).toHaveBeenCalledWith(); }); }); describe('showLog()', () => { it('should show the popover status log', () => { controller.$.statusLog = {show: () => {}}; jest.spyOn(controller.$.statusLog, 'show'); const expedition = {id: 1}; const event = new MouseEvent('click', { view: $window, bubbles: true, cancelable: true }); controller.showLog(event, expedition); expect(controller.$.statusLog.show).toHaveBeenCalledWith(); }); }); }); });