|
|
@ -159,14 +159,12 @@ function createWatchlistItem({ |
|
|
function createPortfolioTableService({ |
|
|
function createPortfolioTableService({ |
|
|
accounts = [], |
|
|
accounts = [], |
|
|
chart = [{ date: '2024-01-01' }], |
|
|
chart = [{ date: '2024-01-01' }], |
|
|
errors = [], |
|
|
|
|
|
holdings = [], |
|
|
holdings = [], |
|
|
performance = createPerformance(), |
|
|
performance = createPerformance(), |
|
|
watchlist = [] |
|
|
watchlist = [] |
|
|
}: { |
|
|
}: { |
|
|
accounts?: AccountWithValue[]; |
|
|
accounts?: AccountWithValue[]; |
|
|
chart?: HistoricalDataItem[]; |
|
|
chart?: HistoricalDataItem[]; |
|
|
errors?: PortfolioPerformanceResponse['errors']; |
|
|
|
|
|
holdings?: PortfolioPosition[]; |
|
|
holdings?: PortfolioPosition[]; |
|
|
performance?: PortfolioPerformanceResponse['performance']; |
|
|
performance?: PortfolioPerformanceResponse['performance']; |
|
|
watchlist?: WatchlistResponse['watchlist']; |
|
|
watchlist?: WatchlistResponse['watchlist']; |
|
|
@ -182,12 +180,7 @@ function createPortfolioTableService({ |
|
|
const portfolioService = { |
|
|
const portfolioService = { |
|
|
getAccountsWithAggregations: jest.fn().mockResolvedValue({ accounts }), |
|
|
getAccountsWithAggregations: jest.fn().mockResolvedValue({ accounts }), |
|
|
getDetails: jest.fn().mockResolvedValue({ holdings }), |
|
|
getDetails: jest.fn().mockResolvedValue({ holdings }), |
|
|
getPerformance: jest.fn().mockResolvedValue({ |
|
|
getPerformance: jest.fn().mockResolvedValue({ chart, performance }) |
|
|
chart, |
|
|
|
|
|
errors, |
|
|
|
|
|
performance, |
|
|
|
|
|
hasErrors: errors.length > 0 |
|
|
|
|
|
}) |
|
|
|
|
|
} as unknown as PortfolioService; |
|
|
} as unknown as PortfolioService; |
|
|
|
|
|
|
|
|
const watchlistService = { |
|
|
const watchlistService = { |
|
|
@ -415,25 +408,6 @@ describe('PortfolioTableService', () => { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('tells the asset profiles of which the market data is delayed', async () => { |
|
|
|
|
|
const result = await getPerformanceTable({ |
|
|
|
|
|
errors: [ |
|
|
|
|
|
{ dataSource: DataSource.MANUAL, symbol: 'AAPL' }, |
|
|
|
|
|
{ dataSource: DataSource.YAHOO, symbol: 'AAPL' } |
|
|
|
|
|
] |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
expect(result).toContain( |
|
|
|
|
|
'Market data is delayed for: AAPL (MANUAL), AAPL (YAHOO)' |
|
|
|
|
|
); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('tells no delay of the market data if there is no error', async () => { |
|
|
|
|
|
const result = await getPerformanceTable(); |
|
|
|
|
|
|
|
|
|
|
|
expect(result).not.toContain('Market data is delayed'); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('tells that no performance is found if the chart is empty', async () => { |
|
|
it('tells that no performance is found if the chart is empty', async () => { |
|
|
const result = await getPerformanceTable({ chart: [] }); |
|
|
const result = await getPerformanceTable({ chart: [] }); |
|
|
|
|
|
|
|
|
|