salix/modules/claim/front/descriptor/index.spec.js

65 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-02-12 06:42:19 +00:00
import './index.js';
describe('Item Component vnClaimDescriptor', () => {
let $httpBackend;
let controller;
const claim = {
id: 2,
clientFk: 101,
client: {email: 'client@email'}
};
beforeEach(ngModule('claim'));
2019-02-12 06:42:19 +00:00
beforeEach(inject(($componentController, _$httpBackend_) => {
2019-02-12 06:42:19 +00:00
$httpBackend = _$httpBackend_;
2020-03-05 13:49:41 +00:00
controller = $componentController('vnClaimDescriptor', {$element: null}, {claim});
2019-02-12 06:42:19 +00:00
}));
describe('showPickupOrder()', () => {
it('should open a new window showing a pickup order PDF document', () => {
controller.showReport = jest.fn();
2019-11-06 08:32:54 +00:00
const params = {
clientId: claim.clientFk,
claimId: claim.id
2019-11-06 08:32:54 +00:00
};
2019-02-12 06:42:19 +00:00
controller.showPickupOrder();
expect(controller.showReport).toHaveBeenCalledWith('claim-pickup-order', params);
2019-02-12 06:42:19 +00:00
});
});
describe('sendPickupOrder()', () => {
2019-10-30 15:57:14 +00:00
it('should make a query and call vnApp.showMessage() if the response is accept', () => {
jest.spyOn(controller, 'sendEmail');
2019-02-12 06:42:19 +00:00
2019-11-06 08:32:54 +00:00
const params = {
recipient: claim.client.email,
clientId: claim.clientFk,
claimId: claim.id
};
controller.sendPickupOrder();
expect(controller.sendEmail).toHaveBeenCalledWith('claim-pickup-order', params);
});
});
describe('deleteClaim()', () => {
2019-10-30 15:57:14 +00:00
it('should perform a query and call showSuccess if the response is accept', () => {
2020-02-26 12:22:52 +00:00
jest.spyOn(controller.vnApp, 'showSuccess');
jest.spyOn(controller.$state, 'go');
$httpBackend.expectDELETE(`Claims/${claim.id}`).respond();
controller.deleteClaim();
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
expect(controller.$state.go).toHaveBeenCalledWith('claim.index');
});
});
2019-02-12 06:42:19 +00:00
});