mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 06:25:51 +01:00
Fix testcase
This commit is contained in:
@@ -12,53 +12,53 @@ class HelpersSpec extends FunSpec with MockitoSugar {
|
|||||||
|
|
||||||
import helpers._
|
import helpers._
|
||||||
|
|
||||||
describe("detect and render links") {
|
describe("urlLink and decorateHtml") {
|
||||||
|
|
||||||
it("should pass identical string when no link is present") {
|
it("should pass identical string when no link is present") {
|
||||||
val before = "Description"
|
val before = "Description"
|
||||||
val after = detectAndRenderLinks(before, repository)
|
val after = decorateHtml(urlLink(before), repository)
|
||||||
assert(after == before)
|
assert(after == before)
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should convert a single link") {
|
it("should convert a single link") {
|
||||||
val before = "http://example.com"
|
val before = "http://example.com"
|
||||||
val after = detectAndRenderLinks(before, repository)
|
val after = decorateHtml(urlLink(before), repository)
|
||||||
assert(after == """<a href="http://example.com">http://example.com</a>""")
|
assert(after == """<a href="http://example.com">http://example.com</a>""")
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should convert a single link within trailing text") {
|
it("should convert a single link within trailing text") {
|
||||||
val before = "Example Project. http://example.com"
|
val before = "Example Project. http://example.com"
|
||||||
val after = detectAndRenderLinks(before, repository)
|
val after = decorateHtml(urlLink(before), repository)
|
||||||
assert(after == """Example Project. <a href="http://example.com">http://example.com</a>""")
|
assert(after == """Example Project. <a href="http://example.com">http://example.com</a>""")
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should convert a multiple links within text") {
|
it("should convert a multiple links within text") {
|
||||||
val before = "Example Project. http://example.com. (See also https://github.com/)"
|
val before = "Example Project. http://example.com. (See also https://github.com/)"
|
||||||
val after = detectAndRenderLinks(before, repository)
|
val after = decorateHtml(urlLink(before), repository)
|
||||||
assert(after == """Example Project. <a href="http://example.com">http://example.com</a>. (See also <a href="https://github.com/">https://github.com/</a>)""")
|
assert(after == """Example Project. <a href="http://example.com">http://example.com</a>. (See also <a href="https://github.com/">https://github.com/</a>)""")
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should properly escape html metacharacters") {
|
it("should properly escape html metacharacters") {
|
||||||
val before = "<>&"
|
val before = "<>&"
|
||||||
val after = detectAndRenderLinks(before, repository)
|
val after = decorateHtml(urlLink(before), repository)
|
||||||
assert(after == """<>&""")
|
assert(after == """<>&""")
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should escape html metacharacters adjacent to a link") {
|
it("should escape html metacharacters adjacent to a link") {
|
||||||
val before = "<http://example.com>"
|
val before = "<http://example.com>"
|
||||||
val after = detectAndRenderLinks(before, repository)
|
val after = decorateHtml(urlLink(before), repository)
|
||||||
assert(after == """<<a href="http://example.com">http://example.com</a>>""")
|
assert(after == """<<a href="http://example.com">http://example.com</a>>""")
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should stop link recognition at a metacharacter") {
|
it("should stop link recognition at a metacharacter") {
|
||||||
val before = "http://exa<mple.com"
|
val before = "http://exa<mple.com"
|
||||||
val after = detectAndRenderLinks(before, repository)
|
val after = decorateHtml(urlLink(before), repository)
|
||||||
assert(after == """<a href="http://exa">http://exa</a><mple.com""")
|
assert(after == """<a href="http://exa">http://exa</a><mple.com""")
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should make sure there are no double quotes in the href attribute") {
|
it("should make sure there are no double quotes in the href attribute") {
|
||||||
val before = "http://exa\"mple.com"
|
val before = "http://exa\"mple.com"
|
||||||
val after = detectAndRenderLinks(before, repository)
|
val after = decorateHtml(urlLink(before), repository)
|
||||||
assert(after == """<a href="http://exa"mple.com">http://exa"mple.com</a>""")
|
assert(after == """<a href="http://exa"mple.com">http://exa"mple.com</a>""")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user