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

49 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-08-09 10:54:29 +00:00
import './index';
describe('Client', () => {
describe('Component vnClientCreditInsuranceCreate', () => {
let controller;
let $scope;
let $httpBackend;
beforeEach(ngModule('client'));
2018-08-09 10:54:29 +00:00
2020-07-23 14:46:16 +00:00
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
2018-08-09 10:54:29 +00:00
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
$scope.form = {
$invalid: false
};
2020-03-17 10:17:50 +00:00
const $element = angular.element('<vn-client-credit-insurance-create></vn-client-credit-insurance-create>');
controller = $componentController('vnClientCreditInsuranceCreate', {$element, $scope});
controller.client = {id: 1101};
2018-08-09 10:54:29 +00:00
controller.card = {
reload: () => {}
};
}));
describe('onSubmit()', () => {
it('should perform a POST query', () => {
2023-01-16 14:18:24 +00:00
let started = Date.vnNew();
2018-08-09 10:54:29 +00:00
controller.creditClassification = {
2018-08-23 08:08:06 +00:00
started: started,
2018-08-09 10:54:29 +00:00
credit: 300,
grade: 1
};
let newData = {
2018-08-23 08:08:06 +00:00
started: started,
2018-08-09 10:54:29 +00:00
credit: 300,
grade: 1,
clientFk: 1101
2018-08-09 10:54:29 +00:00
};
$httpBackend.whenPOST(`creditClassifications/createWithInsurance`, newData).respond(200, true);
$httpBackend.expectPOST(`creditClassifications/createWithInsurance`, newData);
2018-08-09 10:54:29 +00:00
controller.onSubmit();
$httpBackend.flush();
});
});
});
});