Browse Source

Extend tests

pull/5481/head
Thomas Kaul 1 month ago
parent
commit
a91e34cc06
  1. 21
      apps/api/src/services/activities/activities.service.spec.ts

21
apps/api/src/services/activities/activities.service.spec.ts

@ -181,6 +181,17 @@ describe('ActivitiesService', () => {
expect(data).not.toHaveProperty('currency'); expect(data).not.toHaveProperty('currency');
}); });
it('does not store the currency if it is the currency of the existing custom asset profile (clone)', async () => {
const data = await getCreatedActivityData({
assetProfile: { currency: 'EUR', id: 'asset-profile-id' },
currency: 'EUR',
dataSource: DataSource.MANUAL,
symbol: 'GF_COPX'
});
expect(data).not.toHaveProperty('currency');
});
it('stores the currency of an activity with a new asset profile of a data provider', async () => { it('stores the currency of an activity with a new asset profile of a data provider', async () => {
const data = await getCreatedActivityData({ currency: 'USD' }); const data = await getCreatedActivityData({ currency: 'USD' });
@ -190,11 +201,13 @@ describe('ActivitiesService', () => {
async function getCreatedActivityData({ async function getCreatedActivityData({
assetProfile, assetProfile,
currency, currency,
dataSource = DataSource.YAHOO dataSource = DataSource.YAHOO,
symbol = 'VT'
}: { }: {
assetProfile?: { currency: string }; assetProfile?: { currency: string; id?: string };
currency: string; currency: string;
dataSource?: DataSource; dataSource?: DataSource;
symbol?: string;
}) { }) {
const create = jest.fn(({ data }: Prisma.OrderCreateArgs) => { const create = jest.fn(({ data }: Prisma.OrderCreateArgs) => {
return { return {
@ -230,8 +243,8 @@ describe('ActivitiesService', () => {
quantity: 1, quantity: 1,
SymbolProfile: { SymbolProfile: {
connectOrCreate: { connectOrCreate: {
create: { dataSource, currency: 'USD', symbol: 'VT' }, create: { dataSource, symbol, currency: 'USD' },
where: { dataSource_symbol: { dataSource, symbol: 'VT' } } where: { dataSource_symbol: { dataSource, symbol } }
} }
}, },
type: 'BUY', type: 'BUY',

Loading…
Cancel
Save