feat: add blog feed (#3)
* chore: begin working on post service * chore: add debug assets * chore: add whitelist words * feat: add prism for syntax highlighting * feat: updated favicon * feat: add blog feed * fix: add link to written by image * feat: add custom error pages * fix: focus on h2 since h1 is always the journal site title * feat: use status code pages with redirects * fix: add discernible text to link * feat: add support for light and dark theme * fix: wrap body with main tag * fix: style main element in pages to take up full width of container * fix: add heading to home page * feat: add not-found-corgi image * chore: add robots.txt file * chore: clean up place holder posts * fix: namespace header in layouts * fix: use logger instead of console * fix: use new text context in each test when registering services * chore: update workflow to debug failing tests * chore: install playwright deps * fix: extend expect timeout * fix: extend expect timeout * fix: capture traces * fix: capture traces * fix: index file name
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
@inherits Bunit.TestContext
|
||||
|
||||
@code {
|
||||
private Mock<IPostService> _postServiceMock = new();
|
||||
|
||||
[Test]
|
||||
public void Feed_WhenRendedAndNoPosts_ItShouldRenderNoPostsMessage()
|
||||
{
|
||||
_postServiceMock
|
||||
.Setup(x => x.GetPostsAsync())
|
||||
.ReturnsAsync(new List<Post>());
|
||||
|
||||
var ctx = new TestContext();
|
||||
|
||||
ctx.Services.AddSingleton(_postServiceMock.Object);
|
||||
|
||||
var cut = ctx.Render(@<Feed />);
|
||||
|
||||
cut.Find("p").MarkupMatches("<p>Looks like writers block. Check back later.</p>");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Feed_WhenRendedAndPosts_ItShouldRenderPosts()
|
||||
{
|
||||
List<Post> posts = [
|
||||
new Post() { Title = "Post 1", },
|
||||
new Post() { Title = "Post 2", },
|
||||
];
|
||||
|
||||
_postServiceMock
|
||||
.Setup(x => x.GetPostsAsync())
|
||||
.ReturnsAsync(posts);
|
||||
|
||||
var ctx = new TestContext();
|
||||
|
||||
ctx.Services.AddScoped(_ => _postServiceMock.Object);
|
||||
|
||||
var cut = ctx.Render(@<Feed />);
|
||||
|
||||
var articles = cut.FindAll("article");
|
||||
|
||||
articles.Count.Should().Be(2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user