From 6f77636530163fd444d7604801e0335e557527bc Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Thu, 2 Dec 2021 13:40:02 +0100
Subject: [PATCH] TST: update tests for new implementation of linkify

---
 test/core/js/modules/ext_cosmetics.js.js | 43 ++++++++++++++----------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/test/core/js/modules/ext_cosmetics.js.js b/test/core/js/modules/ext_cosmetics.js.js
index d5d4df7f..969c8297 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();
+});
-- 
GitLab