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

66 lines
2.0 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: 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 = {
2020-05-25 05:43:24 +00:00
recipientId: claim.clientFk,
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
});
});
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,
2020-05-25 05:43:24 +00:00
recipientId: claim.clientFk,
claimId: claim.id
};
controller.sendPickupOrder();
2020-06-12 12:28:29 +00:00
expect(controller.vnEmail.send).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
});