2018-11-14 09:55:15 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('Client', () => {
|
|
|
|
describe('Component vnClientRiskIndex', () => {
|
|
|
|
let $componentController;
|
|
|
|
let $scope;
|
|
|
|
let controller;
|
|
|
|
|
2018-12-22 10:59:26 +00:00
|
|
|
beforeEach(ngModule('client'));
|
2018-11-14 09:55:15 +00:00
|
|
|
|
|
|
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
|
|
|
|
$componentController = _$componentController_;
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
controller = $componentController('vnClientRiskIndex', {$scope: $scope});
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('risks() setter', () => {
|
|
|
|
it('should calculate the balance for each line from the oldest date to the newest', () => {
|
|
|
|
let risks = [
|
|
|
|
{credit: 100, debit: 0},
|
|
|
|
{credit: 100, debit: 0},
|
|
|
|
{credit: 0, debit: 300}
|
|
|
|
];
|
|
|
|
controller.$.model = {data: risks};
|
|
|
|
controller.risks = risks;
|
|
|
|
|
|
|
|
expect(controller.risks[0].balance).toEqual(-100);
|
|
|
|
expect(controller.risks[1].balance).toEqual(-200);
|
|
|
|
expect(controller.risks[2].balance).toEqual(-300);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|