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

55 lines
1.7 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 $httpBackend;
2022-05-04 08:35:31 +00:00
let $window;
2018-08-09 12:42:02 +00:00
beforeEach(ngModule('ticket'));
2018-08-09 12:42:02 +00:00
2022-05-04 08:35:31 +00:00
beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$window_) => {
$window = _$window_;
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();
});
});
2022-05-04 08:35:31 +00:00
2022-05-04 10:05:46 +00:00
describe('showLog()', () => {
it('should show the popover status log', () => {
controller.$.statusLog = {show: () => {}};
jest.spyOn(controller.$.statusLog, 'show');
const expedition = {id: 1};
const event = new MouseEvent('click', {
view: $window,
bubbles: true,
cancelable: true
});
controller.showLog(event, expedition);
expect(controller.$.statusLog.show).toHaveBeenCalledWith();
});
});
2018-08-09 12:42:02 +00:00
});
});