fix(tests): add missing linkify test coverage

This commit is contained in:
Łukasz Mierzwa
2018-09-02 17:59:51 +01:00
parent 2bb0f2ffb0
commit a95b919872

View File

@@ -59,6 +59,18 @@ const MountedNonLinkAnnotation = visible => {
);
};
const MountedNonLinkAnnotationContainingLink = visible => {
return mount(
<RenderNonLinkAnnotation
alertStore={alertStore}
name="foo"
value="some long text with http://example.com link"
visible={visible}
afterUpdate={MockAfterUpdate}
/>
);
};
describe("<RenderNonLinkAnnotation />", () => {
it("matches snapshot when visible=true", () => {
const tree = ShallowNonLinkAnnotation(true);
@@ -80,6 +92,12 @@ describe("<RenderNonLinkAnnotation />", () => {
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("<RenderNonLinkAnnotation />", () => {
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/);