1
- using System . Threading . Tasks ;
1
+ using System . Linq ;
2
+ using System . Threading . Tasks ;
2
3
using Bunit ;
3
4
using FluentAssertions ;
4
5
using LinkDotNet . Blog . TestUtilities ;
@@ -26,6 +27,7 @@ public async Task ShouldShowAllBlogPostsWithLatestOneFirst()
26
27
ctx . Services . AddScoped < IRepository > ( _ => BlogPostRepository ) ;
27
28
ctx . Services . AddScoped ( _ => CreateSampleAppConfiguration ( ) ) ;
28
29
var cut = ctx . RenderComponent < Index > ( ) ;
30
+ cut . WaitForState ( ( ) => cut . FindAll ( ".blog-card" ) . Any ( ) ) ;
29
31
30
32
var blogPosts = cut . FindComponents < ShortBlogPost > ( ) ;
31
33
@@ -46,6 +48,7 @@ public async Task ShouldOnlyShowPublishedPosts()
46
48
ctx . Services . AddScoped < IRepository > ( _ => BlogPostRepository ) ;
47
49
ctx . Services . AddScoped ( _ => CreateSampleAppConfiguration ( ) ) ;
48
50
var cut = ctx . RenderComponent < Index > ( ) ;
51
+ cut . WaitForState ( ( ) => cut . FindAll ( ".blog-card" ) . Any ( ) ) ;
49
52
50
53
var blogPosts = cut . FindComponents < ShortBlogPost > ( ) ;
51
54
@@ -62,6 +65,7 @@ public async Task ShouldOnlyLoadTenEntities()
62
65
ctx . Services . AddScoped < IRepository > ( _ => BlogPostRepository ) ;
63
66
ctx . Services . AddScoped ( _ => CreateSampleAppConfiguration ( ) ) ;
64
67
var cut = ctx . RenderComponent < Index > ( ) ;
68
+ cut . WaitForState ( ( ) => cut . FindAll ( ".blog-card" ) . Any ( ) ) ;
65
69
66
70
var blogPosts = cut . FindComponents < ShortBlogPost > ( ) ;
67
71
@@ -80,6 +84,7 @@ public async Task ShouldLoadNextBatchOnClick()
80
84
81
85
cut . FindComponent < BlogPostNavigation > ( ) . Find ( "li:last-child a" ) . Click ( ) ;
82
86
87
+ cut . WaitForState ( ( ) => cut . FindAll ( ".blog-card" ) . Count == 1 ) ;
83
88
var blogPosts = cut . FindComponents < ShortBlogPost > ( ) ;
84
89
blogPosts . Count . Should ( ) . Be ( 1 ) ;
85
90
}
@@ -93,6 +98,7 @@ public async Task ShouldLoadPreviousBatchOnClick()
93
98
ctx . Services . AddScoped < IRepository > ( _ => BlogPostRepository ) ;
94
99
ctx . Services . AddScoped ( _ => CreateSampleAppConfiguration ( ) ) ;
95
100
var cut = ctx . RenderComponent < Index > ( ) ;
101
+ cut . WaitForState ( ( ) => cut . FindAll ( ".blog-card" ) . Any ( ) ) ;
96
102
cut . FindComponent < BlogPostNavigation > ( ) . Find ( "li:last-child a" ) . Click ( ) ;
97
103
98
104
cut . FindComponent < BlogPostNavigation > ( ) . Find ( "li:first-child a" ) . Click ( ) ;
0 commit comments