salix/modules/ticket/front/expedition/index.spec.js

41 lines
1.3 KiB
JavaScript
Raw Normal View History

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
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: () => {}
};
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();
});
});
});
});