Browse Source

API tests fixed

csehatt741 3 weeks ago
committed by Attila Cseh
parent
commit
39d3ad4f49
  1. 3
      apps/api/src/app/export/export.service.ts
  2. 3
      apps/api/src/app/portfolio/calculator/portfolio-calculator-test-utils.ts
  3. 12
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts
  4. 8
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-sell.spec.ts
  5. 4
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy.spec.ts
  6. 8
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-buy-and-sell-partially.spec.ts
  7. 4
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-fee.spec.ts
  8. 4
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-googl-buy.spec.ts
  9. 4
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-item.spec.ts
  10. 4
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-liability.spec.ts
  11. 8
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-with-dividend.spec.ts
  12. 4
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell-partially.spec.ts
  13. 4
      apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.ts

3
apps/api/src/app/export/export.service.ts

@ -120,6 +120,7 @@ export class ExportService {
({ ({
accountId, accountId,
comment, comment,
currency,
date, date,
fee, fee,
id, id,
@ -137,7 +138,7 @@ export class ExportService {
quantity, quantity,
type, type,
unitPrice, unitPrice,
currency: SymbolProfile.currency, currency: currency ?? SymbolProfile.currency,
dataSource: SymbolProfile.dataSource, dataSource: SymbolProfile.dataSource,
date: date.toISOString(), date: date.toISOString(),
symbol: ['FEE', 'INTEREST', 'ITEM', 'LIABILITY'].includes(type) symbol: ['FEE', 'INTEREST', 'ITEM', 'LIABILITY'].includes(type)

3
apps/api/src/app/portfolio/calculator/portfolio-calculator-test-utils.ts

@ -6,10 +6,13 @@ export const activityDummyData = {
comment: undefined, comment: undefined,
createdAt: new Date(), createdAt: new Date(),
currency: undefined, currency: undefined,
fee: undefined,
feeInBaseCurrency: undefined, feeInBaseCurrency: undefined,
id: undefined, id: undefined,
isDraft: false, isDraft: false,
symbolProfileId: undefined, symbolProfileId: undefined,
unitPrice: undefined,
unitPriceInBaseCurrency: undefined,
updatedAt: new Date(), updatedAt: new Date(),
userId: undefined, userId: undefined,
value: undefined, value: undefined,

12
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts

@ -91,7 +91,7 @@ describe('PortfolioCalculator', () => {
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2021-11-22'), date: new Date('2021-11-22'),
fee: 1.55, feeInBaseCurrency: 1.55,
quantity: 2, quantity: 2,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -101,12 +101,12 @@ describe('PortfolioCalculator', () => {
symbol: 'BALN.SW' symbol: 'BALN.SW'
}, },
type: 'BUY', type: 'BUY',
unitPrice: 142.9 unitPriceInBaseCurrency: 142.9
}, },
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2021-11-30'), date: new Date('2021-11-30'),
fee: 1.65, feeInBaseCurrency: 1.65,
quantity: 1, quantity: 1,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -116,12 +116,12 @@ describe('PortfolioCalculator', () => {
symbol: 'BALN.SW' symbol: 'BALN.SW'
}, },
type: 'SELL', type: 'SELL',
unitPrice: 136.6 unitPriceInBaseCurrency: 136.6
}, },
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2021-11-30'), date: new Date('2021-11-30'),
fee: 0, feeInBaseCurrency: 0,
quantity: 1, quantity: 1,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -131,7 +131,7 @@ describe('PortfolioCalculator', () => {
symbol: 'BALN.SW' symbol: 'BALN.SW'
}, },
type: 'SELL', type: 'SELL',
unitPrice: 136.6 unitPriceInBaseCurrency: 136.6
} }
]; ];

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

@ -91,7 +91,7 @@ describe('PortfolioCalculator', () => {
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2021-11-22'), date: new Date('2021-11-22'),
fee: 1.55, feeInBaseCurrency: 1.55,
quantity: 2, quantity: 2,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -101,12 +101,12 @@ describe('PortfolioCalculator', () => {
symbol: 'BALN.SW' symbol: 'BALN.SW'
}, },
type: 'BUY', type: 'BUY',
unitPrice: 142.9 unitPriceInBaseCurrency: 142.9
}, },
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2021-11-30'), date: new Date('2021-11-30'),
fee: 1.65, feeInBaseCurrency: 1.65,
quantity: 2, quantity: 2,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -116,7 +116,7 @@ describe('PortfolioCalculator', () => {
symbol: 'BALN.SW' symbol: 'BALN.SW'
}, },
type: 'SELL', type: 'SELL',
unitPrice: 136.6 unitPriceInBaseCurrency: 136.6
} }
]; ];

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

@ -91,7 +91,7 @@ describe('PortfolioCalculator', () => {
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2021-11-30'), date: new Date('2021-11-30'),
fee: 1.55, feeInBaseCurrency: 1.55,
quantity: 2, quantity: 2,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -101,7 +101,7 @@ describe('PortfolioCalculator', () => {
symbol: 'BALN.SW' symbol: 'BALN.SW'
}, },
type: 'BUY', type: 'BUY',
unitPrice: 136.6 unitPriceInBaseCurrency: 136.6
} }
]; ];

8
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-btcusd-buy-and-sell-partially.spec.ts

@ -105,7 +105,7 @@ describe('PortfolioCalculator', () => {
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2015-01-01'), date: new Date('2015-01-01'),
fee: 0, feeInBaseCurrency: 0,
quantity: 2, quantity: 2,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -115,12 +115,12 @@ describe('PortfolioCalculator', () => {
symbol: 'BTCUSD' symbol: 'BTCUSD'
}, },
type: 'BUY', type: 'BUY',
unitPrice: 320.43 unitPriceInBaseCurrency: 320.43
}, },
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2017-12-31'), date: new Date('2017-12-31'),
fee: 0, feeInBaseCurrency: 0,
quantity: 1, quantity: 1,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -130,7 +130,7 @@ describe('PortfolioCalculator', () => {
symbol: 'BTCUSD' symbol: 'BTCUSD'
}, },
type: 'SELL', type: 'SELL',
unitPrice: 14156.4 unitPriceInBaseCurrency: 14156.4
} }
]; ];

