65 lines
1.9 KiB
JavaScript
65 lines
1.9 KiB
JavaScript
import './index.js';
|
|
|
|
describe('Item Component vnClaimDescriptor', () => {
|
|
let $httpBackend;
|
|
let controller;
|
|
|
|
const claim = {
|
|
id: 2,
|
|
clientFk: 101,
|
|
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', () => {
|
|
controller.showReport = jest.fn();
|
|
|
|
const params = {
|
|
clientId: claim.clientFk,
|
|
claimId: claim.id
|
|
};
|
|
controller.showPickupOrder();
|
|
|
|
expect(controller.showReport).toHaveBeenCalledWith('claim-pickup-order', params);
|
|
});
|
|
});
|
|
|
|
describe('sendPickupOrder()', () => {
|
|
it('should make a query and call vnApp.showMessage() if the response is accept', () => {
|
|
jest.spyOn(controller, 'sendEmail');
|
|
|
|
const params = {
|
|
recipient: claim.client.email,
|
|
clientId: claim.clientFk,
|
|
claimId: claim.id
|
|
};
|
|
controller.sendPickupOrder();
|
|
|
|
expect(controller.sendEmail).toHaveBeenCalledWith('claim-pickup-order', params);
|
|
});
|
|
});
|
|
|
|
describe('deleteClaim()', () => {
|
|
it('should perform a query and call showSuccess if the response is accept', () => {
|
|
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');
|
|
});
|
|
});
|
|
});
|
|
|