2018-09-05 11:47:15 +00:00
|
|
|
import './index.js';
|
2019-10-18 07:53:30 +00:00
|
|
|
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-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('claim'));
|
2018-09-05 11:47:15 +00:00
|
|
|
|
2018-12-22 10:59:26 +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};
|
2019-10-18 07:53:30 +00:00
|
|
|
controller.$.model = crudModel;
|
2018-09-05 11:47:15 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('getSummary()', () => {
|
2018-12-22 10:59:26 +00:00
|
|
|
it('should perform a query to set summary', () => {
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('GET', `Claims/1/getSummary`).respond(200, 24);
|
|
|
|
$httpBackend.expect('GET', `Claims/1/getSummary`);
|
2018-09-05 11:47:15 +00:00
|
|
|
controller.getSummary();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.summary).toEqual(24);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('$onChanges()', () => {
|
2018-12-22 10:59:26 +00:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|