From 2fa00dacaada5bf44534a91ef540ceffcc0338a6 Mon Sep 17 00:00:00 2001 From: Edd Date: Thu, 29 Jun 2023 12:20:53 +0100 Subject: [PATCH] test(governance,markets): tidy up minor test quibbles (#4213) --- .../src/__mocks__/react-markdown.js | 5 ---- .../src/lib/announcements.spec.tsx | 27 ++++++++++++------- libs/environment/src/hooks/use-links.ts | 3 ++- .../src/hooks/use-vega-release.spec.ts | 10 ++++--- .../src/lib/hooks/use-oracle-markets.spec.ts | 1 - 5 files changed, 27 insertions(+), 19 deletions(-) delete mode 100644 apps/governance/src/__mocks__/react-markdown.js diff --git a/apps/governance/src/__mocks__/react-markdown.js b/apps/governance/src/__mocks__/react-markdown.js deleted file mode 100644 index 016bb24d0..000000000 --- a/apps/governance/src/__mocks__/react-markdown.js +++ /dev/null @@ -1,5 +0,0 @@ -function ReactMarkdown({ children }) { - return
{children}
; -} - -export default ReactMarkdown; diff --git a/libs/announcements/src/lib/announcements.spec.tsx b/libs/announcements/src/lib/announcements.spec.tsx index 7690417b6..cc8ecbbb2 100644 --- a/libs/announcements/src/lib/announcements.spec.tsx +++ b/libs/announcements/src/lib/announcements.spec.tsx @@ -26,9 +26,12 @@ describe('Announcements', () => { const { container } = render( ); - await waitFor(() => { - expect(container.firstChild).toBeEmptyDOMElement(); - }); + await act( + async () => + await waitFor(() => { + expect(container.firstChild).toBeEmptyDOMElement(); + }) + ); }); it('does not display the banner when there are no announcements', async () => { @@ -42,9 +45,12 @@ describe('Announcements', () => { const { container } = render( ); - await waitFor(() => { - expect(container.firstChild).toBeEmptyDOMElement(); - }); + await act( + async () => + await waitFor(() => { + expect(container.firstChild).toBeEmptyDOMElement(); + }) + ); }); it('shows the correct announcement', async () => { @@ -200,8 +206,11 @@ describe('Announcements', () => { jest.runOnlyPendingTimers(); }); - await waitFor(() => { - expect(queryByText('Live text')).not.toBeInTheDocument(); - }); + await act( + async () => + await waitFor(() => { + expect(queryByText('Live text')).not.toBeInTheDocument(); + }) + ); }); }); diff --git a/libs/environment/src/hooks/use-links.ts b/libs/environment/src/hooks/use-links.ts index 556fd0af7..6642a66d1 100644 --- a/libs/environment/src/hooks/use-links.ts +++ b/libs/environment/src/hooks/use-links.ts @@ -4,7 +4,8 @@ import { Networks } from '../types'; import { useEnvironment } from './use-environment'; import { stripFullStops } from '@vegaprotocol/utils'; -const VEGA_DOCS_URL = process.env['NX_VEGA_DOCS_URL'] || ''; +const VEGA_DOCS_URL = + process.env['NX_VEGA_DOCS_URL'] || 'https://docs.vega.xyz/mainnet'; type Net = Exclude; export enum DApp { diff --git a/libs/environment/src/hooks/use-vega-release.spec.ts b/libs/environment/src/hooks/use-vega-release.spec.ts index 6144b1554..e290dd062 100644 --- a/libs/environment/src/hooks/use-vega-release.spec.ts +++ b/libs/environment/src/hooks/use-vega-release.spec.ts @@ -6,6 +6,7 @@ import { GITHUB_VEGA_DEV_RELEASES_DATA, } from './mocks/github-releases'; import { useVegaRelease } from './use-vega-release'; +import { act } from 'react-dom/test-utils'; describe('useVegaRelease', () => { beforeEach(() => { @@ -31,8 +32,11 @@ describe('useVegaRelease', () => { it('should return undefined when a release cannot be found', async () => { const { result } = renderHook(() => useVegaRelease('v0.70.1')); - await waitFor(() => { - expect(result.current).toEqual(undefined); - }); + await act( + async () => + await waitFor(() => { + expect(result.current).toEqual(undefined); + }) + ); }); }); diff --git a/libs/markets/src/lib/hooks/use-oracle-markets.spec.ts b/libs/markets/src/lib/hooks/use-oracle-markets.spec.ts index 607e79b2d..3274054f8 100644 --- a/libs/markets/src/lib/hooks/use-oracle-markets.spec.ts +++ b/libs/markets/src/lib/hooks/use-oracle-markets.spec.ts @@ -19,7 +19,6 @@ describe('useOracleMarkets', () => { it('returns correct market list for the given provider', () => { mockMarkets.mockReturnValueOnce({ data: marketsData }); const { result } = renderHook(() => useOracleMarkets(mockProvider)); - console.log(JSON.stringify(result.current)); expect(result.current).toStrictEqual(oracleMarkets); }); });