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

43 lines
1.4 KiB
JavaScript

import './index.js';
import crudModel from 'core/mocks/crud-model';
describe('Claim', () => {
describe('Component summary', () => {
let controller;
let $httpBackend;
let $scope;
beforeEach(ngModule('claim'));
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
$scope = $rootScope.$new();
$httpBackend = _$httpBackend_;
const $element = angular.element('<vn-claim-summary></vn-claim-summary>');
controller = $componentController('vnClaimSummary', {$element, $scope});
controller.claim = {id: 1};
controller.$.model = crudModel;
}));
describe('getSummary()', () => {
it('should perform a query to set summary', () => {
$httpBackend.expect('GET', `Claims/1/getSummary`).respond(200, 24);
controller.getSummary();
$httpBackend.expect('GET', `Claims/1/isEditable`).respond(200, true);
$httpBackend.flush();
expect(controller.summary).toEqual(24);
});
});
describe('$onChanges()', () => {
it('should call getSummary when item.id is defined', () => {
jest.spyOn(controller, 'getSummary');
controller.$onChanges();
expect(controller.getSummary).toHaveBeenCalledWith();
});
});
});
});