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

43 lines
1.4 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;
2020-03-16 10:58:14 +00:00
let $scope;
2018-09-05 11:47:15 +00:00
beforeEach(ngModule('claim'));
2018-09-05 11:47:15 +00:00
2020-07-23 14:46:16 +00:00
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
2020-03-16 10:58:14 +00:00
$scope = $rootScope.$new();
2018-09-05 11:47:15 +00:00
$httpBackend = _$httpBackend_;
2020-03-16 10:58:14 +00:00
const $element = angular.element('<vn-claim-summary></vn-claim-summary>');
controller = $componentController('vnClaimSummary', {$element, $scope});
2020-03-17 10:17:50 +00:00
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', () => {
$httpBackend.expect('GET', `Claims/1/getSummary`).respond(200, 24);
2018-09-05 11:47:15 +00:00
controller.getSummary();
$httpBackend.expect('GET', `Claims/1/isEditable`).respond(200, true);
2018-09-05 11:47:15 +00:00
$httpBackend.flush();
expect(controller.summary).toEqual(24);
});
});
describe('$onChanges()', () => {
it('should call getSummary when item.id is defined', () => {
2020-02-26 12:22:52 +00:00
jest.spyOn(controller, 'getSummary');
2020-03-16 10:58:14 +00:00
2018-09-05 11:47:15 +00:00
controller.$onChanges();
expect(controller.getSummary).toHaveBeenCalledWith();
});
});
});
});