* chore: upgrade react only * chore: import renderHook from testing-library/react * chore: add @babel/runtime to fix tests * fix: fix some of the tests * fix: fix some of the tests * fix: fix tests failing on not being wrapped in act * fix: fix tests in use-environment * fix: fix @types/react issue * fix: fix formatting * fix: remove unsued method * fix: callout not accepting react node and root element null check * fix: main.tsx stats null check * fix: implicit any type fixes * Update libs/environment/src/hooks/use-nodes.spec.tsx * fix: import act from testing-lib * fix: add strict mode back * fix: fix formatting issues * fix: add babel deps for storybook * Update tsconfig.json (#970) * Update tsconfig.json * feat: [console-lite] - add missing types in few places Co-authored-by: maciek <maciek@vegaprotocol.io> * chore(#952): remove any from useDataProvider hook Co-authored-by: macqbat <kubat.maciek@gmail.com> Co-authored-by: maciek <maciek@vegaprotocol.io> Co-authored-by: Bartłomiej Głownia <bglownia@gmail.com>
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
import AccountsTable from './accounts-table';
|
|
import { act, render, screen, waitFor } from '@testing-library/react';
|
|
import type { Accounts_party_accounts } from './__generated__/Accounts';
|
|
import { AccountType } from '@vegaprotocol/types';
|
|
|
|
const singleRow: Accounts_party_accounts = {
|
|
__typename: 'Account',
|
|
type: AccountType.Margin,
|
|
balance: '125600000',
|
|
market: {
|
|
__typename: 'Market',
|
|
name: 'BTCUSD Monthly (30 Jun 2022)',
|
|
id: '10cd0a793ad2887b340940337fa6d97a212e0e517fe8e9eab2b5ef3a38633f35',
|
|
},
|
|
asset: {
|
|
__typename: 'Asset',
|
|
id: '5cfa87844724df6069b94e4c8a6f03af21907d7bc251593d08e4251043ee9f7c',
|
|
symbol: 'tBTC',
|
|
decimals: 5,
|
|
},
|
|
};
|
|
const singleRowData = [singleRow];
|
|
|
|
describe('AccountsTable', () => {
|
|
it('should render successfully', async () => {
|
|
await act(async () => {
|
|
const { baseElement } = render(<AccountsTable data={[]} />);
|
|
expect(baseElement).toBeTruthy();
|
|
});
|
|
});
|
|
|
|
it('should render correct columns', async () => {
|
|
act(async () => {
|
|
render(<AccountsTable data={singleRowData} />);
|
|
await waitFor(async () => {
|
|
const headers = await screen.getAllByRole('columnheader');
|
|
expect(headers).toHaveLength(4);
|
|
expect(
|
|
headers.map((h) =>
|
|
h.querySelector('[ref="eText"]')?.textContent?.trim()
|
|
)
|
|
).toEqual(['Asset', 'Type', 'Market', 'Balance']);
|
|
});
|
|
});
|
|
});
|
|
|
|
it('should apply correct formatting', async () => {
|
|
act(async () => {
|
|
render(<AccountsTable data={singleRowData} />);
|
|
await waitFor(async () => {
|
|
const cells = await screen.getAllByRole('gridcell');
|
|
const expectedValues = [
|
|
'tBTC',
|
|
singleRow.type,
|
|
'BTCUSD Monthly (30 Jun 2022)',
|
|
'1,256.00000',
|
|
];
|
|
cells.forEach((cell, i) => {
|
|
expect(cell).toHaveTextContent(expectedValues[i]);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|