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

48 lines
1.5 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
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => {
2018-08-09 10:54:29 +00:00
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
$scope.form = {
$invalid: false
};
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(`creditClassifications/createWithInsurance`, newData).respond(200, true);
$httpBackend.expectPOST(`creditClassifications/createWithInsurance`, newData);
2018-08-09 10:54:29 +00:00
controller.onSubmit();
$httpBackend.flush();
});
});
});
});