4
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-fee.spec.ts

@ -91,7 +91,7 @@ describe('PortfolioCalculator', () => {
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2021-09-01'), date: new Date('2021-09-01'),
fee: 49, feeInBaseCurrency: 49,
quantity: 0, quantity: 0,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -101,7 +101,7 @@ describe('PortfolioCalculator', () => {
symbol: '2c463fb3-af07-486e-adb0-8301b3d72141' symbol: '2c463fb3-af07-486e-adb0-8301b3d72141'
}, },
type: 'FEE', type: 'FEE',
unitPrice: 0 unitPriceInBaseCurrency: 0
} }
]; ];

4
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-googl-buy.spec.ts

@ -104,7 +104,7 @@ describe('PortfolioCalculator', () => {
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2023-01-03'), date: new Date('2023-01-03'),
fee: 1, feeInBaseCurrency: 1,
quantity: 1, quantity: 1,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -114,7 +114,7 @@ describe('PortfolioCalculator', () => {
symbol: 'GOOGL' symbol: 'GOOGL'
}, },
type: 'BUY', type: 'BUY',
unitPrice: 89.12 unitPriceInBaseCurrency: 89.12
} }
]; ];

4
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-item.spec.ts

@ -91,7 +91,7 @@ describe('PortfolioCalculator', () => {
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2022-01-01'), date: new Date('2022-01-01'),
fee: 0, feeInBaseCurrency: 0,
quantity: 1, quantity: 1,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -101,7 +101,7 @@ describe('PortfolioCalculator', () => {
symbol: 'dac95060-d4f2-4653-a253-2c45e6fb5cde' symbol: 'dac95060-d4f2-4653-a253-2c45e6fb5cde'
}, },
type: 'ITEM', type: 'ITEM',
unitPrice: 500000 unitPriceInBaseCurrency: 500000
} }
]; ];

4
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-liability.spec.ts

@ -91,7 +91,7 @@ describe('PortfolioCalculator', () => {
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2023-01-01'), // Date in future date: new Date('2023-01-01'), // Date in future
fee: 0, feeInBaseCurrency: 0,
quantity: 1, quantity: 1,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -101,7 +101,7 @@ describe('PortfolioCalculator', () => {
symbol: '55196015-1365-4560-aa60-8751ae6d18f8' symbol: '55196015-1365-4560-aa60-8751ae6d18f8'
}, },
type: 'LIABILITY', type: 'LIABILITY',
unitPrice: 3000 unitPriceInBaseCurrency: 3000
} }
]; ];

8
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-msft-buy-with-dividend.spec.ts

@ -104,7 +104,7 @@ describe('PortfolioCalculator', () => {
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2021-09-16'), date: new Date('2021-09-16'),
fee: 19, feeInBaseCurrency: 19,
quantity: 1, quantity: 1,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -114,12 +114,12 @@ describe('PortfolioCalculator', () => {
symbol: 'MSFT' symbol: 'MSFT'
}, },
type: 'BUY', type: 'BUY',
unitPrice: 298.58 unitPriceInBaseCurrency: 298.58
}, },
{ {
...activityDummyData, ...activityDummyData,
date: new Date('2021-11-16'), date: new Date('2021-11-16'),
fee: 0, feeInBaseCurrency: 0,
quantity: 1, quantity: 1,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
@ -129,7 +129,7 @@ describe('PortfolioCalculator', () => {
symbol: 'MSFT' symbol: 'MSFT'
}, },
type: 'DIVIDEND', type: 'DIVIDEND',
unitPrice: 0.62 unitPriceInBaseCurrency: 0.62
} }
]; ];

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

@ -105,13 +105,15 @@ describe('PortfolioCalculator', () => {
...activityDummyData, ...activityDummyData,
...activity, ...activity,
date: parseDate(activity.date), date: parseDate(activity.date),
feeInBaseCurrency: activity.fee,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
currency: activity.currency, currency: activity.currency,
dataSource: activity.dataSource, dataSource: activity.dataSource,
name: 'Novartis AG', name: 'Novartis AG',
symbol: activity.symbol symbol: activity.symbol
} },
unitPriceInBaseCurrency: activity.unitPrice
})); }));
const portfolioCalculator = portfolioCalculatorFactory.createCalculator({ const portfolioCalculator = portfolioCalculatorFactory.createCalculator({

4
apps/api/src/app/portfolio/calculator/roai/portfolio-calculator-novn-buy-and-sell.spec.ts

@ -105,13 +105,15 @@ describe('PortfolioCalculator', () => {
...activityDummyData, ...activityDummyData,
...activity, ...activity,
date: parseDate(activity.date), date: parseDate(activity.date),
feeInBaseCurrency: activity.fee,
SymbolProfile: { SymbolProfile: {
...symbolProfileDummyData, ...symbolProfileDummyData,
currency: activity.currency, currency: activity.currency,
dataSource: activity.dataSource, dataSource: activity.dataSource,
name: 'Novartis AG', name: 'Novartis AG',
symbol: activity.symbol symbol: activity.symbol
} },
unitPriceInBaseCurrency: activity.unitPrice
})); }));
const portfolioCalculator = portfolioCalculatorFactory.createCalculator({ const portfolioCalculator = portfolioCalculatorFactory.createCalculator({

Loading…
Cancel
Save