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

41 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-09-05 11:47:15 +00:00
import './index.js';
import crudModel from 'core/mocks/crud-model';
2018-09-05 11:47:15 +00:00
describe('Claim', () => {
describe('Component summary', () => {
let controller;
let $httpBackend;
2019-09-13 14:09:14 +00:00
beforeEach(angular.mock.module('claim', $translateProvider => {
$translateProvider.translations('en', {});
}));
2018-09-05 11:47:15 +00:00
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
2018-09-05 11:47:15 +00:00
$httpBackend = _$httpBackend_;
controller = $componentController('vnClaimSummary');
controller.claim = {id: 1};
controller.$.model = crudModel;
2018-09-05 11:47:15 +00:00
}));
describe('getSummary()', () => {
it('should perform a query to set summary', () => {
2018-09-05 11:47:15 +00:00
$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', () => {
2018-09-05 11:47:15 +00:00
spyOn(controller, 'getSummary');
controller.$onChanges();
expect(controller.getSummary).toHaveBeenCalledWith();
});
});
});
});