aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-03-06 22:51:53 +0800
committercrupest <crupest@outlook.com>2021-03-06 22:51:53 +0800
commit8f09e3172f249a9f5d229040415a0569e9d1c01b (patch)
tree59507331750831118e7caa071a10e1cb8fc1e627 /BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs
parent24c272403ba360f27acd68c2702c678a86063964 (diff)
downloadtimeline-8f09e3172f249a9f5d229040415a0569e9d1c01b.tar.gz
timeline-8f09e3172f249a9f5d229040415a0569e9d1c01b.tar.bz2
timeline-8f09e3172f249a9f5d229040415a0569e9d1c01b.zip
feat: Auto translate url in markdown post.
Diffstat (limited to 'BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs')
-rw-r--r--BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs
index b91de6c2..f00d9b13 100644
--- a/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs
+++ b/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs
@@ -14,6 +14,7 @@ using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Jpeg;
using System.Net;
+using System.Text.RegularExpressions;
namespace Timeline.Tests.IntegratedTests
{
@@ -36,6 +37,23 @@ namespace Timeline.Tests.IntegratedTests
};
}
+ private static HttpTimelinePostCreateRequest CreateMarkdownPostRequest(string text, DateTime? time = null, string? color = null)
+ {
+ return new HttpTimelinePostCreateRequest()
+ {
+ Time = time,
+ Color = color,
+ DataList = new List<HttpTimelinePostCreateRequestData>()
+ {
+ new HttpTimelinePostCreateRequestData()
+ {
+ ContentType = MimeTypes.TextMarkdown,
+ Data = Convert.ToBase64String(Encoding.UTF8.GetBytes(text))
+ }
+ }
+ };
+ }
+
private readonly ITestOutputHelper _outputHelper;
public TimelinePostTest(ITestOutputHelper outputHelper)
@@ -586,5 +604,19 @@ namespace Timeline.Tests.IntegratedTests
post2.Editable.Should().BeFalse();
}
}
+
+ [Theory]
+ [MemberData(nameof(TimelineNameGeneratorTestData))]
+ public async Task Post_Markdown_Url_Map(TimelineNameGenerator generator)
+ {
+ using var client = await CreateClientAsUser();
+ var post = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts", CreateMarkdownPostRequest("[aaa](1) ![bbb](2)"));
+
+ var res = await client.GetAsync($"timelines/{generator(1)}/posts/{post.Id}/data");
+ var markdown = await res.Content.ReadAsStringAsync();
+
+ markdown.Should().MatchRegex(@$"\[aaa\]\(https?://.*/timelines/{generator(1)}/posts/{post.Id}/data/1\)");
+ markdown.Should().MatchRegex(@$"\[bbb\]\(https?://.*/timelines/{generator(1)}/posts/{post.Id}/data/2\)");
+ }
}
}