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

68 lines
2.1 KiB
JavaScript
Raw Permalink 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: 1101,
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', () => {
2020-06-12 12:28:29 +00:00
jest.spyOn(controller.vnReport, 'show');
2020-06-12 12:28:29 +00:00
window.open = jasmine.createSpy('open');
2019-11-06 08:32:54 +00:00
const params = {
2022-10-04 05:41:40 +00:00
recipientId: claim.clientFk
2019-11-06 08:32:54 +00:00
};
2019-02-12 06:42:19 +00:00
controller.showPickupOrder();
2022-10-04 05:41:40 +00:00
const expectedPath = `Claims/${claim.id}/claim-pickup-pdf`;
expect(controller.vnReport.show).toHaveBeenCalledWith(expectedPath, 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', () => {
2020-06-12 12:28:29 +00:00
jest.spyOn(controller.vnEmail, 'send');
2019-02-12 06:42:19 +00:00
2019-11-06 08:32:54 +00:00
const params = {
recipient: claim.client.email,
2022-10-04 05:41:40 +00:00
recipientId: claim.clientFk
};
controller.sendPickupOrder();
2022-10-04 05:41:40 +00:00
const expectedPath = `Claims/${claim.id}/claim-pickup-email`;
expect(controller.vnEmail.send).toHaveBeenCalledWith(expectedPath, 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
});