salix/modules/client/front/credit-insurance/create/index.spec.js

49 lines
1.6 KiB
JavaScript

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
};
const $element = angular.element('<vn-client-credit-insurance-create></vn-client-credit-insurance-create>');
controller = $componentController('vnClientCreditInsuranceCreate', {$element, $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(`creditClassifications/createWithInsurance`, newData).respond(200, true);
$httpBackend.expectPOST(`creditClassifications/createWithInsurance`, newData);
controller.onSubmit();
$httpBackend.flush();
});
});
});
});