Skip to content

Commit 2dc2b23

Browse files
committed
refactor: More simplifications
1 parent 652e0be commit 2dc2b23

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

tests/LinkDotNet.Blog.IntegrationTests/Web/Features/Home/IndexTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ public void ShouldSetAbsoluteUriForOgData(string givenUri, string expectedUri)
117117

118118
var cut = ctx.RenderComponent<Index>();
119119

120-
cut.WaitForState(() => cut.FindComponents<OgData>().Any());
121-
cut.FindComponent<OgData>().Instance.AbsolutePreviewImageUrl.Should().Be(expectedUri);
120+
cut.WaitForComponent<OgData>().Instance.AbsolutePreviewImageUrl.Should().Be(expectedUri);
122121
}
123122

124123
[Theory]

tests/LinkDotNet.Blog.IntegrationTests/Web/Features/Search/SearchPageTests.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ public async Task ShouldFindBlogPostWhenTitleMatches()
2323

2424
var cut = ctx.RenderComponent<SearchPage>(p => p.Add(s => s.SearchTerm, "Title 1"));
2525

26-
cut.WaitForState(() => cut.FindComponents<ShortBlogPost>().Any());
27-
var blogPosts = cut.FindComponents<ShortBlogPost>();
28-
blogPosts.Should().HaveCount(1);
29-
blogPosts.Single().Find(".description h1").TextContent.Should().Be("Title 1");
26+
var blogPosts = cut.WaitForComponent<ShortBlogPost>();
27+
blogPosts.Find(".description h1").TextContent.Should().Be("Title 1");
3028
}
3129

3230
[Fact]
@@ -41,10 +39,8 @@ public async Task ShouldFindBlogPostWhenTagMatches()
4139

4240
var cut = ctx.RenderComponent<SearchPage>(p => p.Add(s => s.SearchTerm, "Cat"));
4341

44-
cut.WaitForState(() => cut.FindComponents<ShortBlogPost>().Any());
45-
var blogPosts = cut.FindComponents<ShortBlogPost>();
46-
blogPosts.Should().HaveCount(1);
47-
blogPosts.Single().Find(".description h1").TextContent.Should().Be("Title 1");
42+
var blogPost = cut.WaitForComponent<ShortBlogPost>();
43+
blogPost.Find(".description h1").TextContent.Should().Be("Title 1");
4844
}
4945

5046
[Fact]
@@ -57,10 +53,8 @@ public async Task ShouldUnescapeQuery()
5753

5854
var cut = ctx.RenderComponent<SearchPage>(p => p.Add(s => s.SearchTerm, "Title%201"));
5955

60-
cut.WaitForState(() => cut.FindComponents<ShortBlogPost>().Any());
61-
var blogPosts = cut.FindComponents<ShortBlogPost>();
62-
blogPosts.Should().HaveCount(1);
63-
blogPosts.Single().Find(".description h1").TextContent.Should().Be("Title 1");
56+
var blogPosts = cut.WaitForComponent<ShortBlogPost>();
57+
blogPosts.Find(".description h1").TextContent.Should().Be("Title 1");
6458
}
6559

6660
private void RegisterServices(TestContext ctx)

tests/LinkDotNet.Blog.IntegrationTests/Web/Shared/Skills/SkillTableTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ public async Task ShouldNotAllowToEditSkillTagsWhenNotAdmin()
6767
var cut = ctx.RenderComponent<SkillTable>(p =>
6868
p.Add(s => s.ShowAdminActions, false));
6969

70-
cut.WaitForState(() => cut.FindComponents<SkillTag>().Any());
71-
cut.FindComponent<SkillTag>().Instance.ShowAdminActions.Should().BeFalse();
70+
cut.WaitForComponent<SkillTag>().Instance.ShowAdminActions.Should().BeFalse();
7271
}
7372

7473
[Fact]

tests/LinkDotNet.Blog.UnitTests/Web/Features/Admin/Sitemap/SitemapPageTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ public void ShouldDisplaySitemap()
4343

4444
cut.Find("button").Click();
4545

46-
cut.WaitForState(() => cut.FindAll("tr").Count > 1);
47-
var row = cut.FindAll("tr").Last();
46+
var row = cut.WaitForElements("tr").Last();
4847
row.Children.First().InnerHtml.Should().Be("loc");
4948
row.Children.Last().InnerHtml.Should().Be("Now");
5049
}

0 commit comments

Comments
 (0)