From 69220d1b2e5df97dfd205df9d1d16cef389ecfec Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 27 Jun 2022 11:51:10 -0400 Subject: [PATCH] Add tests to cover placeholder text bug Signed-off-by: Sebastian Malton --- .../namespace-select-filter.test.tsx | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/renderer/components/+namespaces/namespace-select-filter.test.tsx b/src/renderer/components/+namespaces/namespace-select-filter.test.tsx index cc0622dcba..afc0ccf69a 100644 --- a/src/renderer/components/+namespaces/namespace-select-filter.test.tsx +++ b/src/renderer/components/+namespaces/namespace-select-filter.test.tsx @@ -188,5 +188,49 @@ describe("", () => { }); }); }); + + describe("when multi-selection key is pressed", () => { + beforeEach(() => { + const filter = result.getByTestId("namespace-select-filter"); + + fireEvent.keyDown(filter, { key: "Meta" }); + }); + + it("should show placeholder text as 'All namespaces'", () => { + expect(result.baseElement.querySelector("#react-select-namespace-select-filter-placeholder")).toHaveTextContent("All namespaces"); + }); + + describe("when 'test-2' is clicked", () => { + beforeEach(() => { + result.getByText("test-2").click(); + }); + + it("should not show placeholder text as 'All namespaces'", () => { + expect(result.baseElement.querySelector("#react-select-namespace-select-filter-placeholder")).not.toHaveTextContent("All namespaces"); + }); + + describe("when 'test-2' is clicked", () => { + beforeEach(() => { + result.getByText("test-2").click(); + }); + + it("should show placeholder text as 'All namespaces'", () => { + expect(result.baseElement.querySelector("#react-select-namespace-select-filter-placeholder")).toHaveTextContent("All namespaces"); + }); + + describe("when multi-selection key is raised", () => { + beforeEach(() => { + const filter = result.getByTestId("namespace-select-filter"); + + fireEvent.keyUp(filter, { key: "Meta" }); + }); + + it("should show placeholder text as 'All namespaces'", () => { + expect(result.baseElement.querySelector("#react-select-namespace-select-filter-placeholder")).toHaveTextContent("All namespaces"); + }); + }); + }); + }); + }); }); });