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

35 lines
1021 B
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 $httpBackend;
beforeEach(ngModule('ticket'));
2018-08-09 12:42:02 +00:00
2020-07-23 14:46:16 +00:00
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
2018-08-09 12:42:02 +00:00
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
$scope.model = {
refresh: () => {}
};
controller = $componentController('vnTicketExpedition', {$element: null, $scope});
2018-08-09 12:42:02 +00:00
}));
describe('onDialogAccept()', () => {
2018-08-09 12:42:02 +00:00
it('should perform a DELETE query', () => {
2020-02-26 12:22:52 +00:00
jest.spyOn($scope.model, 'refresh');
2018-08-09 12:42:02 +00:00
const id = 1;
2018-08-09 12:42:02 +00:00
$httpBackend.expectDELETE(`Expeditions/${id}`).respond(200);
controller.onDialogAccept(id);
2018-08-09 12:42:02 +00:00
$httpBackend.flush();
expect($scope.model.refresh).toHaveBeenCalledWith();
});
});
});
});