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

32 lines
1.0 KiB
JavaScript

import './index.js';
describe('Claim', () => {
describe('Component vnClaimCard', () => {
let $scope;
let controller;
let $httpBackend;
let $state;
beforeEach(ngModule('claim'));
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => {
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
$state = {params: {id: 1}};
controller = $componentController('vnClaimCard', {$scope, $state});
}));
describe('getCard()', () => {
it(`should make a query and save the data in claim`, () => {
let json = encodeURIComponent(JSON.stringify(controller.filter));
$httpBackend.expectGET(`/claim/api/Claims/${controller.$state.params.id}?filter=${json}`).respond({id: 1});
controller.getCard();
$httpBackend.flush();
expect(controller.claim).toEqual({id: 1});
});
});
});
});