Skip to content

Commit 6c366d5

Browse files
committed
Added tests for CreateBlogPostPage
1 parent 3c5a20b commit 6c366d5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/LinkDotNet.Blog.UnitTests/Web/Shared/Admin/CreateNewBlogPostTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,28 @@ public void ShouldAcceptInputWithoutLosingFocusOrEnter()
177177
blogPost.Tags.Should().HaveCount(3);
178178
blogPost.Tags.Select(t => t.Content).Should().Contain(new[] { "Tag1", "Tag2", "Tag3" });
179179
}
180+
181+
[Theory]
182+
[InlineData("short", "b", true, "**", "**Test**")]
183+
[InlineData("short", "i", true, "*", "*Test*")]
184+
[InlineData("short", "b", false, "**", "Test")]
185+
[InlineData("short", "f", false, "**", "Test")]
186+
[InlineData("content", "b", true, "**", "**Test**")]
187+
[InlineData("content", "i", true, "*", "*Test*")]
188+
[InlineData("content", "b", false, "**", "Test")]
189+
[InlineData("content", "f", false, "**", "Test")]
190+
public void ShouldSetMarkerOnKeyUp(string id, string key, bool ctrlPressed, string fence, string expected)
191+
{
192+
var markerMock = new Mock<IMarkerService>();
193+
markerMock.Setup(m => m.GetNewMarkdownForElementAsync(id, "Test", fence, fence))
194+
.ReturnsAsync(expected);
195+
Services.AddScoped(_ => markerMock.Object);
196+
var cut = RenderComponent<CreateNewBlogPost>();
197+
cut.Find($"#{id}").Input("Test");
198+
cut.Find($"#{id}").KeyUp(key, ctrlKey: ctrlPressed);
199+
200+
var content = cut.Find($"#{id}").TextContent;
201+
202+
content.Should().Be(expected);
203+
}
180204
}

0 commit comments

Comments
 (0)