import './index'; describe('Ticket', () => { describe('Component vnTicketExpedition', () => { let controller; let $scope; let $state; let $httpBackend; beforeEach(ngModule('ticket')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_, _$httpBackend_) => { $state = _$state_; $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.model = { refresh: () => {} }; controller = $componentController('vnTicketExpedition', {$state, $scope}); })); describe('returnDialog()', () => { it('should perform a DELETE query', () => { 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(); }); }); }); });