Skip to content
Snippets Groups Projects
Verified Commit 6f776365 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

TST: update tests for new implementation of linkify

parent 94f2132f
No related branches found
No related tags found
2 merge requests!59REL: release 0.4.1,!55F linkify edit mode
Pipeline #16866 passed
......@@ -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();
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment