Extend unit tests (#99)

pull/102/head
Thomas 3 years ago committed by GitHub
parent e56514629f
commit 368de7dedc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,6 +17,7 @@ jest.mock('../services/data-provider.service', () => {
return { return {
DataProviderService: jest.fn().mockImplementation(() => { DataProviderService: jest.fn().mockImplementation(() => {
const today = format(new Date(), 'yyyy-MM-dd'); const today = format(new Date(), 'yyyy-MM-dd');
const yesterday = format(getYesterday(), 'yyyy-MM-dd');
return { return {
get: () => { get: () => {
@ -44,9 +45,11 @@ jest.mock('../services/data-provider.service', () => {
getHistorical: () => { getHistorical: () => {
return Promise.resolve({ return Promise.resolve({
BTCUSD: { BTCUSD: {
[yesterday]: 56710.122,
[today]: 57973.008 [today]: 57973.008
}, },
ETHUSD: { ETHUSD: {
[yesterday]: 3641.984,
[today]: 3915.337 [today]: 3915.337
} }
}); });
@ -214,7 +217,7 @@ describe('Portfolio', () => {
) )
} }
}, },
// allocationCurrent: 0.9999999559148652, allocationCurrent: 1,
allocationInvestment: 1, allocationInvestment: 1,
currency: Currency.USD, currency: Currency.USD,
exchange: UNKNOWN_KEY, exchange: UNKNOWN_KEY,
@ -225,7 +228,7 @@ describe('Portfolio', () => {
Currency.USD, Currency.USD,
baseCurrency baseCurrency
), ),
// marketPrice: 57973.008, marketPrice: 57973.008,
marketState: MarketState.open, marketState: MarketState.open,
name: 'Bitcoin USD', name: 'Bitcoin USD',
quantity: 1, quantity: 1,
@ -326,7 +329,7 @@ describe('Portfolio', () => {
Currency.USD, Currency.USD,
baseCurrency baseCurrency
), ),
// marketPrice: 57973.008, marketPrice: 3915.337,
name: 'Ethereum USD', name: 'Ethereum USD',
quantity: 0.2, quantity: 0.2,
transactionCount: 1, transactionCount: 1,
@ -357,7 +360,7 @@ describe('Portfolio', () => {
baseCurrency baseCurrency
), ),
investmentInOriginalCurrency: 0.2 * 991.49, investmentInOriginalCurrency: 0.2 * 991.49,
// marketPrice: 0, // marketPrice: 3915.337,
quantity: 0.2 quantity: 0.2
} }
}); });
@ -433,7 +436,7 @@ describe('Portfolio', () => {
baseCurrency baseCurrency
), ),
investmentInOriginalCurrency: 0.2 * 991.49 + 0.3 * 1050, investmentInOriginalCurrency: 0.2 * 991.49 + 0.3 * 1050,
// marketPrice: 0, // marketPrice: 3641.984,
quantity: 0.5 quantity: 0.5
} }
}); });
@ -582,8 +585,7 @@ describe('Portfolio', () => {
} }
]); ]);
// TODO: Fix expect(portfolio.getCommittedFunds()).toEqual(
/*expect(portfolio.getCommittedFunds()).toEqual(
exchangeRateDataService.toCurrency( exchangeRateDataService.toCurrency(
0.2 * 991.49, 0.2 * 991.49,
Currency.USD, Currency.USD,
@ -599,7 +601,7 @@ describe('Portfolio', () => {
Currency.USD, Currency.USD,
baseCurrency baseCurrency
) )
);*/ );
expect(portfolio.getFees()).toEqual( expect(portfolio.getFees()).toEqual(
exchangeRateDataService.toCurrency(3, Currency.USD, baseCurrency) exchangeRateDataService.toCurrency(3, Currency.USD, baseCurrency)
@ -611,12 +613,11 @@ describe('Portfolio', () => {
(0.2 * 991.49 - 0.1 * 1050 + 0.2 * 1050) / (0.2 - 0.1 + 0.2), (0.2 * 991.49 - 0.1 * 1050 + 0.2 * 1050) / (0.2 - 0.1 + 0.2),
currency: Currency.USD, currency: Currency.USD,
firstBuyDate: '2018-01-05T00:00:00.000Z', firstBuyDate: '2018-01-05T00:00:00.000Z',
// TODO: Fix investment: exchangeRateDataService.toCurrency(
/*investment: exchangeRateDataService.toCurrency(
0.2 * 991.49 - 0.1 * 1050 + 0.2 * 1050, 0.2 * 991.49 - 0.1 * 1050 + 0.2 * 1050,
Currency.USD, Currency.USD,
baseCurrency baseCurrency
),*/ ),
investmentInOriginalCurrency: 0.2 * 991.49 - 0.1 * 1050 + 0.2 * 1050, investmentInOriginalCurrency: 0.2 * 991.49 - 0.1 * 1050 + 0.2 * 1050,
// marketPrice: 0, // marketPrice: 0,
quantity: 0.2 - 0.1 + 0.2 quantity: 0.2 - 0.1 + 0.2

Loading…
Cancel
Save