import ExternalDomainLink from "src/decidim/external_domain_warning"; describe("ExternalDomainLink", () => { const content = `
`; const config = { "external_domain_allowlist": ["example.com"] }; window.Decidim = { config: { get: (key) => config[key] } } beforeEach(() => { $("body").html(content); $('a[target="_blank"]').each((_i, elem) => new ExternalDomainLink(elem)); }); it("updates the link to the external link URL", () => { const $link = $("#links a")[0]; expect($link.outerHTML).toEqual( 'This is an external link' ); }); it("does not update the link to the external link URL when its in the allow list", () => { const $link = $("#links a")[1]; expect($link.outerHTML).toEqual( 'This is an external link from a domain in the allowlist' ); }); it("does not update the link to the external link URL when the parent class is excluded", () => { const $link = $("#links a")[2]; expect($link.outerHTML).toEqual( 'This is an external link within an editor' ); }); it("updates the link to the external link URL", () => { const $link = $("#links a")[3]; expect($link.outerHTML).toEqual( 'This is an external link without the last slash' ); }); });