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

39 lines
1.2 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;
beforeEach(ngModule('ticket'));
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();
});
});
});
});