34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
import './index';
|
|
|
|
describe('Client', () => {
|
|
describe('Component vnClientRiskIndex', () => {
|
|
let $componentController;
|
|
let $scope;
|
|
let controller;
|
|
|
|
beforeEach(ngModule('client'));
|
|
|
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
|
|
$componentController = _$componentController_;
|
|
$scope = $rootScope.$new();
|
|
controller = $componentController('vnClientRiskIndex', {$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);
|
|
});
|
|
});
|
|
});
|
|
});
|