Browse Source

Add tests for investments by month

pull/1089/head
Thomas 3 years ago
parent
commit
a42f6eec90
  1. 6
      apps/api/src/app/portfolio/portfolio-calculator-baln-buy-and-sell.spec.ts
  2. 6
      apps/api/src/app/portfolio/portfolio-calculator-baln-buy.spec.ts
  3. 4
      apps/api/src/app/portfolio/portfolio-calculator-no-orders.spec.ts
  4. 7
      apps/api/src/app/portfolio/portfolio-calculator-novn-buy-and-sell-partially.spec.ts

6
apps/api/src/app/portfolio/portfolio-calculator-baln-buy-and-sell.spec.ts

@ -62,6 +62,8 @@ describe('PortfolioCalculator', () => {
parseDate('2021-11-22') parseDate('2021-11-22')
); );
const investmentsByMonth = portfolioCalculator.getInvestmentsByMonth();
spy.mockRestore(); spy.mockRestore();
expect(currentPositions).toEqual({ expect(currentPositions).toEqual({
@ -91,6 +93,10 @@ describe('PortfolioCalculator', () => {
], ],
totalInvestment: new Big('0') totalInvestment: new Big('0')
}); });
expect(investmentsByMonth).toEqual([
{ date: '2021-11-01', investment: new Big('12.6') }
]);
}); });
}); });
}); });

6
apps/api/src/app/portfolio/portfolio-calculator-baln-buy.spec.ts

@ -51,6 +51,8 @@ describe('PortfolioCalculator', () => {
parseDate('2021-11-30') parseDate('2021-11-30')
); );
const investmentsByMonth = portfolioCalculator.getInvestmentsByMonth();
spy.mockRestore(); spy.mockRestore();
expect(currentPositions).toEqual({ expect(currentPositions).toEqual({
@ -80,6 +82,10 @@ describe('PortfolioCalculator', () => {
], ],
totalInvestment: new Big('273.2') totalInvestment: new Big('273.2')
}); });
expect(investmentsByMonth).toEqual([
{ date: '2021-11-01', investment: new Big('273.2') }
]);
}); });
}); });
}); });

4
apps/api/src/app/portfolio/portfolio-calculator-no-orders.spec.ts

@ -39,6 +39,8 @@ describe('PortfolioCalculator', () => {
new Date() new Date()
); );
const investmentsByMonth = portfolioCalculator.getInvestmentsByMonth();
spy.mockRestore(); spy.mockRestore();
expect(currentPositions).toEqual({ expect(currentPositions).toEqual({
@ -51,6 +53,8 @@ describe('PortfolioCalculator', () => {
positions: [], positions: [],
totalInvestment: new Big(0) totalInvestment: new Big(0)
}); });
expect(investmentsByMonth).toEqual([]);
}); });
}); });
}); });

7
apps/api/src/app/portfolio/portfolio-calculator-novn-buy-and-sell-partially.spec.ts

@ -62,6 +62,8 @@ describe('PortfolioCalculator', () => {
parseDate('2022-03-07') parseDate('2022-03-07')
); );
const investmentsByMonth = portfolioCalculator.getInvestmentsByMonth();
spy.mockRestore(); spy.mockRestore();
expect(currentPositions).toEqual({ expect(currentPositions).toEqual({
@ -91,6 +93,11 @@ describe('PortfolioCalculator', () => {
], ],
totalInvestment: new Big('75.80') totalInvestment: new Big('75.80')
}); });
expect(investmentsByMonth).toEqual([
{ date: '2022-03-01', investment: new Big('151.6') },
{ date: '2022-04-01', investment: new Big('-85.73') }
]);
}); });
}); });
}); });

Loading…
Cancel
Save