Bug/1606 wrong update of new added deposit (#1608)
* chore: fix for accounts update * chore: fix for accounts update Co-authored-by: maciek <maciek@vegaprotocol.io>
This commit is contained in:
parent
2031a57b48
commit
15e6c4ffef
@ -1,6 +1,6 @@
|
|||||||
import { AccountType } from '@vegaprotocol/types';
|
import { AccountType } from '@vegaprotocol/types';
|
||||||
import type { AccountFields, Account } from './accounts-data-provider';
|
import type { AccountFields, Account } from './accounts-data-provider';
|
||||||
import { getAccountData } from './accounts-data-provider';
|
import { getAccountData, getId } from './accounts-data-provider';
|
||||||
|
|
||||||
describe('getAccountData', () => {
|
describe('getAccountData', () => {
|
||||||
it('should return the correct aggregated data', () => {
|
it('should return the correct aggregated data', () => {
|
||||||
@ -9,6 +9,41 @@ describe('getAccountData', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getId', () => {
|
||||||
|
it('should return the correct string', () => {
|
||||||
|
expect(
|
||||||
|
getId({
|
||||||
|
type: AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
balance: '1',
|
||||||
|
asset: { id: 'assetId' },
|
||||||
|
market: null,
|
||||||
|
})
|
||||||
|
).toEqual(
|
||||||
|
getId({
|
||||||
|
type: AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
balance: '1',
|
||||||
|
assetId: 'assetId',
|
||||||
|
marketId: '',
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
getId({
|
||||||
|
type: AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
balance: '1',
|
||||||
|
asset: { id: 'assetId' },
|
||||||
|
market: { id: 'testId' },
|
||||||
|
})
|
||||||
|
).toEqual(
|
||||||
|
getId({
|
||||||
|
type: AccountType.ACCOUNT_TYPE_GENERAL,
|
||||||
|
balance: '1',
|
||||||
|
assetId: 'assetId',
|
||||||
|
marketId: 'testId',
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const accounts = [
|
const accounts = [
|
||||||
{
|
{
|
||||||
__typename: 'Account',
|
__typename: 'Account',
|
||||||
|
@ -37,7 +37,7 @@ export const getId = (
|
|||||||
) =>
|
) =>
|
||||||
isAccount(account)
|
isAccount(account)
|
||||||
? `${account.type}-${account.asset.id}-${account.market?.id ?? 'null'}`
|
? `${account.type}-${account.asset.id}-${account.market?.id ?? 'null'}`
|
||||||
: `${account.type}-${account.assetId}-${account.marketId}`;
|
: `${account.type}-${account.assetId}-${account.marketId || 'null'}`;
|
||||||
|
|
||||||
export type Account = Omit<AccountFieldsFragment, 'market' | 'asset'> & {
|
export type Account = Omit<AccountFieldsFragment, 'market' | 'asset'> & {
|
||||||
market?: Market | null;
|
market?: Market | null;
|
||||||
|
Loading…
Reference in New Issue
Block a user