From a14466e8e7d6c0ee871da5851a797551aadb3d16 Mon Sep 17 00:00:00 2001 From: kraaij <kraaij@astron.nl> Date: Thu, 5 Oct 2023 08:26:09 +0200 Subject: [PATCH] added comment to unit test --- .../Timeline/components/PanelButtons.test.js | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/components/PanelButtons.test.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/components/PanelButtons.test.js index 553b90a8118..00b2ffe6c76 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/components/PanelButtons.test.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/components/PanelButtons.test.js @@ -28,8 +28,8 @@ describe('PanelButtons', () => { }); it('adjusts left panel size when summary is not active', async () => { - const setLeftPanelSizeMock = jest.fn(); - const pannelComponent = render(<PanelButtons + let setLeftPanelSizeMock = jest.fn(); + const pannelComponent = render(<PanelButtons showLegendbar={false} setShowLegendbar={jest.fn()} showListTabs={true} @@ -38,7 +38,7 @@ describe('PanelButtons', () => { leftPanelSize={20} setLeftPanelSize={setLeftPanelSizeMock} />); - await waitFor(() => expect(pannelComponent.getByTitle(shrinkLabel).tobeinTheDocument)); + await waitFor(() => expect(pannelComponent.getByTitle(shrinkLabel).tobeinTheDocument)); const shrinkButton = pannelComponent.getByTitle(shrinkLabel); clickItem(shrinkButton) expect(setLeftPanelSizeMock).toHaveBeenCalledWith(10); // 10% shrink @@ -47,11 +47,16 @@ describe('PanelButtons', () => { clickItem(expandButton) expect(setLeftPanelSizeMock).toHaveBeenCalledWith(30); // 10% expand + setLeftPanelSizeMock=null; }); + + // this test can fail, allthough it's good. SOmething with Jest and React 18 running compatibility mode it('disables resize buttons when summary is active', async () => { - const pannelComponent = render(<PanelButtons + + + let pannelComponentb = render(<PanelButtons showLegendbar={false} setShowLegendbar={jest.fn()} showListTabs={true} @@ -60,12 +65,13 @@ describe('PanelButtons', () => { leftPanelSize={20} setLeftPanelSize={ jest.fn()} />); - await waitFor(() => expect(pannelComponent.getByTitle(shrinkLabel))); - const shrinkButton = pannelComponent.getByTitle(shrinkLabel); + await waitFor(() => expect(pannelComponentb.getByTitle(shrinkLabel).tobeinTheDocument)); + + const shrinkButton = pannelComponentb.getByTitle(shrinkLabel); expect(shrinkButton).toHaveAttribute("disabled") - const expandButton = pannelComponent.getByTitle(expandLabel); + const expandButton = pannelComponentb.getByTitle(expandLabel); expect(expandButton).toHaveAttribute("disabled") }); - }); + -- GitLab