2020-08-27 09:16:36 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('Client', () => {
|
|
|
|
describe('Component vnClientBalancCreate', () => {
|
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
|
|
|
let $httpParamSerializer;
|
|
|
|
|
|
|
|
beforeEach(ngModule('client'));
|
|
|
|
|
|
|
|
beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$httpParamSerializer = _$httpParamSerializer_;
|
|
|
|
let $scope = $rootScope.$new();
|
|
|
|
const $element = angular.element('<vn-client-balance-create></vn-client-balance-create>');
|
|
|
|
const $transclude = {
|
|
|
|
$$boundTransclude: {
|
|
|
|
$$slots: []
|
|
|
|
}
|
|
|
|
};
|
|
|
|
controller = $componentController('vnClientBalanceCreate', {$element, $scope, $transclude});
|
|
|
|
controller.receipt = {
|
|
|
|
clientFk: 101,
|
|
|
|
companyFk: 442
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('bankSelection() setter', () => {
|
|
|
|
it('should set the receipt description property', () => {
|
|
|
|
controller.bankSelection = {
|
|
|
|
id: 1,
|
|
|
|
bank: 'Cash',
|
|
|
|
accountingType: {
|
|
|
|
id: 2,
|
|
|
|
receiptDescription: 'Cash'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(controller.receipt.description).toEqual('Cash');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('getAmountPaid()', () => {
|
|
|
|
it('should make an http GET query and then set the receipt amountPaid property', () => {
|
|
|
|
controller.$params = {id: 101};
|
|
|
|
const receipt = controller.receipt;
|
|
|
|
const filter = {
|
|
|
|
where: {
|
|
|
|
clientFk: 101,
|
|
|
|
companyFk: 442
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const serializedParams = $httpParamSerializer({filter});
|
2020-10-26 07:38:43 +00:00
|
|
|
$httpBackend.expect('GET', `ClientRisks?${serializedParams}`).respond([{amount: 20}]);
|
2020-08-27 09:16:36 +00:00
|
|
|
controller.getAmountPaid();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(receipt.amountPaid).toEqual(20);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('responseHandler()', () => {
|
|
|
|
it('should make an http POST query and then call to the parent responseHandler() method', () => {
|
|
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
|
|
|
|
controller.$params = {id: 101};
|
|
|
|
|
2021-01-22 14:46:03 +00:00
|
|
|
$httpBackend.expect('POST', `Clients/101/createReceipt`).respond({id: 1});
|
2020-08-27 09:16:36 +00:00
|
|
|
controller.responseHandler('accept');
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|
2020-12-16 15:25:19 +00:00
|
|
|
|
|
|
|
describe('deliveredAmount() setter', () => {
|
|
|
|
it('should set the deliveredAmount property', () => {
|
|
|
|
controller.amountPaid = 999;
|
|
|
|
controller.deliveredAmount = 1000;
|
|
|
|
|
|
|
|
expect(controller.amountToReturn).toEqual(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('accountShortToStandard()', () => {
|
|
|
|
it('should get de account in stardard format', () => {
|
|
|
|
const shortAccount = '4.3';
|
|
|
|
controller.accountShortToStandard(shortAccount);
|
|
|
|
|
|
|
|
expect(controller.receipt.compensationAccount).toEqual('4000000003');
|
|
|
|
});
|
|
|
|
});
|
2020-08-27 09:16:36 +00:00
|
|
|
});
|
|
|
|
});
|