From 2edffeebd79fa2eb6424f78e5677c823997729da Mon Sep 17 00:00:00 2001 From: Tharun Rajendran Date: Mon, 21 Mar 2022 21:55:08 +0530 Subject: [PATCH] chore(test): rewritten core layout component test using rtl (#4655) --- frontend/layouts/CoreLayout/CoreLayout.tests.jsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/layouts/CoreLayout/CoreLayout.tests.jsx b/frontend/layouts/CoreLayout/CoreLayout.tests.jsx index e7262cf2e1..4ce3a144b4 100644 --- a/frontend/layouts/CoreLayout/CoreLayout.tests.jsx +++ b/frontend/layouts/CoreLayout/CoreLayout.tests.jsx @@ -1,4 +1,4 @@ -import { mount } from "enzyme"; +import { render, screen } from "@testing-library/react"; import helpers from "test/helpers"; import { userStub } from "test/stubs"; @@ -38,13 +38,12 @@ describe("CoreLayout - layouts", () => { mockStore, }); - const appWithFlash = mount(componentWithFlash); - const appWithoutFlash = mount(componentWithoutFlash); + const { container, rerender } = render(componentWithFlash); - expect(appWithFlash.length).toEqual(1); - expect(appWithoutFlash.length).toEqual(1); + expect(container.querySelector(".flash-message")).toBeInTheDocument(); - expect(appWithFlash.find("FlashMessage").html()).toBeTruthy(); - expect(appWithoutFlash.find("FlashMessage").html()).toBeFalsy(); + rerender(componentWithoutFlash); + + expect(container.querySelector(".flash-message")).not.toBeInTheDocument(); }); });