2018-08-09 12:42:02 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('Ticket', () => {
|
|
|
|
describe('Component vnTicketExpedition', () => {
|
|
|
|
let controller;
|
|
|
|
let $scope;
|
|
|
|
let $state;
|
|
|
|
let $httpBackend;
|
|
|
|
|
2019-09-13 14:09:14 +00:00
|
|
|
beforeEach(angular.mock.module('ticket', $translateProvider => {
|
|
|
|
$translateProvider.translations('en', {});
|
|
|
|
}));
|
2018-08-09 12:42:02 +00:00
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_, _$httpBackend_) => {
|
2018-08-09 12:42:02 +00:00
|
|
|
$state = _$state_;
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$scope.model = {
|
|
|
|
refresh: () => {}
|
|
|
|
};
|
2018-12-22 10:59:26 +00:00
|
|
|
controller = $componentController('vnTicketExpedition', {$state, $scope});
|
2018-08-09 12:42:02 +00:00
|
|
|
}));
|
|
|
|
|
2018-09-04 09:57:41 +00:00
|
|
|
describe('returnDialog()', () => {
|
2018-08-09 12:42:02 +00:00
|
|
|
it('should perform a DELETE query', () => {
|
|
|
|
spyOn($scope.model, 'refresh');
|
|
|
|
|
2018-09-04 09:57:41 +00:00
|
|
|
let response = 'ACCEPT';
|
|
|
|
controller.expeditionId = 1;
|
2018-08-09 12:42:02 +00:00
|
|
|
|
|
|
|
$httpBackend.when('DELETE', `/ticket/api/Expeditions/1`).respond(200);
|
|
|
|
$httpBackend.expect('DELETE', `/ticket/api/Expeditions/1`);
|
2018-09-04 09:57:41 +00:00
|
|
|
controller.returnDialog(response);
|
2018-08-09 12:42:02 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect($scope.model.refresh).toHaveBeenCalledWith();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|