Skip to content
Snippets Groups Projects
Commit 7060ed2c authored by Joscha Schmiedt's avatar Joscha Schmiedt
Browse files

Add more complex URL patterns to linkify tests

parent bc66a6c5
No related branches found
No related tags found
2 merge requests!131FIX: error in regexp to match URLs,!128F 344 extern linkify absorbs commas etc into link adress
......@@ -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();
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment