2019-02-12 06:42:19 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('Item Component vnClaimDescriptor', () => {
|
|
|
|
let $httpBackend;
|
|
|
|
let controller;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('claim'));
|
2019-02-12 06:42:19 +00:00
|
|
|
|
|
|
|
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
controller = $componentController('vnClaimDescriptor');
|
|
|
|
controller.claim = {id: 2};
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('showPickupOrder()', () => {
|
|
|
|
it('should open a new window showing a pickup order PDF document', () => {
|
2019-10-24 22:53:53 +00:00
|
|
|
let expectedPath = 'report/rpt-claim-pickup-order?claimFk=2';
|
2019-02-12 06:42:19 +00:00
|
|
|
spyOn(window, 'open');
|
|
|
|
controller.showPickupOrder();
|
|
|
|
|
|
|
|
expect(window.open).toHaveBeenCalledWith(expectedPath);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('confirmPickupOrder()', () => {
|
|
|
|
it('should call confirmPickupOrder.show()', () => {
|
|
|
|
controller.$scope.confirmPickupOrder = {
|
|
|
|
show: jasmine.createSpy('show')
|
|
|
|
};
|
|
|
|
controller.claim = {id: 2};
|
|
|
|
controller.confirmPickupOrder();
|
|
|
|
|
|
|
|
expect(controller.$scope.confirmPickupOrder.show).toHaveBeenCalledWith();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('sendPickupOrder(response)', () => {
|
|
|
|
it('should make a query and call vnApp.showMessage() if the response is ACCEPT', () => {
|
|
|
|
spyOn(controller.vnApp, 'showMessage');
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('POST', `email/claim-pickup-order`, {claimFk: 2}).respond();
|
|
|
|
$httpBackend.expect('POST', `email/claim-pickup-order`, {claimFk: 2}).respond();
|
2019-02-12 06:42:19 +00:00
|
|
|
controller.sendPickupOrder('ACCEPT');
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Notification sent!');
|
|
|
|
});
|
|
|
|
});
|
2019-06-14 07:29:23 +00:00
|
|
|
|
|
|
|
describe('confirmDeleteClaim()', () => {
|
|
|
|
it('should call confirmDeleteClaim.show()', () => {
|
|
|
|
controller.$scope.confirmDeleteClaim = {
|
|
|
|
show: jasmine.createSpy('show')
|
|
|
|
};
|
|
|
|
controller.claim = {id: 2};
|
|
|
|
controller.confirmDeleteClaim();
|
|
|
|
|
|
|
|
expect(controller.$scope.confirmDeleteClaim.show).toHaveBeenCalledWith();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('deleteClaime(response)', () => {
|
|
|
|
it('should perform a query and call showSuccess if the response is ACCEPT', () => {
|
|
|
|
let response = 'ACCEPT';
|
|
|
|
controller.claim = {id: 2};
|
|
|
|
|
|
|
|
spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
spyOn(controller.$state, 'go');
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('DELETE', `Claims/2`).respond(200);
|
|
|
|
$httpBackend.expect('DELETE', `Claims/2`);
|
2019-06-14 07:29:23 +00:00
|
|
|
controller.deleteClaim(response);
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Claim deleted!');
|
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('claim.index');
|
|
|
|
});
|
|
|
|
});
|
2019-02-12 06:42:19 +00:00
|
|
|
});
|
|
|
|
|