import './index'; describe('Ticket', () => { describe('Component vnTicketExpedition', () => { let $componentController; let controller; let $scope; let $state; let $httpBackend; beforeEach(() => { angular.mock.module('ticket'); }); beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$state_, _$httpBackend_) => { $componentController = _$componentController_; $state = _$state_; $httpBackend = _$httpBackend_; $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); $scope = $rootScope.$new(); $scope.model = { refresh: () => {} }; controller = $componentController('vnTicketExpedition', {$state: $state}, {$scope: $scope}); })); describe('deleteExpedition()', () => { it('should perform a DELETE query', () => { spyOn($scope.model, 'refresh'); let expedition = {id: 1}; $httpBackend.when('DELETE', `/ticket/api/Expeditions/1`).respond(200); $httpBackend.expect('DELETE', `/ticket/api/Expeditions/1`); controller.deleteExpedition(expedition); $httpBackend.flush(); expect($scope.model.refresh).toHaveBeenCalledWith(); }); }); }); });