From a95b919872138837cc7726afe0c1bb563c352c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Sun, 2 Sep 2018 17:59:51 +0100 Subject: [PATCH] fix(tests): add missing linkify test coverage --- .../AlertGroup/Annotation/index.test.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ui/src/Components/Grid/AlertGrid/AlertGroup/Annotation/index.test.js b/ui/src/Components/Grid/AlertGrid/AlertGroup/Annotation/index.test.js index ed1edbbad..31a3bfa67 100644 --- a/ui/src/Components/Grid/AlertGrid/AlertGroup/Annotation/index.test.js +++ b/ui/src/Components/Grid/AlertGrid/AlertGroup/Annotation/index.test.js @@ -59,6 +59,18 @@ const MountedNonLinkAnnotation = visible => { ); }; +const MountedNonLinkAnnotationContainingLink = visible => { + return mount( + + ); +}; + describe("", () => { it("matches snapshot when visible=true", () => { const tree = ShallowNonLinkAnnotation(true); @@ -80,6 +92,12 @@ describe("", () => { expect(tree.html()).not.toMatch(/some long text/); }); + it("links inside annotation are rendered as a.href", () => { + const tree = MountedNonLinkAnnotationContainingLink(true); + const link = tree.find("a[href='http://example.com']"); + expect(link.text()).toBe("http://example.com"); + }); + it("clicking on + icon hides the value", () => { const tree = MountedNonLinkAnnotation(true); expect(tree.html()).toMatch(/fa-search-minus/); @@ -89,6 +107,13 @@ describe("", () => { expect(tree.html()).not.toMatch(/some long text/); }); + it("clicking on a link inside annotation doesn't hide the value", () => { + const tree = MountedNonLinkAnnotationContainingLink(true); + expect(tree.html()).toMatch(/fa-search-minus/); + tree.find("a").simulate("click"); + expect(tree.html()).toMatch(/fa-search-minus/); + }); + it("clicking on - icon shows the value", () => { const tree = MountedNonLinkAnnotation(false); expect(tree.html()).toMatch(/fa-search-plus/);