import './index'; describe('Ticket', () => { describe('Component vnTicketExpedition', () => { let controller; let $scope; let $httpBackend; beforeEach(ngModule('ticket')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.model = { refresh: () => {} }; const $element = angular.element(''); controller = $componentController('vnTicketExpedition', {$element, $scope}); })); describe('returnDialog()', () => { it('should perform a DELETE query', () => { jest.spyOn($scope.model, 'refresh'); let response = 'accept'; controller.expeditionId = 1; $httpBackend.when('DELETE', `Expeditions/1`).respond(200); $httpBackend.expect('DELETE', `Expeditions/1`); controller.returnDialog(response); $httpBackend.flush(); expect($scope.model.refresh).toHaveBeenCalledWith(); }); }); }); });