66 lines
1.9 KiB
JavaScript
66 lines
1.9 KiB
JavaScript
import './index.js';
|
|
|
|
describe('Item Component vnClaimDescriptor', () => {
|
|
let $httpBackend;
|
|
let controller;
|
|
|
|
const claim = {
|
|
id: 2,
|
|
clientFk: 1101,
|
|
client: {email: 'client@email'}
|
|
};
|
|
|
|
beforeEach(ngModule('claim'));
|
|
|
|
beforeEach(inject(($componentController, _$httpBackend_) => {
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
controller = $componentController('vnClaimDescriptor', {$element: null}, {claim});
|
|
}));
|
|
|
|
describe('showPickupOrder()', () => {
|
|
it('should open a new window showing a pickup order PDF document', () => {
|
|
jest.spyOn(controller.vnReport, 'show');
|
|
|
|
window.open = jasmine.createSpy('open');
|
|
const params = {
|
|
recipientId: claim.clientFk
|
|
};
|
|
controller.showPickupOrder();
|
|
|
|
const expectedPath = `Claims/${claim.id}/claim-pickup-pdf`;
|
|
|
|
expect(controller.vnReport.show).toHaveBeenCalledWith(expectedPath, params);
|
|
});
|
|
});
|
|
|
|
describe('sendPickupOrder()', () => {
|
|
it('should make a query and call vnApp.showMessage() if the response is accept', () => {
|
|
jest.spyOn(controller.vnEmail, 'send');
|
|
|
|
const params = {
|
|
recipient: claim.client.email,
|
|
recipientId: claim.clientFk
|
|
};
|
|
controller.sendPickupOrder();
|
|
|
|
const expectedPath = `Claims/${claim.id}/claim-pickup-email`;
|
|
|
|
expect(controller.vnEmail.send).toHaveBeenCalledWith(expectedPath, params);
|
|
});
|
|
});
|
|
|
|
describe('deleteClaim()', () => {
|
|
it('should perform a query and call showSuccess if the response is accept', () => {
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
$httpBackend.expectDELETE(`Claims/${claim.id}`).respond();
|
|
controller.deleteClaim();
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
|
});
|
|
});
|
|
});
|
|
|