File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
LinkDotNet.Blog.IntegrationTests/Web/Pages
LinkDotNet.Blog.Web/Pages Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,25 @@ public async Task ShouldShowAllBlogPostsWithLatestOneFirst()
34
34
blogPosts [ 1 ] . Find ( ".description h1" ) . InnerHtml . Should ( ) . Be ( "Old" ) ;
35
35
}
36
36
37
+ [ Fact ]
38
+ public async Task ShouldOnlyShowPublishedPosts ( )
39
+ {
40
+ var publishedPost = new BlogPostBuilder ( ) . WithTitle ( "Published" ) . IsPublished ( ) . Build ( ) ;
41
+ var unpublishedPost = new BlogPostBuilder ( ) . WithTitle ( "Not published" ) . IsPublished ( false ) . Build ( ) ;
42
+ await BlogPostRepository . StoreAsync ( publishedPost ) ;
43
+ await BlogPostRepository . StoreAsync ( unpublishedPost ) ;
44
+ using var ctx = new TestContext ( ) ;
45
+ ctx . JSInterop . Mode = JSRuntimeMode . Loose ;
46
+ ctx . Services . AddScoped < IRepository > ( _ => BlogPostRepository ) ;
47
+ ctx . Services . AddScoped ( _ => CreateSampleAppConfiguration ( ) ) ;
48
+ var cut = ctx . RenderComponent < Index > ( ) ;
49
+
50
+ var blogPosts = cut . FindComponents < ShortBlogPost > ( ) ;
51
+
52
+ blogPosts . Should ( ) . HaveCount ( 1 ) ;
53
+ blogPosts [ 0 ] . Find ( ".description h1" ) . InnerHtml . Should ( ) . Be ( "Published" ) ;
54
+ }
55
+
37
56
private static AppConfiguration CreateSampleAppConfiguration ( )
38
57
{
39
58
return new ( )
Original file line number Diff line number Diff line change 23
23
IList <BlogPost > _blogPosts = new List <BlogPost >();
24
24
protected override async Task OnInitializedAsync ()
25
25
{
26
- _blogPosts = (await _repository .GetAllAsync (orderBy : b => b .UpdatedDate )).ToList ();
26
+ _blogPosts = (await _repository .GetAllAsync (p => p . IsPublished , b => b .UpdatedDate )).ToList ();
27
27
}
28
28
29
29
private string GetAbsolutePreviewImageUrl ()
You can’t perform that action at this time.
0 commit comments