2019-02-12 06:42:19 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('Item Component vnClaimDescriptor', () => {
|
|
|
|
let $httpBackend;
|
|
|
|
let controller;
|
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
const claim = {
|
|
|
|
id: 2,
|
2021-06-23 11:24:23 +00:00
|
|
|
clientFk: 1101,
|
2020-04-30 10:48:52 +00:00
|
|
|
client: {email: 'client@email'}
|
|
|
|
};
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('claim'));
|
2019-02-12 06:42:19 +00:00
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
2019-02-12 06:42:19 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
2020-03-05 13:49:41 +00:00
|
|
|
|
2020-04-30 10:48:52 +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-04-30 10:48:52 +00:00
|
|
|
|
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
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-30 10:48:52 +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 = {
|
2020-04-30 10:48:52 +00:00
|
|
|
recipient: claim.client.email,
|
2022-10-04 05:41:40 +00:00
|
|
|
recipientId: claim.clientFk
|
2019-06-14 07:29:23 +00:00
|
|
|
};
|
2020-04-30 10:48:52 +00:00
|
|
|
controller.sendPickupOrder();
|
2019-06-14 07:29:23 +00:00
|
|
|
|
2022-10-04 05:41:40 +00:00
|
|
|
const expectedPath = `Claims/${claim.id}/claim-pickup-email`;
|
|
|
|
|
|
|
|
expect(controller.vnEmail.send).toHaveBeenCalledWith(expectedPath, params);
|
2019-06-14 07:29:23 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
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');
|
2020-04-30 10:48:52 +00:00
|
|
|
|
|
|
|
$httpBackend.expectDELETE(`Claims/${claim.id}`).respond();
|
|
|
|
controller.deleteClaim();
|
2019-06-14 07:29:23 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
2019-06-14 07:29:23 +00:00
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('claim.index');
|
|
|
|
});
|
|
|
|
});
|
2019-02-12 06:42:19 +00:00
|
|
|
});
|
|
|
|
|