From 3a9ab1f0a99ab0ed40bf4f41b3b5afb6a452a58e Mon Sep 17 00:00:00 2001 From: Paul Schultz Date: Wed, 11 Dec 2024 22:24:08 -0600 Subject: [PATCH] apply suggested changes Signed-off-by: Paul Schultz --- .../src/apis/system/ApiProvider.test.tsx | 14 ++++---------- .../components/CodeSnippet/CodeSnippet.test.tsx | 10 ++++++---- .../HeaderActionMenu/HeaderActionMenu.test.tsx | 10 +++++++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/core-app-api/src/apis/system/ApiProvider.test.tsx b/packages/core-app-api/src/apis/system/ApiProvider.test.tsx index 8db9c4e018..ceb3a0d12a 100644 --- a/packages/core-app-api/src/apis/system/ApiProvider.test.tsx +++ b/packages/core-app-api/src/apis/system/ApiProvider.test.tsx @@ -55,9 +55,7 @@ describe('ApiProvider', () => { , ); - expect(renderedHoc.getByText('hoc message: hello').innerHTML).toEqual( - 'hoc message: hello', - ); + expect(renderedHoc.getByText('hoc message: hello')).toBeInTheDocument(); }); it('should provide nested access to apis', () => { @@ -86,7 +84,7 @@ describe('ApiProvider', () => { , ); - expect(renderedHook.getByText('a=z b=y').innerHTML).toEqual('a=z b=y'); + expect(renderedHook.getByText('a=z b=y')).toBeInTheDocument(); }); it('should ignore deps in prototype', () => { @@ -109,9 +107,7 @@ describe('ApiProvider', () => { , ); - expect(renderedHoc.getByText('hoc message: hello').innerHTML).toEqual( - 'hoc message: hello', - ); + expect(renderedHoc.getByText('hoc message: hello')).toBeInTheDocument(); }); it('should error if no provider is available', () => { @@ -233,8 +229,6 @@ describe('v1 consumer', () => { , ); - expect(renderedHook.getByText('hook message: hello').innerHTML).toEqual( - 'hook message: hello', - ); + expect(renderedHook.getByText('hook message: hello')).toBeInTheDocument(); }); }); diff --git a/packages/core-components/src/components/CodeSnippet/CodeSnippet.test.tsx b/packages/core-components/src/components/CodeSnippet/CodeSnippet.test.tsx index a5b0999497..c0096e7ae9 100644 --- a/packages/core-components/src/components/CodeSnippet/CodeSnippet.test.tsx +++ b/packages/core-components/src/components/CodeSnippet/CodeSnippet.test.tsx @@ -34,10 +34,12 @@ describe('', () => { // react-syntax-highlighter is large and can cause significant slowdowns // This test makes sure we're loading things in asynchronously and not too broadly. it('renders quickly', async () => { - await expect( - renderInTestApp(), - ).resolves.not.toThrow(); - }, 1000); + const start = new Date(); + await renderInTestApp(); + const end = new Date(); + + expect(end.getTime() - start.getTime()).toBeLessThanOrEqual(1000); + }, 1500); it('renders text without exploding', async () => { const { getByText } = await renderInTestApp(); diff --git a/packages/core-components/src/layout/HeaderActionMenu/HeaderActionMenu.test.tsx b/packages/core-components/src/layout/HeaderActionMenu/HeaderActionMenu.test.tsx index 4a92cd63c3..00f52196aa 100644 --- a/packages/core-components/src/layout/HeaderActionMenu/HeaderActionMenu.test.tsx +++ b/packages/core-components/src/layout/HeaderActionMenu/HeaderActionMenu.test.tsx @@ -22,9 +22,13 @@ import userEvent from '@testing-library/user-event'; describe('', () => { it('renders without any items and without exploding', async () => { - await expect( - renderInTestApp(), - ).resolves.not.toThrow(); + const rendered = await renderInTestApp( + , + ); + + expect( + rendered.queryByTestId('header-action-item'), + ).not.toBeInTheDocument(); }); it('can open the menu and click menu items', async () => {