From 107171d46abf6544fe6db719e676a5e7f7ec9d73 Mon Sep 17 00:00:00 2001 From: Dexter Edwards Date: Thu, 12 May 2022 13:32:14 +0100 Subject: [PATCH] renaming test files (#351) * renaming test files * add eslint plugin jest * enable linting rule and additional rules * fix a metric ton of linting errors * fix lint errors * remove export --- .eslintrc.json | 9 +++- .../src/app/components/table/table.spec.tsx | 26 ++++----- .../app/components/truncate/truncate.spec.tsx | 4 +- .../integration/{app.spec.ts => app.test.ts} | 0 .../integration/{app.spec.ts => app.test.ts} | 0 .../{proposal.test.tsx => proposal.spec.tsx} | 0 ...est.tsx => proposal-change-table.spec.tsx} | 0 ...-label.test.tsx => tranche-label.spex.tsx} | 0 .../vega-wallet-connect-button.spec.tsx | 4 +- .../web3-container/web3-container.spec.tsx | 20 ++++--- apps/trading/specs/index.spec.tsx | 1 + libs/accounts/src/lib/accounts-table.spec.tsx | 6 +-- libs/deal-ticket/src/deal-ticket.spec.tsx | 6 +-- .../deal-ticket/src/use-order-submit.spec.tsx | 10 ++-- libs/deposits/src/lib/deposit-form.spec.tsx | 28 ++++++---- .../src/lib/order-list-manager.spec.tsx | 6 +-- libs/order-list/src/lib/order-list.spec.tsx | 10 ++-- .../src/lib/positions-table.spec.tsx | 6 +-- .../hooks/use-apply-grid-transaction.spec.ts | 8 +-- ...mine-ids.test.ts => determine-ids.spec.ts} | 2 +- ...lash-cell.test.tsx => flash-cell.spec.tsx} | 0 ...rice-cell.test.tsx => price-cell.spec.tsx} | 0 ...ell.test.tsx => price-flash-cell.spec.tsx} | 0 .../{remove-0x.test.ts => remove-0x.spec.ts} | 0 libs/trades/src/lib/trades-table.spec.tsx | 6 +-- .../{callout.test.tsx => callout.spec.tsx} | 8 +-- .../copy-with-tooltip.spec.tsx | 2 +- ...-link.test.tsx => etherscan-link.spec.tsx} | 10 ++-- ...able.test.tsx => key-value-table.spec.tsx} | 0 .../components/sparkline/sparkline.spec.tsx | 2 - .../src/components/tooltip/tooltip.spec.tsx | 4 +- libs/ui-toolkit/src/utils/class-names.spec.ts | 4 +- ...ialog.test.tsx => connect-dialog.spec.tsx} | 6 +-- libs/wallet/src/manage-dialog.spec.tsx | 3 +- .../{provider.test.tsx => provider.spec.tsx} | 2 +- libs/wallet/src/use-vega-transaction.spec.tsx | 10 ++-- .../transaction-dialog.spec.tsx | 8 +-- ....tsx => use-ethereum-transaction.spec.tsx} | 6 +-- .../web3/src/lib/web3-connect-dialog.spec.tsx | 4 +- libs/web3/src/lib/web3-provider.spec.tsx | 2 +- .../src/lib/use-complete-withdraw.spec.tsx | 6 +-- libs/withdraws/src/lib/use-withdraw.spec.tsx | 6 +-- .../src/lib/use-withdrawals.spec.tsx | 8 +-- .../src/lib/withdraw-dialog.spec.tsx | 2 +- libs/withdraws/src/lib/withdraw-form.spec.tsx | 6 +-- .../src/lib/withdraw-manager.spec.tsx | 10 ++-- .../src/lib/withdrawals-table.spec.tsx | 18 +++---- package.json | 1 + yarn.lock | 53 +++++++++++++++++++ 49 files changed, 204 insertions(+), 129 deletions(-) rename apps/stats-e2e/src/integration/{app.spec.ts => app.test.ts} (100%) rename apps/token-e2e/src/integration/{app.spec.ts => app.test.ts} (100%) rename apps/token/src/lib/type-policies/{proposal.test.tsx => proposal.spec.tsx} (100%) rename apps/token/src/routes/governance/components/proposal-change-table/{proposal-change-table.test.tsx => proposal-change-table.spec.tsx} (100%) rename apps/token/src/routes/tranches/{tranche-label.test.tsx => tranche-label.spex.tsx} (100%) rename libs/react-helpers/src/lib/{determine-ids.test.ts => determine-ids.spec.ts} (85%) rename libs/react-helpers/src/lib/grid/{flash-cell.test.tsx => flash-cell.spec.tsx} (100%) rename libs/react-helpers/src/lib/grid/{price-cell.test.tsx => price-cell.spec.tsx} (100%) rename libs/react-helpers/src/lib/grid/{price-flash-cell.test.tsx => price-flash-cell.spec.tsx} (100%) rename libs/react-helpers/src/lib/{remove-0x.test.ts => remove-0x.spec.ts} (100%) rename libs/ui-toolkit/src/components/callout/{callout.test.tsx => callout.spec.tsx} (81%) rename libs/ui-toolkit/src/components/etherscan-link/{etherscan-link.test.tsx => etherscan-link.spec.tsx} (73%) rename libs/ui-toolkit/src/components/key-value-table/{key-value-table.test.tsx => key-value-table.spec.tsx} (100%) rename libs/wallet/src/{connect-dialog.test.tsx => connect-dialog.spec.tsx} (96%) rename libs/wallet/src/{provider.test.tsx => provider.spec.tsx} (97%) rename libs/web3/src/lib/{use-ethereum-transaction.test.tsx => use-ethereum-transaction.spec.tsx} (96%) diff --git a/.eslintrc.json b/.eslintrc.json index 5f9a4d8d2..20df314eb 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,7 @@ { "root": true, "ignorePatterns": ["**/*"], - "plugins": ["@nrwl/nx", "eslint-plugin-unicorn", "jsx-a11y"], + "plugins": ["@nrwl/nx", "eslint-plugin-unicorn", "jsx-a11y", "jest"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], @@ -66,6 +66,13 @@ ] } }, + { + "files": ["*.spec.ts", "*.spec.tsx"], + "extends": ["plugin:@nrwl/nx/typescript", "plugin:jest/recommended"], + "rules": { + "jest/consistent-test-it": ["error", { "fn": "it" }] + } + }, { "files": ["*.js", "*.jsx"], "extends": ["plugin:@nrwl/nx/javascript"], diff --git a/apps/explorer/src/app/components/table/table.spec.tsx b/apps/explorer/src/app/components/table/table.spec.tsx index 6937d3c58..d5873a008 100644 --- a/apps/explorer/src/app/components/table/table.spec.tsx +++ b/apps/explorer/src/app/components/table/table.spec.tsx @@ -3,19 +3,21 @@ import { render, screen } from '@testing-library/react'; import { TableWithTbody, TableRow, TableHeader, TableCell } from './index'; describe('Renders all table components', () => { - render( - - - Title - Content - - - ); + it('Renders table components', () => { + render( + + + Title + Content + + + ); - expect(screen.getByTestId('test-table')).toBeInTheDocument(); - expect(screen.getByTestId('test-tr')).toBeInTheDocument(); - expect(screen.getByTestId('test-th')).toHaveTextContent('Title'); - expect(screen.getByTestId('test-td')).toHaveTextContent('Content'); + expect(screen.getByTestId('test-table')).toBeInTheDocument(); + expect(screen.getByTestId('test-tr')).toBeInTheDocument(); + expect(screen.getByTestId('test-th')).toHaveTextContent('Title'); + expect(screen.getByTestId('test-td')).toHaveTextContent('Content'); + }); }); describe('Table row', () => { diff --git a/apps/explorer/src/app/components/truncate/truncate.spec.tsx b/apps/explorer/src/app/components/truncate/truncate.spec.tsx index 85677d8be..1828f8305 100644 --- a/apps/explorer/src/app/components/truncate/truncate.spec.tsx +++ b/apps/explorer/src/app/components/truncate/truncate.spec.tsx @@ -10,7 +10,7 @@ describe('Truncate', () => { expect(screen.getByTestId('truncate-test')).toBeInTheDocument(); }); - it('it truncates as expected', () => { + it('truncates as expected', () => { const test = 'randomstringblahblah'; const startChars = 3; const endChars = 3; @@ -25,7 +25,7 @@ describe('Truncate', () => { expect(screen.getByText(expectedString)).toBeInTheDocument(); }); - it("it doesn't truncate if the string is too short", () => { + it("doesn't truncate if the string is too short", () => { const test = 'randomstringblahblah'; const startChars = test.length; const endChars = test.length; diff --git a/apps/stats-e2e/src/integration/app.spec.ts b/apps/stats-e2e/src/integration/app.test.ts similarity index 100% rename from apps/stats-e2e/src/integration/app.spec.ts rename to apps/stats-e2e/src/integration/app.test.ts diff --git a/apps/token-e2e/src/integration/app.spec.ts b/apps/token-e2e/src/integration/app.test.ts similarity index 100% rename from apps/token-e2e/src/integration/app.spec.ts rename to apps/token-e2e/src/integration/app.test.ts diff --git a/apps/token/src/lib/type-policies/proposal.test.tsx b/apps/token/src/lib/type-policies/proposal.spec.tsx similarity index 100% rename from apps/token/src/lib/type-policies/proposal.test.tsx rename to apps/token/src/lib/type-policies/proposal.spec.tsx diff --git a/apps/token/src/routes/governance/components/proposal-change-table/proposal-change-table.test.tsx b/apps/token/src/routes/governance/components/proposal-change-table/proposal-change-table.spec.tsx similarity index 100% rename from apps/token/src/routes/governance/components/proposal-change-table/proposal-change-table.test.tsx rename to apps/token/src/routes/governance/components/proposal-change-table/proposal-change-table.spec.tsx diff --git a/apps/token/src/routes/tranches/tranche-label.test.tsx b/apps/token/src/routes/tranches/tranche-label.spex.tsx similarity index 100% rename from apps/token/src/routes/tranches/tranche-label.test.tsx rename to apps/token/src/routes/tranches/tranche-label.spex.tsx diff --git a/apps/trading/components/vega-wallet-connect-button/vega-wallet-connect-button.spec.tsx b/apps/trading/components/vega-wallet-connect-button/vega-wallet-connect-button.spec.tsx index c9e4150bd..5ca631d6b 100644 --- a/apps/trading/components/vega-wallet-connect-button/vega-wallet-connect-button.spec.tsx +++ b/apps/trading/components/vega-wallet-connect-button/vega-wallet-connect-button.spec.tsx @@ -24,7 +24,7 @@ const generateJsx = ( ); }; -test('Not connected', () => { +it('Not connected', () => { render(generateJsx({ keypair: null } as VegaWalletContextShape, props)); const button = screen.getByRole('button'); @@ -34,7 +34,7 @@ test('Not connected', () => { expect(props.setManageDialog).not.toHaveBeenCalled(); }); -test('Connected', () => { +it('Connected', () => { render( generateJsx( { keypair: { pub: '123456__123456' } } as VegaWalletContextShape, diff --git a/apps/trading/components/web3-container/web3-container.spec.tsx b/apps/trading/components/web3-container/web3-container.spec.tsx index 5860c33b3..04028f99e 100644 --- a/apps/trading/components/web3-container/web3-container.spec.tsx +++ b/apps/trading/components/web3-container/web3-container.spec.tsx @@ -62,7 +62,7 @@ function setup(mock = networkParamsQueryMock) { ); } -test('Prompt to connect opens dialog', async () => { +it('Prompt to connect opens dialog', async () => { mockHookValue = defaultHookValue; setup(); @@ -78,17 +78,19 @@ test('Prompt to connect opens dialog', async () => { expect(screen.getByTestId('web3-connector-list')).toBeInTheDocument(); }); -test('Error message is shown', async () => { +it('Error message is shown', async () => { const message = 'Opps! An error'; mockHookValue = { ...defaultHookValue, error: new Error(message) }; setup(); expect(screen.getByText('Loading...')).toBeInTheDocument(); - expect(await screen.findByText(`Something went wrong: ${message}`)); + expect( + await screen.findByText(`Something went wrong: ${message}`) + ).toBeInTheDocument(); expect(screen.queryByText('Child')).not.toBeInTheDocument(); }); -test('Checks that chain ID matches app ID', async () => { +it('Checks that chain ID matches app ID', async () => { const expectedChainId = 4; mockHookValue = { ...defaultHookValue, @@ -98,11 +100,13 @@ test('Checks that chain ID matches app ID', async () => { setup(); expect(screen.getByText('Loading...')).toBeInTheDocument(); - expect(await screen.findByText(`This app only works on chain ID: 3`)); + expect( + await screen.findByText(`This app only works on chain ID: 3`) + ).toBeInTheDocument(); expect(screen.queryByText('Child')).not.toBeInTheDocument(); }); -test('Passes ethereum config to children', async () => { +it('Passes ethereum config to children', async () => { mockHookValue = { ...defaultHookValue, isActive: true, @@ -117,7 +121,7 @@ test('Passes ethereum config to children', async () => { ).toBeInTheDocument(); }); -test('Shows no config found message if the network parameter doesnt exist', async () => { +it('Shows no config found message if the network parameter doesnt exist', async () => { const mock: MockedResponse = { request: { query: NETWORK_PARAMS_QUERY, @@ -141,7 +145,7 @@ test('Shows no config found message if the network parameter doesnt exist', asyn ).toBeInTheDocument(); }); -test('Shows message if ethereum config could not be parsed', async () => { +it('Shows message if ethereum config could not be parsed', async () => { const mock: MockedResponse = { request: { query: NETWORK_PARAMS_QUERY, diff --git a/apps/trading/specs/index.spec.tsx b/apps/trading/specs/index.spec.tsx index 1f61cff81..c287a13df 100644 --- a/apps/trading/specs/index.spec.tsx +++ b/apps/trading/specs/index.spec.tsx @@ -13,5 +13,6 @@ jest.mock('@vegaprotocol/ui-toolkit', () => { describe('Index', () => { it('should render successfully', () => { render(); + expect(true).toBeTruthy(); }); }); diff --git a/libs/accounts/src/lib/accounts-table.spec.tsx b/libs/accounts/src/lib/accounts-table.spec.tsx index 2304a5e2f..14aeea304 100644 --- a/libs/accounts/src/lib/accounts-table.spec.tsx +++ b/libs/accounts/src/lib/accounts-table.spec.tsx @@ -21,14 +21,14 @@ const singleRow: Accounts_party_accounts = { }; const singleRowData = [singleRow]; -test('should render successfully', async () => { +it('should render successfully', async () => { await act(async () => { const { baseElement } = render(); expect(baseElement).toBeTruthy(); }); }); -test('Render correct columns', async () => { +it('Render correct columns', async () => { await act(async () => { render(); await waitFor(async () => { @@ -43,7 +43,7 @@ test('Render correct columns', async () => { }); }); -test('Correct formatting applied', async () => { +it('Correct formatting applied', async () => { await act(async () => { render(); await waitFor(async () => { diff --git a/libs/deal-ticket/src/deal-ticket.spec.tsx b/libs/deal-ticket/src/deal-ticket.spec.tsx index ea933438a..e49a50383 100644 --- a/libs/deal-ticket/src/deal-ticket.spec.tsx +++ b/libs/deal-ticket/src/deal-ticket.spec.tsx @@ -57,7 +57,7 @@ function generateJsx() { ); } -test('Deal ticket defaults', () => { +it('Deal ticket defaults', () => { render(generateJsx()); // Assert defaults are used @@ -82,7 +82,7 @@ test('Deal ticket defaults', () => { ); }); -test('Can edit deal ticket', () => { +it('Can edit deal ticket', () => { render(generateJsx()); // Asssert changing values @@ -113,7 +113,7 @@ test('Can edit deal ticket', () => { ); }); -test('Handles TIF select box dependent on order type', () => { +it('Handles TIF select box dependent on order type', () => { render(generateJsx()); // Check only IOC and diff --git a/libs/deal-ticket/src/use-order-submit.spec.tsx b/libs/deal-ticket/src/use-order-submit.spec.tsx index 7b8529bd2..b6ed20374 100644 --- a/libs/deal-ticket/src/use-order-submit.spec.tsx +++ b/libs/deal-ticket/src/use-order-submit.spec.tsx @@ -36,7 +36,7 @@ function setup( return renderHook(() => useOrderSubmit(market), { wrapper }); } -test('Has the correct default state', () => { +it('Has the correct default state', () => { const { result } = setup(); expect(typeof result.current.submit).toEqual('function'); expect(typeof result.current.reset).toEqual('function'); @@ -45,7 +45,7 @@ test('Has the correct default state', () => { expect(result.current.transaction.error).toEqual(null); }); -test('Should not sendTx if no keypair', async () => { +it('Should not sendTx if no keypair', async () => { const mockSendTx = jest.fn(); const { result } = setup({ sendTx: mockSendTx, keypairs: [], keypair: null }); await act(async () => { @@ -54,7 +54,7 @@ test('Should not sendTx if no keypair', async () => { expect(mockSendTx).not.toHaveBeenCalled(); }); -test('Should not sendTx side is not specified', async () => { +it('Should not sendTx side is not specified', async () => { const mockSendTx = jest.fn(); const keypair = { pub: '0x123', @@ -70,7 +70,7 @@ test('Should not sendTx side is not specified', async () => { expect(mockSendTx).not.toHaveBeenCalled(); }); -test('Create an Id if a signature is returned', async () => { +it('Create an Id if a signature is returned', async () => { const signature = '597a7706491e6523c091bab1e4d655b62c45a224e80f6cd92ac366aa5dd9a070cc7dd3c6919cb07b81334b876c662dd43bdbe5e827c8baa17a089feb654fab0b'; const expectedId = @@ -106,7 +106,7 @@ test('Create an Id if a signature is returned', async () => { expect(result.current.id).toEqual(expectedId); }); -test('Should submit a correctly formatted order', async () => { +it('Should submit a correctly formatted order', async () => { const mockSendTx = jest.fn().mockReturnValue(Promise.resolve({})); const keypair = { pub: '0x123', diff --git a/libs/deposits/src/lib/deposit-form.spec.tsx b/libs/deposits/src/lib/deposit-form.spec.tsx index 0554f56e8..337285437 100644 --- a/libs/deposits/src/lib/deposit-form.spec.tsx +++ b/libs/deposits/src/lib/deposit-form.spec.tsx @@ -44,7 +44,7 @@ beforeEach(() => { }; }); -test('Form validation', async () => { +it('Form validation', async () => { const mockUseVegaWallet = useVegaWallet as jest.Mock; mockUseVegaWallet.mockReturnValue({ keypair: null }); @@ -77,26 +77,32 @@ test('Form validation', async () => { fireEvent.change(screen.getByLabelText('From (Ethereum address)'), { target: { value: invalidEthereumAddress }, }); - expect(await screen.findByText('Invalid Ethereum address')); + expect( + await screen.findByText('Invalid Ethereum address') + ).toBeInTheDocument(); const invalidVegaKey = 'abc'; fireEvent.change(screen.getByLabelText('To (Vega key)'), { target: { value: invalidVegaKey }, }); - expect(await screen.findByText('Invalid Vega key')); + expect(await screen.findByText('Invalid Vega key')).toBeInTheDocument(); // Max amount validation const amountMoreThanAvailable = '11'; fireEvent.change(screen.getByLabelText('Amount'), { target: { value: amountMoreThanAvailable }, }); - expect(await screen.findByText('Insufficient amount in Ethereum wallet')); + expect( + await screen.findByText('Insufficient amount in Ethereum wallet') + ).toBeInTheDocument(); const amountMoreThanLimit = '21'; fireEvent.change(screen.getByLabelText('Amount'), { target: { value: amountMoreThanLimit }, }); - expect(await screen.findByText('Amount is above permitted maximum')); + expect( + await screen.findByText('Amount is above permitted maximum') + ).toBeInTheDocument(); rerender( { fireEvent.change(screen.getByLabelText('Amount'), { target: { value: amountMoreThanAllowance }, }); - expect(await screen.findByText('Amount is above approved amount')); + expect( + await screen.findByText('Amount is above approved amount') + ).toBeInTheDocument(); // Min amount validation rerender(); // Rerender with selected asset so we have asset.decimals @@ -119,7 +127,7 @@ test('Form validation', async () => { target: { value: amountLessThanMinViable }, }); - expect(await screen.findByText('Value is below minimum')); + expect(await screen.findByText('Value is below minimum')).toBeInTheDocument(); rerender( { fireEvent.change(screen.getByLabelText('Amount'), { target: { value: amountLessThanLimit }, }); - expect(await screen.findByText('Value is below minimum')); + expect(await screen.findByText('Value is below minimum')).toBeInTheDocument(); }); -test('Approval', () => { +it('Approval', () => { const mockUseVegaWallet = useVegaWallet as jest.Mock; mockUseVegaWallet.mockReturnValue({ keypair: null }); @@ -156,7 +164,7 @@ test('Approval', () => { expect(props.submitApprove).toHaveBeenCalled(); }); -test('Deposit', async () => { +it('Deposit', async () => { const vegaKey = 'f8885edfa7ffdb6ed996ca912e9258998e47bf3515c885cf3c63fb56b15de36f'; const mockUseVegaWallet = useVegaWallet as jest.Mock; diff --git a/libs/order-list/src/lib/order-list-manager.spec.tsx b/libs/order-list/src/lib/order-list-manager.spec.tsx index a49c1dd02..98c0edc88 100644 --- a/libs/order-list/src/lib/order-list-manager.spec.tsx +++ b/libs/order-list/src/lib/order-list-manager.spec.tsx @@ -7,7 +7,7 @@ import { forwardRef } from 'react'; jest.mock('./order-list'); -test('Renders a loading state while awaiting orders', () => { +it('Renders a loading state while awaiting orders', () => { jest.spyOn(useDataProviderHook, 'useDataProvider').mockReturnValue({ data: [], loading: true, @@ -17,7 +17,7 @@ test('Renders a loading state while awaiting orders', () => { expect(screen.getByText('Loading...')).toBeInTheDocument(); }); -test('Renders an error state', () => { +it('Renders an error state', () => { const errorMsg = 'Oops! An Error'; jest.spyOn(useDataProviderHook, 'useDataProvider').mockReturnValue({ data: [], @@ -30,7 +30,7 @@ test('Renders an error state', () => { ).toBeInTheDocument(); }); -test('Renders the order list if orders provided', async () => { +it('Renders the order list if orders provided', async () => { // @ts-ignore Orderlist is read only but we need to override with the forwardref to // avoid warnings about padding refs orderListMock.OrderList = forwardRef(() =>
OrderList
); diff --git a/libs/order-list/src/lib/order-list.spec.tsx b/libs/order-list/src/lib/order-list.spec.tsx index 2cbc332ce..bc383e180 100644 --- a/libs/order-list/src/lib/order-list.spec.tsx +++ b/libs/order-list/src/lib/order-list.spec.tsx @@ -10,7 +10,7 @@ import { } from '@vegaprotocol/types'; import { OrderList } from './order-list'; -test('No orders message shown', async () => { +it('No orders message shown', async () => { await act(async () => { render(); }); @@ -75,7 +75,7 @@ const limitOrder: Orders_party_orders = { rejectionReason: null, }; -test('Correct columns are rendered', async () => { +it('Correct columns are rendered', async () => { await act(async () => { render(); }); @@ -94,7 +94,7 @@ test('Correct columns are rendered', async () => { ]); }); -test('Correct formatting applied for market order', async () => { +it('Correct formatting applied for market order', async () => { await act(async () => { render(); }); @@ -115,7 +115,7 @@ test('Correct formatting applied for market order', async () => { }); }); -test('Correct formatting applied for GTT limit order', async () => { +it('Correct formatting applied for GTT limit order', async () => { await act(async () => { render(); }); @@ -137,7 +137,7 @@ test('Correct formatting applied for GTT limit order', async () => { }); }); -test('Correct formatting applied for a rejected order', async () => { +it('Correct formatting applied for a rejected order', async () => { const rejectedOrder = { ...marketOrder, status: OrderStatus.Rejected, diff --git a/libs/positions/src/lib/positions-table.spec.tsx b/libs/positions/src/lib/positions-table.spec.tsx index caac796b2..70b84e231 100644 --- a/libs/positions/src/lib/positions-table.spec.tsx +++ b/libs/positions/src/lib/positions-table.spec.tsx @@ -55,14 +55,14 @@ const singleRow: Positions_party_positions = { }; const singleRowData = [singleRow]; -test('should render successfully', async () => { +it('should render successfully', async () => { await act(async () => { const { baseElement } = render(); expect(baseElement).toBeTruthy(); }); }); -test('Render correct columns', async () => { +it('Render correct columns', async () => { await act(async () => { render(); await waitFor(async () => { @@ -83,7 +83,7 @@ test('Render correct columns', async () => { }); }); -test('Correct formatting applied', async () => { +it('Correct formatting applied', async () => { await act(async () => { render(); await waitFor(async () => { diff --git a/libs/react-helpers/src/hooks/use-apply-grid-transaction.spec.ts b/libs/react-helpers/src/hooks/use-apply-grid-transaction.spec.ts index e7c9249a9..88d1cfe69 100644 --- a/libs/react-helpers/src/hooks/use-apply-grid-transaction.spec.ts +++ b/libs/react-helpers/src/hooks/use-apply-grid-transaction.spec.ts @@ -29,7 +29,7 @@ function setup(items: Items, rowNodes: Items) { return gridApiMock; } -test('Adds items', () => { +it('Adds items', () => { const gridApiMock = setup(items, []); expect(gridApiMock.applyTransaction).toHaveBeenCalledWith({ update: [], @@ -38,7 +38,7 @@ test('Adds items', () => { }); }); -test('Doesnt update rows without changes', () => { +it('Doesnt update rows without changes', () => { const rowNodes: Array<{ id: string; value: number }> = [...items]; const gridApiMock = setup(items, rowNodes); expect(gridApiMock.applyTransaction).toHaveBeenCalledWith({ @@ -48,7 +48,7 @@ test('Doesnt update rows without changes', () => { }); }); -test('Update rows with changes', () => { +it('Update rows with changes', () => { const rowNodes = [...items]; const updatedItems = [ { id: '1', value: 10 }, @@ -62,7 +62,7 @@ test('Update rows with changes', () => { }); }); -test('Updates and adds at the same time', () => { +it('Updates and adds at the same time', () => { const newItem = { id: '3', value: 3 }; const updatedItem = { id: '2', value: 20 }; const gridApiMock = setup([newItem, updatedItem], [...items]); diff --git a/libs/react-helpers/src/lib/determine-ids.test.ts b/libs/react-helpers/src/lib/determine-ids.spec.ts similarity index 85% rename from libs/react-helpers/src/lib/determine-ids.test.ts rename to libs/react-helpers/src/lib/determine-ids.spec.ts index 3d5dfcfd4..06b4df8a0 100644 --- a/libs/react-helpers/src/lib/determine-ids.test.ts +++ b/libs/react-helpers/src/lib/determine-ids.spec.ts @@ -1,6 +1,6 @@ import { determineId } from './determine-id'; -test('It produces a known result for an ID', () => { +it('produces a known result for an ID', () => { const res = determineId( 'cfe592d169f87d0671dd447751036d0dddc165b9c4b65e5a5060e2bbadd1aa726d4cbe9d3c3b327bcb0bff4f83999592619a2493f9bbd251fae99ce7ce766909' ); diff --git a/libs/react-helpers/src/lib/grid/flash-cell.test.tsx b/libs/react-helpers/src/lib/grid/flash-cell.spec.tsx similarity index 100% rename from libs/react-helpers/src/lib/grid/flash-cell.test.tsx rename to libs/react-helpers/src/lib/grid/flash-cell.spec.tsx diff --git a/libs/react-helpers/src/lib/grid/price-cell.test.tsx b/libs/react-helpers/src/lib/grid/price-cell.spec.tsx similarity index 100% rename from libs/react-helpers/src/lib/grid/price-cell.test.tsx rename to libs/react-helpers/src/lib/grid/price-cell.spec.tsx diff --git a/libs/react-helpers/src/lib/grid/price-flash-cell.test.tsx b/libs/react-helpers/src/lib/grid/price-flash-cell.spec.tsx similarity index 100% rename from libs/react-helpers/src/lib/grid/price-flash-cell.test.tsx rename to libs/react-helpers/src/lib/grid/price-flash-cell.spec.tsx diff --git a/libs/react-helpers/src/lib/remove-0x.test.ts b/libs/react-helpers/src/lib/remove-0x.spec.ts similarity index 100% rename from libs/react-helpers/src/lib/remove-0x.test.ts rename to libs/react-helpers/src/lib/remove-0x.spec.ts diff --git a/libs/trades/src/lib/trades-table.spec.tsx b/libs/trades/src/lib/trades-table.spec.tsx index ddd452849..abebb4dd3 100644 --- a/libs/trades/src/lib/trades-table.spec.tsx +++ b/libs/trades/src/lib/trades-table.spec.tsx @@ -16,7 +16,7 @@ const trade: TradeFields = { }, }; -test('Correct columns are rendered', async () => { +it('Correct columns are rendered', async () => { await act(async () => { render(); }); @@ -26,7 +26,7 @@ test('Correct columns are rendered', async () => { expect(headers.map((h) => h.textContent?.trim())).toEqual(expectedHeaders); }); -test('Columns are formatted', async () => { +it('Number and data columns are formatted', async () => { await act(async () => { render(); }); @@ -42,7 +42,7 @@ test('Columns are formatted', async () => { }); }); -test('Columns are formatted', async () => { +it('Price and size columns are formatted', async () => { const trade2 = { ...trade, id: 'trade-id-2', diff --git a/libs/ui-toolkit/src/components/callout/callout.test.tsx b/libs/ui-toolkit/src/components/callout/callout.spec.tsx similarity index 81% rename from libs/ui-toolkit/src/components/callout/callout.test.tsx rename to libs/ui-toolkit/src/components/callout/callout.spec.tsx index 8ef09887d..39e5594d5 100644 --- a/libs/ui-toolkit/src/components/callout/callout.test.tsx +++ b/libs/ui-toolkit/src/components/callout/callout.spec.tsx @@ -2,12 +2,12 @@ import { render, screen } from '@testing-library/react'; import { Callout } from '.'; import { Intent } from '../../utils/intent'; -test('It renders content within callout', () => { +it('renders content within callout', () => { render(Content); expect(screen.getByTestId('callout')).toHaveTextContent('Content'); }); -test('It renders title and icon', () => { +it('renders title and icon', () => { render(); expect( screen.getByTestId('callout').querySelector('svg') @@ -17,14 +17,14 @@ test('It renders title and icon', () => { const intents = Object.values(Intent).filter((i) => i !== Intent.Progress); -test.each(intents)('Applies class for %s', (intent) => { +it.each(intents)('Applies class for %s', (intent) => { render(); expect(screen.getByTestId('callout')).toHaveClass( `shadow-intent-${intent.toLowerCase()}` ); }); -test(`Applies class for progress`, () => { +it(`Applies class for progress`, () => { render(); expect(screen.getByTestId('callout')).toHaveClass( 'shadow-black', diff --git a/libs/ui-toolkit/src/components/copy-with-tooltip/copy-with-tooltip.spec.tsx b/libs/ui-toolkit/src/components/copy-with-tooltip/copy-with-tooltip.spec.tsx index eea40667b..26254a9c5 100644 --- a/libs/ui-toolkit/src/components/copy-with-tooltip/copy-with-tooltip.spec.tsx +++ b/libs/ui-toolkit/src/components/copy-with-tooltip/copy-with-tooltip.spec.tsx @@ -14,7 +14,7 @@ afterAll(() => { jest.useRealTimers(); }); -test('CopyWithTooltip', async () => { +it('CopyWithTooltip', async () => { const copyText = 'Text to be copied'; render( diff --git a/libs/ui-toolkit/src/components/etherscan-link/etherscan-link.test.tsx b/libs/ui-toolkit/src/components/etherscan-link/etherscan-link.spec.tsx similarity index 73% rename from libs/ui-toolkit/src/components/etherscan-link/etherscan-link.test.tsx rename to libs/ui-toolkit/src/components/etherscan-link/etherscan-link.spec.tsx index feb050d71..1f3ac4831 100644 --- a/libs/ui-toolkit/src/components/etherscan-link/etherscan-link.test.tsx +++ b/libs/ui-toolkit/src/components/etherscan-link/etherscan-link.spec.tsx @@ -1,22 +1,22 @@ import { render, screen } from '@testing-library/react'; import { EtherscanLink } from '.'; -test('It renders a link with the text', () => { +it('renders a link with the text', () => { render(); expect(screen.getByText('foo')).toBeInTheDocument(); }); -test('It renders a link with the tx hash if no text is provided', () => { +it('renders a link with the tx hash if no text is provided', () => { render(); expect(screen.getByText('tx')).toBeInTheDocument(); }); -test('It renders a link with the address if no text is provided', () => { +it('renders a link with the address if no text is provided', () => { render(); expect(screen.getByText('address')).toBeInTheDocument(); }); -test('It links to etherscan address', () => { +it('links to etherscan address', () => { const hash = 'hash'; render(); expect(screen.getByTestId('etherscan-link')).toHaveAttribute( @@ -25,7 +25,7 @@ test('It links to etherscan address', () => { ); }); -test('It links to etherscan transaction', () => { +it('links to etherscan transaction', () => { const hash = 'hash'; render(); expect(screen.getByTestId('etherscan-link')).toHaveAttribute( diff --git a/libs/ui-toolkit/src/components/key-value-table/key-value-table.test.tsx b/libs/ui-toolkit/src/components/key-value-table/key-value-table.spec.tsx similarity index 100% rename from libs/ui-toolkit/src/components/key-value-table/key-value-table.test.tsx rename to libs/ui-toolkit/src/components/key-value-table/key-value-table.spec.tsx diff --git a/libs/ui-toolkit/src/components/sparkline/sparkline.spec.tsx b/libs/ui-toolkit/src/components/sparkline/sparkline.spec.tsx index cea989390..a3ca2b004 100644 --- a/libs/ui-toolkit/src/components/sparkline/sparkline.spec.tsx +++ b/libs/ui-toolkit/src/components/sparkline/sparkline.spec.tsx @@ -1,8 +1,6 @@ import { render, screen } from '@testing-library/react'; -import { theme } from '@vegaprotocol/tailwindcss-config'; import { Sparkline } from './sparkline'; -export const Colors = theme.colors; const props = { data: [ diff --git a/libs/ui-toolkit/src/components/tooltip/tooltip.spec.tsx b/libs/ui-toolkit/src/components/tooltip/tooltip.spec.tsx index 8a75edd3a..62144d406 100644 --- a/libs/ui-toolkit/src/components/tooltip/tooltip.spec.tsx +++ b/libs/ui-toolkit/src/components/tooltip/tooltip.spec.tsx @@ -1,7 +1,7 @@ import { fireEvent, render, screen } from '@testing-library/react'; import { Tooltip } from './tooltip'; -test('Renders a tooltip', async () => { +it('Renders a tooltip', async () => { const props = { description: 'description', children: , @@ -13,7 +13,7 @@ test('Renders a tooltip', async () => { expect(await screen.findByRole('tooltip')).toBeInTheDocument(); }); -test('Doesnt render a tooltip if no description provided', () => { +it('Doesnt render a tooltip if no description provided', () => { const props = { description: undefined, children: , diff --git a/libs/ui-toolkit/src/utils/class-names.spec.ts b/libs/ui-toolkit/src/utils/class-names.spec.ts index 6c6bc7e72..76b42f9e0 100644 --- a/libs/ui-toolkit/src/utils/class-names.spec.ts +++ b/libs/ui-toolkit/src/utils/class-names.spec.ts @@ -1,6 +1,6 @@ import { includesLeftPadding, includesRightPadding } from './class-names'; -test('includesLeftPadding detects class name which affects left padding', () => { +it('includesLeftPadding detects class name which affects left padding', () => { expect(includesLeftPadding()).toEqual(false); expect(includesLeftPadding('')).toEqual(false); expect(includesLeftPadding('pl-8')).toEqual(true); @@ -19,7 +19,7 @@ test('includesLeftPadding detects class name which affects left padding', () => expect(includesLeftPadding('apx-16')).toEqual(false); }); -test('includesRightPadding detects class name which affects right padding', () => { +it('includesRightPadding detects class name which affects right padding', () => { expect(includesRightPadding()).toEqual(false); expect(includesRightPadding('')).toEqual(false); expect(includesRightPadding('pr-8')).toEqual(true); diff --git a/libs/wallet/src/connect-dialog.test.tsx b/libs/wallet/src/connect-dialog.spec.tsx similarity index 96% rename from libs/wallet/src/connect-dialog.test.tsx rename to libs/wallet/src/connect-dialog.spec.tsx index 38c8a2f90..ae203cf07 100644 --- a/libs/wallet/src/connect-dialog.test.tsx +++ b/libs/wallet/src/connect-dialog.spec.tsx @@ -46,7 +46,7 @@ function generateJSX( ); } -test('Renders list of connectors', () => { +it('Renders list of connectors', () => { const { container, rerender } = render(generateJSX()); expect(container).toBeEmptyDOMElement(); rerender(generateJSX({ dialogOpen: true })); @@ -69,7 +69,7 @@ const fillInForm = () => { return { wallet: walletValue, passphrase: passphraseValue }; }; -test('Successful connection using rest auth form', async () => { +it('Successful connection using rest auth form', async () => { const spy = jest .spyOn(defaultProps.connectors['rest'] as RestConnector, 'authenticate') .mockImplementation(() => Promise.resolve({ success: true, error: null })); @@ -97,7 +97,7 @@ test('Successful connection using rest auth form', async () => { expect(defaultProps.setDialogOpen).toHaveBeenCalledWith(false); }); -test('Unsuccessful connection using rest auth form', async () => { +it('Unsuccessful connection using rest auth form', async () => { // Error from service let spy = jest .spyOn(defaultProps.connectors['rest'] as RestConnector, 'authenticate') diff --git a/libs/wallet/src/manage-dialog.spec.tsx b/libs/wallet/src/manage-dialog.spec.tsx index feac2df7a..5697cb94e 100644 --- a/libs/wallet/src/manage-dialog.spec.tsx +++ b/libs/wallet/src/manage-dialog.spec.tsx @@ -1,3 +1,4 @@ +/* eslint-disable jest/no-conditional-expect */ import { fireEvent, render, screen, within } from '@testing-library/react'; import { VegaWalletContext } from './context'; import type { VegaWalletContextShape, VegaKeyExtended } from './context'; @@ -41,7 +42,7 @@ const generateJsx = ( ); }; -test('Shows list of available keys and can disconnect', () => { +it('Shows list of available keys and can disconnect', () => { render(generateJsx(context as VegaWalletContextShape, props)); const list = screen.getByTestId('keypair-list'); diff --git a/libs/wallet/src/provider.test.tsx b/libs/wallet/src/provider.spec.tsx similarity index 97% rename from libs/wallet/src/provider.test.tsx rename to libs/wallet/src/provider.spec.tsx index 6843b7bb7..43559fbe0 100644 --- a/libs/wallet/src/provider.test.tsx +++ b/libs/wallet/src/provider.spec.tsx @@ -50,7 +50,7 @@ const generateJSX = () => ( ); -test('Can connect, disconnect and retrieve keypairs', async () => { +it('Can connect, disconnect and retrieve keypairs', async () => { const mockKeypairs = [{ pub: 'public key 1' }, { pub: 'public key 2' }]; jest .spyOn(restConnector, 'connect') diff --git a/libs/wallet/src/use-vega-transaction.spec.tsx b/libs/wallet/src/use-vega-transaction.spec.tsx index 4ee7e302f..6388745f2 100644 --- a/libs/wallet/src/use-vega-transaction.spec.tsx +++ b/libs/wallet/src/use-vega-transaction.spec.tsx @@ -24,7 +24,7 @@ function setup(context?: Partial) { return renderHook(() => useVegaTransaction(), { wrapper }); } -test('Has the correct default state', () => { +it('Has the correct default state', () => { const { result } = setup(); expect(result.current.transaction.status).toEqual(VegaTxStatus.Default); expect(result.current.transaction.txHash).toEqual(null); @@ -34,7 +34,7 @@ test('Has the correct default state', () => { expect(typeof result.current.send).toEqual('function'); }); -test('If provider returns null status should be default', async () => { +it('If provider returns null status should be default', async () => { const mockSendTx = jest.fn().mockReturnValue(Promise.resolve(null)); const { result } = setup({ sendTx: mockSendTx }); await act(async () => { @@ -43,7 +43,7 @@ test('If provider returns null status should be default', async () => { expect(result.current.transaction.status).toEqual(VegaTxStatus.Default); }); -test('Handles a single error', async () => { +it('Handles a single error', async () => { const errorMessage = 'Oops error!'; const mockSendTx = jest .fn() @@ -56,7 +56,7 @@ test('Handles a single error', async () => { expect(result.current.transaction.error).toEqual({ error: errorMessage }); }); -test('Handles multiple errors', async () => { +it('Handles multiple errors', async () => { const errorObj = { errors: { something: 'Went wrong!', @@ -71,7 +71,7 @@ test('Handles multiple errors', async () => { expect(result.current.transaction.error).toEqual(errorObj); }); -test('Returns the signature if successful', async () => { +it('Returns the signature if successful', async () => { const successObj = { tx: { inputData: 'input-data', diff --git a/libs/web3/src/lib/transaction-dialog/transaction-dialog.spec.tsx b/libs/web3/src/lib/transaction-dialog/transaction-dialog.spec.tsx index 59f75a02f..07773273d 100644 --- a/libs/web3/src/lib/transaction-dialog/transaction-dialog.spec.tsx +++ b/libs/web3/src/lib/transaction-dialog/transaction-dialog.spec.tsx @@ -26,7 +26,7 @@ const generateJsx = (moreProps?: Partial) => { return ; }; -test('Opens when tx starts and closes if the user rejects the tx', () => { +it('Opens when tx starts and closes if the user rejects the tx', () => { const { container, rerender } = render(generateJsx()); // Dialog closed by default @@ -47,7 +47,7 @@ test('Opens when tx starts and closes if the user rejects the tx', () => { expect(container).toBeEmptyDOMElement(); }); -test('Doesn\t repoen if user dismissed the dialog', () => { +it('Doesn\t repoen if user dismissed the dialog', () => { const { container, rerender } = render( generateJsx({ status: EthTxStatus.Pending }) ); @@ -62,7 +62,7 @@ test('Doesn\t repoen if user dismissed the dialog', () => { expect(container).toBeEmptyDOMElement(); }); -test('Dialog states', () => { +it('Dialog states', () => { const { rerender } = render(generateJsx({ status: EthTxStatus.Requested })); expect(screen.getByText('Confirm transaction')).toBeInTheDocument(); expect(screen.getByText('Confirm transaction in wallet')).toBeInTheDocument(); @@ -89,7 +89,7 @@ test('Dialog states', () => { expect(screen.getByText(errorMsg)).toBeInTheDocument(); }); -test('Success state waits for confirmation event if provided', () => { +it('Success state waits for confirmation event if provided', () => { const { rerender } = render( generateJsx({ status: EthTxStatus.Complete, confirmed: false }) ); diff --git a/libs/web3/src/lib/use-ethereum-transaction.test.tsx b/libs/web3/src/lib/use-ethereum-transaction.spec.tsx similarity index 96% rename from libs/web3/src/lib/use-ethereum-transaction.test.tsx rename to libs/web3/src/lib/use-ethereum-transaction.spec.tsx index 158809505..a15dc8cf4 100644 --- a/libs/web3/src/lib/use-ethereum-transaction.test.tsx +++ b/libs/web3/src/lib/use-ethereum-transaction.spec.tsx @@ -5,7 +5,7 @@ import { EthTxStatus } from './use-ethereum-transaction'; import type { ReactNode } from 'react'; import { useEthereumTransaction } from './use-ethereum-transaction'; import type { ethers } from 'ethers'; -import { EthereumError } from '../lib/ethereum-error'; +import { EthereumError } from './ethereum-error'; beforeAll(() => { jest.useFakeTimers(); @@ -56,7 +56,7 @@ function setup(perform: () => void) { ); } -test('Ethereum transaction flow', async () => { +it('Ethereum transaction flow', async () => { const { result } = setup(() => { return mockContract.depositAsset({ assetSource: 'asset-source', @@ -114,7 +114,7 @@ test('Ethereum transaction flow', async () => { }); }); -test('Error handling', async () => { +it('Error handling', async () => { const { result } = setup(() => { throw new EthereumError(errorMsg, 500); }); diff --git a/libs/web3/src/lib/web3-connect-dialog.spec.tsx b/libs/web3/src/lib/web3-connect-dialog.spec.tsx index 4ce308252..8542d03b6 100644 --- a/libs/web3/src/lib/web3-connect-dialog.spec.tsx +++ b/libs/web3/src/lib/web3-connect-dialog.spec.tsx @@ -16,7 +16,7 @@ const props = { desiredChainId: 3, }; -test('Dialog can be open or closed', () => { +it('Dialog can be open or closed', () => { const { container, rerender } = render(); expect(container).toBeEmptyDOMElement(); rerender(); @@ -26,7 +26,7 @@ test('Dialog can be open or closed', () => { ).toBeInTheDocument(); }); -test('Renders connection options', async () => { +it('Renders connection options', async () => { const spyOnConnect = jest .spyOn(foo, 'activate') .mockReturnValue(Promise.resolve()); diff --git a/libs/web3/src/lib/web3-provider.spec.tsx b/libs/web3/src/lib/web3-provider.spec.tsx index d3507319c..9b8faa79b 100644 --- a/libs/web3/src/lib/web3-provider.spec.tsx +++ b/libs/web3/src/lib/web3-provider.spec.tsx @@ -8,7 +8,7 @@ const [foo, fooHooks] = initializeConnector((actions) => new MetaMask(actions)); const connectors: [MetaMask, Web3ReactHooks][] = [[foo, fooHooks]]; -test('Renders children', async () => { +it('Renders children', async () => { await act(async () => { render( diff --git a/libs/withdraws/src/lib/use-complete-withdraw.spec.tsx b/libs/withdraws/src/lib/use-complete-withdraw.spec.tsx index 5f6f4bfa9..2eb5c1ebc 100644 --- a/libs/withdraws/src/lib/use-complete-withdraw.spec.tsx +++ b/libs/withdraws/src/lib/use-complete-withdraw.spec.tsx @@ -24,7 +24,7 @@ function setup(mocks?: MockedResponse[]) { return renderHook(() => useCompleteWithdraw(), { wrapper }); } -test('Should perform the Ethereum transaction with the fetched approval', async () => { +it('Should perform the Ethereum transaction with the fetched approval', async () => { const withdrawalId = 'withdrawal-id'; const erc20WithdrawalApproval: Erc20Approval_erc20WithdrawalApproval = { __typename: 'Erc20WithdrawalApproval', @@ -62,7 +62,7 @@ test('Should perform the Ethereum transaction with the fetched approval', async }); }); -test('Captures an error if the erc20Withdrawal is not found', async () => { +it('Captures an error if the erc20Withdrawal is not found', async () => { const withdrawalId = 'withdrawal-id'; const mockERC20Approval: MockedResponse = { request: { @@ -93,7 +93,7 @@ test('Captures an error if the erc20Withdrawal is not found', async () => { }); }); -test('Captures an error if erc20 approval query fails', async () => { +it('Captures an error if erc20 approval query fails', async () => { const withdrawalId = 'withdrawal-id'; const mockERC20Approval: MockedResponse = { request: { diff --git a/libs/withdraws/src/lib/use-withdraw.spec.tsx b/libs/withdraws/src/lib/use-withdraw.spec.tsx index 4ea32b330..a2dea26d8 100644 --- a/libs/withdraws/src/lib/use-withdraw.spec.tsx +++ b/libs/withdraws/src/lib/use-withdraw.spec.tsx @@ -102,7 +102,7 @@ beforeEach(() => { }; }); -test('Creates withdrawal and immediately submits Ethereum transaction', async () => { +it('Creates withdrawal and immediately submits Ethereum transaction', async () => { const { result } = setup([mockERC20Approval]); await act(async () => { @@ -146,7 +146,7 @@ test('Creates withdrawal and immediately submits Ethereum transaction', async () ); }); -test('Doesnt perform Ethereum tx if cancelled', async () => { +it('Doesnt perform Ethereum tx if cancelled', async () => { const { result } = setup([mockERC20Approval], true); await act(async () => { @@ -167,7 +167,7 @@ test('Doesnt perform Ethereum tx if cancelled', async () => { expect(mockPerform).not.toHaveBeenCalled(); }); -test('Reset will reset both transactions', async () => { +it('Reset will reset both transactions', async () => { const { result } = setup([mockERC20Approval]); await act(async () => { diff --git a/libs/withdraws/src/lib/use-withdrawals.spec.tsx b/libs/withdraws/src/lib/use-withdrawals.spec.tsx index d1e22fcb3..53fc1c875 100644 --- a/libs/withdraws/src/lib/use-withdrawals.spec.tsx +++ b/libs/withdraws/src/lib/use-withdrawals.spec.tsx @@ -11,7 +11,7 @@ import type { } from './__generated__/Withdrawals'; describe('updateQuery', () => { - test('Updates existing withdrawals', () => { + it('Updates existing withdrawals', () => { const withdrawal = generateWithdrawal({ id: '1', status: WithdrawalStatus.Open, @@ -32,7 +32,7 @@ describe('updateQuery', () => { }); }); - test('Adds new withdrawals', () => { + it('Adds new withdrawals', () => { const withdrawal = generateWithdrawal({ id: '1', amount: '100', @@ -53,7 +53,7 @@ describe('updateQuery', () => { }); }); - test('Creates new party if not present', () => { + it('Creates new party if not present', () => { const withdrawalUpdate = generateWithdrawal({ id: '2', }); @@ -67,7 +67,7 @@ describe('updateQuery', () => { }); }); - test('Handles updates and inserts simultaneously', () => { + it('Handles updates and inserts simultaneously', () => { const withdrawal1 = generateWithdrawal({ id: '1', status: WithdrawalStatus.Open, diff --git a/libs/withdraws/src/lib/withdraw-dialog.spec.tsx b/libs/withdraws/src/lib/withdraw-dialog.spec.tsx index e638f9bcc..6998a4576 100644 --- a/libs/withdraws/src/lib/withdraw-dialog.spec.tsx +++ b/libs/withdraws/src/lib/withdraw-dialog.spec.tsx @@ -35,7 +35,7 @@ const generateJsx = (override?: PartialDeep) => { return ; }; -test('Dialog transaction states', () => { +it('Dialog transaction states', () => { const { rerender } = render( generateJsx({ vegaTx: { diff --git a/libs/withdraws/src/lib/withdraw-form.spec.tsx b/libs/withdraws/src/lib/withdraw-form.spec.tsx index a70d32e88..d08bd6954 100644 --- a/libs/withdraws/src/lib/withdraw-form.spec.tsx +++ b/libs/withdraws/src/lib/withdraw-form.spec.tsx @@ -29,7 +29,7 @@ beforeEach(() => { const generateJsx = (props: WithdrawFormProps) => ; -test('Validation', async () => { +it('Validation', async () => { const { rerender } = render(generateJsx(props)); fireEvent.submit(screen.getByTestId('withdraw-form')); @@ -86,7 +86,7 @@ test('Validation', async () => { }); }); -test('Use max button', () => { +it('Use max button', () => { const asset = props.assets[0]; render(generateJsx({ ...props, selectedAsset: asset })); @@ -97,7 +97,7 @@ test('Use max button', () => { ); }); -test('Use connected Ethereum account', () => { +it('Use connected Ethereum account', () => { render(generateJsx({ ...props, ethereumAccount: ethereumAddress })); fireEvent.click(screen.getByText('Use connected')); diff --git a/libs/withdraws/src/lib/withdraw-manager.spec.tsx b/libs/withdraws/src/lib/withdraw-manager.spec.tsx index e03edaee2..35dd4fac9 100644 --- a/libs/withdraws/src/lib/withdraw-manager.spec.tsx +++ b/libs/withdraws/src/lib/withdraw-manager.spec.tsx @@ -47,7 +47,7 @@ const generateJsx = (props: WithdrawManagerProps) => ( ); -test('Valid form submission opens transaction dialog', async () => { +it('Valid form submission opens transaction dialog', async () => { render(generateJsx(props)); submitValid(); expect(await screen.findByRole('dialog')).toBeInTheDocument(); @@ -59,7 +59,7 @@ test('Valid form submission opens transaction dialog', async () => { }); }); -test('Expected Ethereum error closes the dialog', async () => { +it('Expected Ethereum error closes the dialog', async () => { const { rerender } = render(generateJsx(props)); submitValid(); expect(await screen.findByRole('dialog')).toBeInTheDocument(); @@ -75,7 +75,7 @@ test('Expected Ethereum error closes the dialog', async () => { expect(screen.queryByRole('dialog')).not.toBeInTheDocument(); }); -test('Correct min max values provided to form', async () => { +it('Correct min max values provided to form', async () => { render(generateJsx(props)); // Set other fields to be valid @@ -103,11 +103,11 @@ test('Correct min max values provided to form', async () => { target: { value: '2' }, }); fireEvent.submit(screen.getByTestId('withdraw-form')); - expect(await screen.findByText('Value is above maximum')); + expect(await screen.findByText('Value is above maximum')).toBeInTheDocument(); expect(mockSubmit).not.toBeCalled(); }); -test('Initial asset id can preselect asset', async () => { +it('Initial asset id can preselect asset', async () => { const asset = props.assets[0]; render(generateJsx({ ...props, initialAssetId: asset.id })); expect(screen.getByLabelText('Asset')).toHaveValue(asset.id); diff --git a/libs/withdraws/src/lib/withdrawals-table.spec.tsx b/libs/withdraws/src/lib/withdrawals-table.spec.tsx index 1529b7a5e..5095e4172 100644 --- a/libs/withdraws/src/lib/withdrawals-table.spec.tsx +++ b/libs/withdraws/src/lib/withdrawals-table.spec.tsx @@ -21,7 +21,7 @@ const generateJsx = (props: WithdrawalsTableProps) => ( ); -test('Renders the correct columns', async () => { +it('Renders the correct columns', async () => { const withdrawal = generateWithdrawal(); await act(async () => { render(generateJsx({ withdrawals: [withdrawal] })); @@ -66,49 +66,49 @@ describe('StatusCell', () => { }; }); - test('Open', () => { + it('Open', () => { props.value = WithdrawalStatus.Finalized; props.data.pendingOnForeignChain = false; props.data.txHash = null; render(); - expect(screen.getByText('Open')); + expect(screen.getByText('Open')).toBeInTheDocument(); fireEvent.click(screen.getByText('Complete', { selector: 'button' })); expect(mockComplete).toHaveBeenCalled(); }); - test('Pending', () => { + it('Pending', () => { props.value = WithdrawalStatus.Finalized; props.data.pendingOnForeignChain = true; props.data.txHash = '0x123'; render(); - expect(screen.getByText('Pending')); + expect(screen.getByText('Pending')).toBeInTheDocument(); expect(screen.getByText('View on Etherscan')).toHaveAttribute( 'href', expect.stringContaining(props.data.txHash) ); }); - test('Finalized', () => { + it('Finalized', () => { props.value = WithdrawalStatus.Finalized; props.data.pendingOnForeignChain = false; props.data.txHash = '0x123'; render(); - expect(screen.getByText('Finalized')); + expect(screen.getByText('Finalized')).toBeInTheDocument(); expect(screen.getByText('View on Etherscan')).toHaveAttribute( 'href', expect.stringContaining(props.data.txHash) ); }); - test('Fallback', () => { + it('Fallback', () => { props.value = WithdrawalStatus.Rejected; props.data.pendingOnForeignChain = false; props.data.txHash = '0x123'; render(); - expect(screen.getByText('Rejected')); + expect(screen.getByText('Rejected')).toBeInTheDocument(); }); }); diff --git a/package.json b/package.json index 495d7286d..968b35f83 100644 --- a/package.json +++ b/package.json @@ -121,6 +121,7 @@ "eslint-config-prettier": "8.1.0", "eslint-plugin-cypress": "^2.10.3", "eslint-plugin-import": "2.25.2", + "eslint-plugin-jest": "^26.1.5", "eslint-plugin-jsx-a11y": "6.5.1", "eslint-plugin-react": "7.27.0", "eslint-plugin-react-hooks": "4.3.0", diff --git a/yarn.lock b/yarn.lock index 9d4ab5b34..9da200a5f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5823,6 +5823,14 @@ "@typescript-eslint/types" "5.18.0" "@typescript-eslint/visitor-keys" "5.18.0" +"@typescript-eslint/scope-manager@5.22.0": + version "5.22.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.22.0.tgz#590865f244ebe6e46dc3e9cab7976fc2afa8af24" + integrity sha512-yA9G5NJgV5esANJCO0oF15MkBO20mIskbZ8ijfmlKIvQKg0ynVKfHZ15/nhAJN5m8Jn3X5qkwriQCiUntC9AbA== + dependencies: + "@typescript-eslint/types" "5.22.0" + "@typescript-eslint/visitor-keys" "5.22.0" + "@typescript-eslint/type-utils@5.18.0": version "5.18.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.18.0.tgz#62dbfc8478abf36ba94a90ddf10be3cc8e471c74" @@ -5842,6 +5850,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.18.0.tgz#4f0425d85fdb863071680983853c59a62ce9566e" integrity sha512-bhV1+XjM+9bHMTmXi46p1Led5NP6iqQcsOxgx7fvk6gGiV48c6IynY0apQb7693twJDsXiVzNXTflhplmaiJaw== +"@typescript-eslint/types@5.22.0": + version "5.22.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.22.0.tgz#50a4266e457a5d4c4b87ac31903b28b06b2c3ed0" + integrity sha512-T7owcXW4l0v7NTijmjGWwWf/1JqdlWiBzPqzAWhobxft0SiEvMJB56QXmeCQjrPuM8zEfGUKyPQr/L8+cFUBLw== + "@typescript-eslint/typescript-estree@5.10.1": version "5.10.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.10.1.tgz#b268e67be0553f8790ba3fe87113282977adda15" @@ -5868,6 +5881,19 @@ semver "^7.3.5" tsutils "^3.21.0" +"@typescript-eslint/typescript-estree@5.22.0": + version "5.22.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.22.0.tgz#e2116fd644c3e2fda7f4395158cddd38c0c6df97" + integrity sha512-EyBEQxvNjg80yinGE2xdhpDYm41so/1kOItl0qrjIiJ1kX/L/L8WWGmJg8ni6eG3DwqmOzDqOhe6763bF92nOw== + dependencies: + "@typescript-eslint/types" "5.22.0" + "@typescript-eslint/visitor-keys" "5.22.0" + debug "^4.3.2" + globby "^11.0.4" + is-glob "^4.0.3" + semver "^7.3.5" + tsutils "^3.21.0" + "@typescript-eslint/utils@5.18.0": version "5.18.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.18.0.tgz#27fc84cf95c1a96def0aae31684cb43a37e76855" @@ -5880,6 +5906,18 @@ eslint-scope "^5.1.1" eslint-utils "^3.0.0" +"@typescript-eslint/utils@^5.10.0": + version "5.22.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.22.0.tgz#1f2c4897e2cf7e44443c848a13c60407861babd8" + integrity sha512-HodsGb037iobrWSUMS7QH6Hl1kppikjA1ELiJlNSTYf/UdMEwzgj0WIp+lBNb6WZ3zTwb0tEz51j0Wee3iJ3wQ== + dependencies: + "@types/json-schema" "^7.0.9" + "@typescript-eslint/scope-manager" "5.22.0" + "@typescript-eslint/types" "5.22.0" + "@typescript-eslint/typescript-estree" "5.22.0" + eslint-scope "^5.1.1" + eslint-utils "^3.0.0" + "@typescript-eslint/visitor-keys@5.10.1": version "5.10.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.10.1.tgz#29102de692f59d7d34ecc457ed59ab5fc558010b" @@ -5896,6 +5934,14 @@ "@typescript-eslint/types" "5.18.0" eslint-visitor-keys "^3.0.0" +"@typescript-eslint/visitor-keys@5.22.0": + version "5.22.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.22.0.tgz#f49c0ce406944ffa331a1cfabeed451ea4d0909c" + integrity sha512-DbgTqn2Dv5RFWluG88tn0pP6Ex0ROF+dpDO1TNNZdRtLjUr6bdznjA6f/qNqJLjd2PgguAES2Zgxh/JzwzETDg== + dependencies: + "@typescript-eslint/types" "5.22.0" + eslint-visitor-keys "^3.0.0" + "@vegaprotocol/smart-contracts-sdk@^1.6.0": version "1.6.0" resolved "https://registry.yarnpkg.com/@vegaprotocol/smart-contracts-sdk/-/smart-contracts-sdk-1.6.0.tgz#c689d5928148113dddbe39ed963c74817f432d5e" @@ -10854,6 +10900,13 @@ eslint-plugin-import@^2.25.2: resolve "^1.22.0" tsconfig-paths "^3.14.1" +eslint-plugin-jest@^26.1.5: + version "26.1.5" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-26.1.5.tgz#6cfca264818d6d6aa120b019dab4d62b6aa8e775" + integrity sha512-su89aDuljL9bTjEufTXmKUMSFe2kZUL9bi7+woq+C2ukHZordhtfPm4Vg+tdioHBaKf8v3/FXW9uV0ksqhYGFw== + dependencies: + "@typescript-eslint/utils" "^5.10.0" + eslint-plugin-jsx-a11y@6.5.1, eslint-plugin-jsx-a11y@^6.5.1: version "6.5.1" resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.5.1.tgz#cdbf2df901040ca140b6ec14715c988889c2a6d8"