Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit f965f52

Browse files
Hubert KosterHubert Koster
authored andcommitted
chore: fixing test
1 parent c0fff3c commit f965f52

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/features/dashboard/components/ApiTokenTable/__tests__/index.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,26 @@ describe('Api Token Table', () => {
5353
const loadingElement = await screen.findByTestId('circles-loading');
5454
expect(loadingElement).not.toBeVisible();
5555
});
56+
57+
it('Should be able to render the tokens in the table', () => {
58+
mockUseApiToken.mockImplementationOnce(() => ({
59+
tokens: [
60+
{
61+
display_name: 'testtoken1',
62+
last_used: '',
63+
scopes: ['admin', 'payments', 'read', 'trade', 'trading_information'],
64+
token: 'asddfdsa1231',
65+
valid_for_ip: '',
66+
},
67+
],
68+
isLoadingTokens: false,
69+
}));
70+
71+
render(<ApiTokenTable />);
72+
73+
const token = screen.getByText('testtoken1');
74+
expect(token).toBeVisible();
75+
});
5676
});
5777

5878
describe('DeleteTokenDialog', () => {

src/features/dashboard/components/ApiTokenTable/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const ApiTokenTable = (props: HTMLAttributes<HTMLDivElement>) => {
4646
useEffect(() => {
4747
const row_element_exists = table_row_ref !== null;
4848
if (tokens.length > 0 && row_element_exists) {
49-
const row_height = table_row_ref.current?.clientHeight;
49+
const row_height = table_row_ref.current && table_row_ref.current.clientHeight;
5050
setTableHeight(row_height * tokens.length);
5151
}
5252
}, [tokens, table_row_ref]);

0 commit comments

Comments
 (0)