import './index'; describe('Client', () => { describe('Component vnClientCreditInsuranceCreate', () => { let controller; let $scope; let $httpBackend; beforeEach(ngModule('client')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.form = { $invalid: false }; controller = $componentController('vnClientCreditInsuranceCreate', {$scope}); controller.client = {id: 101}; controller.card = { reload: () => {} }; })); describe('onSubmit()', () => { it('should perform a POST query', () => { let started = new Date(); controller.creditClassification = { started: started, credit: 300, grade: 1 }; let newData = { started: started, credit: 300, grade: 1, clientFk: 101 }; $httpBackend.whenPOST(`/client/api/creditClassifications/createWithInsurance`, newData).respond(200, true); $httpBackend.expectPOST(`/client/api/creditClassifications/createWithInsurance`, newData); controller.onSubmit(); $httpBackend.flush(); }); }); }); });