From b2a0e27cbe10c50f1bbeeea8f91fde30a684e3a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Mon, 27 Aug 2018 09:46:12 +0100 Subject: [PATCH] fix(tests): add tests for matcher delete button visibility --- .../SilenceModal/SilenceForm.test.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ui/src/Components/SilenceModal/SilenceForm.test.js b/ui/src/Components/SilenceModal/SilenceForm.test.js index 5db5e0f64..f0d189c80 100644 --- a/ui/src/Components/SilenceModal/SilenceForm.test.js +++ b/ui/src/Components/SilenceModal/SilenceForm.test.js @@ -43,6 +43,26 @@ describe(" matchers", () => { expect(silenceFormStore.data.matchers).toHaveLength(2); }); + it("trash icon is not visible when there's only one matcher", () => { + const tree = MountedSilenceForm(); + expect(silenceFormStore.data.matchers).toHaveLength(1); + + const matcher = tree.find("SilenceMatch"); + const button = matcher.find("button"); + expect(button).toHaveLength(0); + }); + + it("trash icon is visible when there are two matchers", () => { + silenceFormStore.data.addEmptyMatcher(); + silenceFormStore.data.addEmptyMatcher(); + const tree = MountedSilenceForm(); + expect(silenceFormStore.data.matchers).toHaveLength(2); + + const matcher = tree.find("SilenceMatch"); + const button = matcher.find("button"); + expect(button).toHaveLength(2); + }); + it("clicking trash icon on a matcher select removes it", () => { silenceFormStore.data.addEmptyMatcher(); silenceFormStore.data.addEmptyMatcher();