test(governance,markets): tidy up minor test quibbles (#4213)

This commit is contained in:
Edd 2023-06-29 12:20:53 +01:00 committed by GitHub
parent 45b7c2ad4d
commit 2fa00dacaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 19 deletions

View File

@ -1,5 +0,0 @@
function ReactMarkdown({ children }) {
return <div>{children}</div>;
}
export default ReactMarkdown;

View File

@ -26,9 +26,12 @@ describe('Announcements', () => {
const { container } = render(
<AnnouncementBanner app="console" configUrl={MOCK_URL} />
);
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(
<AnnouncementBanner app="console" configUrl={MOCK_URL} />
);
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();
})
);
});
});

View File

@ -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<Networks, 'CUSTOM'>;
export enum DApp {

View File

@ -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);
})
);
});
});

View File

@ -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);
});
});