salix/client/claim/src/card/index.spec.js

37 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-08-24 11:16:11 +00:00
import './index.js';
describe('Claim', () => {
describe('Component vnClaimCard', () => {
let $componentController;
let $scope;
let controller;
let $httpBackend;
let $state;
beforeEach(() => {
angular.mock.module('claim');
});
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => {
$componentController = _$componentController_;
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$scope = $rootScope.$new();
$state = {params: {id: 1}};
controller = $componentController('vnClaimCard', {$scope: $scope, $state: $state});
}));
2018-10-03 06:00:19 +00:00
describe('getCard()', () => {
2018-08-24 11:16:11 +00:00
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});
2018-10-03 06:00:19 +00:00
controller.getCard();
2018-08-24 11:16:11 +00:00
$httpBackend.flush();
expect(controller.claim).toEqual({id: 1});
});
});
});
});