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,
|
|
|
|
clientFk: 101,
|
|
|
|
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 = {
|
2020-05-25 05:43:24 +00:00
|
|
|
recipientId: claim.clientFk,
|
2020-04-30 10:48:52 +00:00
|
|
|
claimId: claim.id
|
2019-11-06 08:32:54 +00:00
|
|
|
};
|
2019-02-12 06:42:19 +00:00
|
|
|
controller.showPickupOrder();
|
|
|
|
|
2020-06-12 12:28:29 +00:00
|
|
|
expect(controller.vnReport.show).toHaveBeenCalledWith('claim-pickup-order', 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,
|
2020-05-25 05:43:24 +00:00
|
|
|
recipientId: claim.clientFk,
|
2020-04-30 10:48:52 +00:00
|
|
|
claimId: claim.id
|
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
|
|
|
|
2020-06-12 12:28:29 +00:00
|
|
|
expect(controller.vnEmail.send).toHaveBeenCalledWith('claim-pickup-order', 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
|
|
|
});
|
|
|
|
|