mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 12:53:11 +08:00
Add extended testing for Markdown links
While reviewing #6542 it became apparent that there was another Markdown link format variant, used in comments that came from the web API, called the "inline link" style. It allows to specify the tooltip title within the actual URL portion, as such: [link text](https://osu.ppy.sh "tooltip text") Add tests with a couple of easy and trickier examples of such a format. Moreover, add a new edge case of a Markdown link with a link inside the display text, which during tests was detected to be problematic.
This commit is contained in:
parent
ef4dd3e028
commit
a89ea78a7a
@ -273,6 +273,54 @@ namespace osu.Game.Tests.Chat
|
||||
Assert.AreEqual(21, result.Links[0].Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMarkdownFormatLinkWithInlineTitle()
|
||||
{
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [this link format](https://osu.ppy.sh \"osu!\") before..." });
|
||||
|
||||
Assert.AreEqual("I haven't seen this link format before...", result.DisplayContent);
|
||||
Assert.AreEqual(1, result.Links.Count);
|
||||
Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
|
||||
Assert.AreEqual(15, result.Links[0].Index);
|
||||
Assert.AreEqual(16, result.Links[0].Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMarkdownFormatLinkWithInlineTitleAndEscapedQuotes()
|
||||
{
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [this link format](https://osu.ppy.sh \"inner quote \\\" just to confuse \") before..." });
|
||||
|
||||
Assert.AreEqual("I haven't seen this link format before...", result.DisplayContent);
|
||||
Assert.AreEqual(1, result.Links.Count);
|
||||
Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
|
||||
Assert.AreEqual(15, result.Links[0].Index);
|
||||
Assert.AreEqual(16, result.Links[0].Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMarkdownFormatLinkWithUrlInTextAndInlineTitle()
|
||||
{
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [https://osu.ppy.sh](https://osu.ppy.sh \"https://osu.ppy.sh\") before..." });
|
||||
|
||||
Assert.AreEqual("I haven't seen https://osu.ppy.sh before...", result.DisplayContent);
|
||||
Assert.AreEqual(1, result.Links.Count);
|
||||
Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
|
||||
Assert.AreEqual(15, result.Links[0].Index);
|
||||
Assert.AreEqual(18, result.Links[0].Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMarkdownFormatLinkWithMisleadingUrlInText()
|
||||
{
|
||||
Message result = MessageFormatter.FormatMessage(new Message { Content = "I haven't seen [https://google.com](https://osu.ppy.sh) before..." });
|
||||
|
||||
Assert.AreEqual("I haven't seen https://google.com before...", result.DisplayContent);
|
||||
Assert.AreEqual(1, result.Links.Count);
|
||||
Assert.AreEqual("https://osu.ppy.sh", result.Links[0].Url);
|
||||
Assert.AreEqual(15, result.Links[0].Index);
|
||||
Assert.AreEqual(18, result.Links[0].Length);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChannelLink()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user