diff --git a/test/core/js/modules/ext_cosmetics.js.js b/test/core/js/modules/ext_cosmetics.js.js index d5d4df7f10a2859bcd7318680d4f6720aedc6127..969c8297b8b5cf85d0a668d7c30e8b0f45e34d4d 100644 --- a/test/core/js/modules/ext_cosmetics.js.js +++ b/test/core/js/modules/ext_cosmetics.js.js @@ -46,13 +46,16 @@ QUnit.test("linkify - https", function (assert) { ["this is other text https://link", 1], ["this is other text https://link and here comes another link https://link and more text", 2], ]; + for (let test_case of test_cases) { - var text_value = $(`<div class="caosdb-f-property-text-value">${test_case[0]}</div>`); - $(document.body).append(text_value); - assert.equal($(text_value).find("a[href='https://link']").length, 0, "no link present"); + const container = $('<div></div>'); + $(document.body).append(container); + const text_value = $(`<div class="caosdb-f-property-text-value">${test_case[0]}</div>`); + container.append(text_value); + assert.equal($(container).find("a[href='https://link']").length, 0, "no link present"); cosmetics.linkify(); - assert.equal($(text_value).find("a[href='https://link']").length, test_case[1], "link is present"); - text_value.remove(); + assert.equal($(container).find("a[href='https://link']").length, test_case[1], "link is present"); + container.remove(); } }); @@ -66,22 +69,26 @@ QUnit.test("linkify - http", function (assert) { ["this is other text http://link and here comes another link http://link and more text", 2], ]; for (let test_case of test_cases) { - var text_value = $(`<div class="caosdb-f-property-text-value">${test_case[0]}</div>`); - $(document.body).append(text_value); - assert.equal($(text_value).find("a[href='http://link']").length, 0, "no link present"); + const container = $('<div></div>'); + $(document.body).append(container); + const text_value = $(`<div class="caosdb-f-property-text-value">${test_case[0]}</div>`); + $(container).append(text_value); + assert.equal($(container).find("a[href='http://link']").length, 0, "no link present"); cosmetics.linkify(); - assert.equal($(text_value).find("a[href='http://link']").length, test_case[1], "link is present"); - text_value.remove(); + assert.equal($(container).find("a[href='http://link']").length, test_case[1], "link is present"); + container.remove(); } }); QUnit.test("linkify cut-off (40)", function (assert) { - var test_case = "here is some text https://this.is.a.link/with/more/than/40/characters/ this is more text"; - var text_value = $(`<div class="caosdb-f-property-text-value">${test_case}</div>`); - $(document.body).append(text_value); - assert.equal($(text_value).find("a").length, 0, "no link present"); + const container = $('<div></div>'); + $(document.body).append(container); + const test_case = "here is some text https://this.is.a.link/with/more/than/40/characters/ this is more text"; + const text_value = $(`<div class="caosdb-f-property-text-value">${test_case}</div>`); + $(container).append(text_value); + assert.equal($(container).find("a").length, 0, "no link present"); cosmetics.linkify(); - assert.equal($(text_value).find("a").length, 1, "link is present"); - assert.equal($(text_value).find("a").text(), "https://this.is.a.link/with/more/th[...] ", "link text has been cut off"); - text_value.remove(); -}); \ No newline at end of file + assert.equal($(container).find("a").length, 1, "link is present"); + assert.equal($(container).find("a").text(), "https://this.is.a.link/with/more/th[...] ", "link text has been cut off"); + container.remove(); +});