diff --git a/test/core/js/modules/ext_cosmetics.js.js b/test/core/js/modules/ext_cosmetics.js.js index f903469c6512779aea4df737e01eadd22a374daa..2352599fb2b88d981f1402fc318aac2b3eeca038 100644 --- a/test/core/js/modules/ext_cosmetics.js.js +++ b/test/core/js/modules/ext_cosmetics.js.js @@ -51,12 +51,12 @@ QUnit.test("custom datetime", function (assert) { const text_value = $(`<span class="caosdb-f-property-datetime-value">${test_case[0]}</span>`); container.append(text_value); assert.equal($(container).find(" ").length, 0, "Test original datetime."); - cosmetics.custom_datetime(); - const newValueElement = + cosmetics.custom_datetime(); + const newValueElement = container[0].querySelector("span.caosdb-v-property-datetime-customized-newvalue"); - assert.ok(newValueElement, "Datetime customization: Test if result exists."); - assert.equal(newValueElement.innerHTML, test_case[1], - "Datetime customization: compared result."); + assert.ok(newValueElement, "Datetime customization: Test if result exists."); + assert.equal(newValueElement.innerHTML, test_case[1], + "Datetime customization: compared result."); container.remove(); } }); @@ -64,22 +64,22 @@ QUnit.test("custom datetime", function (assert) { QUnit.test("linkify - https", function (assert) { assert.ok(cosmetics.linkify, "linkify available"); var test_cases = [ - ["https://link", 1], - ["this is other text https://link", 1], - ["https://link this is other text", 1], - ["this is other text https://link and this as well", 1], - ["this is other text https://link", 1], - ["this is other text https://link and here comes another link https://link and more text", 2], + ["https://link", 1, "https://link",], + ["this is other text https://link.com", 1, "https://link.com"], + ["https://link; this is other text", 1, "https://link"], + ["this is other text https://link.de and this as well", 1, "https://link.de"], + ["this is other text https://link:3000", 1, "https://link:3000"], + ["this is other text https://link.org/test, and here comes another link https://link.org/test and more text", 2, "https://link.org/test"], ]; for (let test_case of test_cases) { - const container = $('<div></div>'); + var 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"); + assert.equal($(container).find(`a[href='${test_case[2]}']`).length, 0, "no link present"); cosmetics.linkify(); - assert.equal($(container).find("a[href='https://link']").length, test_case[1], "link is present"); + assert.equal($(container).find(`a[href='${test_case[2]}']`).length, test_case[1], `link is present: ${$(container)[0].outerHTML}`); container.remove(); } });