2018-08-09 10:54:29 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('Client', () => {
|
|
|
|
describe('Component vnClientCreditInsuranceCreate', () => {
|
|
|
|
let controller;
|
|
|
|
let $scope;
|
|
|
|
let $httpBackend;
|
|
|
|
|
2019-09-13 14:09:14 +00:00
|
|
|
beforeEach(angular.mock.module('client', $translateProvider => {
|
|
|
|
$translateProvider.translations('en', {});
|
|
|
|
}));
|
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
|
|
|
|
};
|
2018-12-22 10:59:26 +00:00
|
|
|
controller = $componentController('vnClientCreditInsuranceCreate', {$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
|
|
|
|
};
|
|
|
|
|
|
|
|
$httpBackend.whenPOST(`/client/api/creditClassifications/createWithInsurance`, newData).respond(200, true);
|
|
|
|
$httpBackend.expectPOST(`/client/api/creditClassifications/createWithInsurance`, newData);
|
|
|
|
controller.onSubmit();
|
|
|
|
$httpBackend.flush();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|