2018-08-09 10:54:29 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('Client', () => {
|
|
|
|
describe('Component vnClientCreditInsuranceCreate', () => {
|
|
|
|
let controller;
|
|
|
|
let $scope;
|
|
|
|
let $httpBackend;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('client'));
|
2018-08-09 10:54:29 +00:00
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(angular.mock.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});
|
2018-08-09 10:54:29 +00:00
|
|
|
controller.client = {id: 101};
|
|
|
|
controller.card = {
|
|
|
|
reload: () => {}
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('onSubmit()', () => {
|
|
|
|
it('should perform a POST query', () => {
|
2018-08-23 08:08:06 +00:00
|
|
|
let started = new Date();
|
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: 101
|
|
|
|
};
|
|
|
|
|
2019-10-24 22:53:53 +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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|