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

53 lines
1.7 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;
beforeEach(() => {
ngModule('claim');
});
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', () => {
let expectedPath = '/api/report/rpt-claim-pickup-order?claimFk=2';
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');
$httpBackend.when('POST', `/api/email/claim-pickup-order`, {claimFk: 2}).respond();
$httpBackend.expect('POST', `/api/email/claim-pickup-order`, {claimFk: 2}).respond();
controller.sendPickupOrder('ACCEPT');
$httpBackend.flush();
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Notification sent!');
});
});
});