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

50 lines
1.6 KiB
JavaScript

import './index';
describe('Client', () => {
describe('Component vnClientCreditInsuranceCreate', () => {
let controller;
let $scope;
let $httpBackend;
beforeEach(angular.mock.module('client', $translateProvider => {
$translateProvider.translations('en', {});
}));
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();
});
});
});
});