Skip to content

Commit 1f3782f

Browse files
committed
Added test for table
1 parent 983e7ae commit 1f3782f

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

LinkDotNet.Blog.UnitTests/Web/Pages/Admin/SitemapTests.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
using Bunit;
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using Bunit;
24
using Bunit.TestDoubles;
5+
using FluentAssertions;
36
using LinkDotNet.Blog.Web.Pages.Admin;
47
using LinkDotNet.Blog.Web.Shared.Services.Sitemap;
58
using Microsoft.Extensions.DependencyInjection;
@@ -11,7 +14,7 @@ namespace LinkDotNet.Blog.UnitTests.Web.Pages.Admin
1114
public class SitemapTests : TestContext
1215
{
1316
[Fact]
14-
public void ShouldDisplayAndSaveSitemap()
17+
public void ShouldSaveSitemap()
1518
{
1619
this.AddTestAuthorization().SetAuthorized("steven");
1720
var sitemapMock = new Mock<ISitemapService>();
@@ -25,5 +28,30 @@ public void ShouldDisplayAndSaveSitemap()
2528

2629
sitemapMock.Verify(s => s.SaveSitemapToFileAsync(sitemap));
2730
}
31+
32+
[Fact]
33+
public void ShouldDisplaySitemap()
34+
{
35+
this.AddTestAuthorization().SetAuthorized("steven");
36+
var sitemapMock = new Mock<ISitemapService>();
37+
Services.AddScoped(_ => sitemapMock.Object);
38+
var sitemap = new SitemapUrlSet
39+
{
40+
Urls = new List<SitemapUrl>
41+
{
42+
new() { Location = "loc", LastModified = "Now" },
43+
},
44+
};
45+
sitemapMock.Setup(s => s.CreateSitemapAsync())
46+
.ReturnsAsync(sitemap);
47+
var cut = RenderComponent<Sitemap>();
48+
49+
cut.Find("button").Click();
50+
51+
cut.WaitForState(() => cut.FindAll("tr").Count > 1);
52+
var row = cut.FindAll("tr").Last();
53+
row.Children.First().InnerHtml.Should().Be("loc");
54+
row.Children.Last().InnerHtml.Should().Be("Now");
55+
}
2856
}
2957
}

0 commit comments

Comments
 (0)