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

39 lines
1.3 KiB
JavaScript

import './index.js';
describe('Claim', () => {
describe('Component summary', () => {
let controller;
let $httpBackend;
beforeEach(angular.mock.module('claim', $translateProvider => {
$translateProvider.translations('en', {});
}));
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
controller = $componentController('vnClaimSummary');
controller.claim = {id: 1};
}));
describe('getSummary()', () => {
it('should perform a query to set summary', () => {
$httpBackend.when('GET', `/claim/api/Claims/1/getSummary`).respond(200, 24);
$httpBackend.expect('GET', `/claim/api/Claims/1/getSummary`);
controller.getSummary();
$httpBackend.flush();
expect(controller.summary).toEqual(24);
});
});
describe('$onChanges()', () => {
it('should call getSummary when item.id is defined', () => {
spyOn(controller, 'getSummary');
controller.$onChanges();
expect(controller.getSummary).toHaveBeenCalledWith();
});
});
});
});