mirror of
https://github.com/prymitive/karma
synced 2026-05-09 03:36:44 +00:00
fix(tests): add missing linkify test coverage
This commit is contained in:
@@ -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/);
|
||||
|
||||
Reference in New Issue
Block a user