66 lines
2.0 KiB
JavaScript
66 lines
2.0 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', () => {
|
|
jest.spyOn(controller.vnReport, 'show');
|
|
|
|
window.open = jasmine.createSpy('open');
|
|
const params = {
|
|
recipientId: claim.clientFk,
|
|
claimId: claim.id
|
|
};
|
|
controller.showPickupOrder();
|
|
|
|
expect(controller.vnReport.show).toHaveBeenCalledWith('claim-pickup-order', 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,
|
|
claimId: claim.id
|
|
};
|
|
controller.sendPickupOrder();
|
|
|
|
expect(controller.vnEmail.send).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');
|
|
});
|
|
});
|
|
});
|
|
|