From b5112880a59ec4cb38328a4b3196cb52a0ffbee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Sun, 2 Sep 2018 19:12:59 +0100 Subject: [PATCH] fix(tests): add missing coverage cases for LabelNameInput --- ui/src/Components/SilenceModal/LabelNameInput.test.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ui/src/Components/SilenceModal/LabelNameInput.test.js b/ui/src/Components/SilenceModal/LabelNameInput.test.js index dbcc8934e..6af967fd4 100644 --- a/ui/src/Components/SilenceModal/LabelNameInput.test.js +++ b/ui/src/Components/SilenceModal/LabelNameInput.test.js @@ -77,7 +77,7 @@ describe("", () => { }, 100); }); - it("suggestions are empited on failed fetch", done => { + it("suggestions are emptied on failed fetch", done => { fetch.mockReject(new Error("fake error message")); ShallowLabelNameInput(); // use timeout since mount will call fetch @@ -86,4 +86,12 @@ describe("", () => { done(); }, 100); }); + + it("doesn't fetch suggestions if value is changed to empty string", () => { + const tree = MountedLabelNameInput(); + const instance = tree.instance(); + const fetchSpy = jest.spyOn(instance, "populateValueSuggestions"); + instance.onChange(""); + expect(fetchSpy).not.toHaveBeenCalled(); + }); });