Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Compare link-commits output whole
Four checks only looked for a missing anchor, which output with the
text dropped also passes, and no message held the entities cgit
escapes it with.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/extensions/test-link-commits.lua | 21 |
1 file changed, 13 insertions, 8 deletions
diff --git a/tests/extensions/test-link-commits.lua b/tests/extensions/test-link-commits.lua index dca16d4..58b63ea 100644 --- a/tests/extensions/test-link-commits.lua +++ b/tests/extensions/test-link-commits.lua @@ -17,23 +17,23 @@ local function render(text) return h.run({}, { text }) end -local out, ret = render("see #123 near deadbee") +local out = render("see #123 near deadbee") h.equals("an unedited copy leaves issue marks as text", out, "see #123 near <a href='./?id=deadbee'>deadbee</a>") h.load_with(script, { { "-- { pattern = \"#(%d+)\"", "{ pattern = \"#(%d+)\"" } }) +local ret out, ret = render("see #123 for details") -h.contains("issue mark becomes a link", out, "<a href='https://bugs.example.com/?bug=123'>#123</a>") -h.contains("text around the link survives", out, "see ") -h.contains("text after the link survives", out, " for details") +h.equals("issue mark becomes a link amid its text", out, + "see <a href='https://bugs.example.com/?bug=123'>#123</a> for details") h.equals("close answers zero", ret, 0) out = render("fixed in deadbee") h.contains("seven hex characters link", out, "<a href='./?id=deadbee'>deadbee</a>") out = render("fixed in deadbe") -h.excludes("six hex characters stay text", out, "<a") +h.equals("six hex characters stay text", out, "fixed in deadbe") out = render("fixed in 1234567") h.contains("an all digit run still links", out, "<a href='./?id=1234567'>1234567</a>") @@ -47,13 +47,13 @@ out = render("commit " .. sha256) h.contains("a full sha256 name links", out, "'./?id=" .. sha256 .. "'") out = render("commit " .. sha256 .. "0") -h.excludes("sixty five hex characters stay text", out, "<a") +h.equals("sixty five hex characters stay text", out, "commit " .. sha256 .. "0") out = render("prefixdeadbeef") -h.excludes("a hex run inside a word stays text", out, "<a") +h.equals("a hex run inside a word stays text", out, "prefixdeadbeef") out = render("deadbeefy") -h.excludes("a hex run ending inside a word stays text", out, "<a") +h.equals("a hex run ending inside a word stays text", out, "deadbeefy") -- The issue rule wins the overlap because it starts first, and the digit run -- inside it must not be wrapped a second time. @@ -78,6 +78,11 @@ h.equals("an empty message still answers zero", ret, 0) out = render("plain words only") h.equals("a message with no matches passes through", out, "plain words only") +-- cgit hands the message over already escaped. +out = render("a & b <deadbeef>") +h.equals("escaped text keeps its entities around a link", out, + "a & b <<a href='./?id=deadbeef'>deadbeef</a>>") + -- A rule broad enough to capture a quote or a percent sign still has to -- leave a url that stays inside its attribute and means what it says. h.load_with(script, { { "local rules = {", "local rules = { { pattern = \"T:(%S+)\", url = \"https://t/%s\" }," } }) |
