import $ from "jquery"; // eslint-disable-line id-length import ExternalLink from "./external_link"; describe("ExternalLink", () => { const content = ` `; const config = { "icons_path": "/path/to/icons.svg" }; window.Decidim = { config: { get: (key) => config[key] } } const expectedIcon = ''; beforeEach(() => { $("body").html(content); $('a[target="_blank"]').each((_i, elem) => { const $link = $(elem); $link.data("external-link", new ExternalLink($link)); }); }); it("adds the external link indicator to the normal external link", () => { const $link = $("#links a")[0]; expect($link.outerHTML).toEqual( `This is an external link ${expectedIcon}(External link)` ); }); it("adds the external link indicator without a spacer to the image link", () => { const $link = $("#links a")[1]; expect($link.outerHTML).toEqual( `${expectedIcon}(External link)` ); }); it("adds the external link indicator with a custom spacer to the link with the custom spacer configuration", () => { const $link = $("#links a")[2]; expect($link.outerHTML).toEqual( `Custom spacer link%%%${expectedIcon}(External link)` ); }); it("adds the external link indicator with a custom container to the link with the custom container configuration", () => { const $link = $("#links a")[3]; expect($link.outerHTML).toEqual( `${expectedIcon}(External link)This is the link` ); }); });