File tree Expand file tree Collapse file tree
src/LinkDotNet.Blog.Web/Features/Search
tests/LinkDotNet.Blog.IntegrationTests/Web/Features/Search Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919
2020 protected override async Task OnParametersSetAsync ()
2121 {
22- var term = Uri .UnescapeDataString (SearchTerm );
23- blogPosts = await BlogPostRepository .GetAllAsync (t => t .IsPublished && (t .Title .Contains (term )
24- || t .Tags .Any (tag => tag == term )),
25- b => b .UpdatedDate );
22+ var term = Uri .UnescapeDataString (SearchTerm );
23+ blogPosts = await BlogPostRepository .GetAllAsync (t => t .IsPublished && (t .Title .ToLower ().Contains (term .ToLower ()) || t .Tags .Any (tag => tag .ToLower () == term .ToLower ())),
24+ b => b .UpdatedDate );
2625 }
2726}
Original file line number Diff line number Diff line change @@ -56,6 +56,34 @@ public async Task ShouldUnescapeQuery()
5656 blogPosts . Find ( ".description h4" ) . TextContent . ShouldBe ( "Title 1" ) ;
5757 }
5858
59+ [ Fact ]
60+ public async Task ShouldFindBlogPostWhenTitleMatchesCaseInsensitive ( )
61+ {
62+ var blogPost = new BlogPostBuilder ( ) . WithTitle ( "Title" ) . Build ( ) ;
63+ await Repository . StoreAsync ( blogPost ) ;
64+ using var ctx = new BunitContext ( ) ;
65+ RegisterServices ( ctx ) ;
66+
67+ var cut = ctx . Render < SearchPage > ( p => p . Add ( s => s . SearchTerm , "title" ) ) ;
68+
69+ var blogPosts = cut . WaitForComponent < ShortBlogPost > ( ) ;
70+ blogPosts . Find ( ".description h4" ) . TextContent . ShouldBe ( "Title" ) ;
71+ }
72+
73+ [ Fact ]
74+ public async Task ShouldFindBlogPostWhenTagMatchesCaseInsensitive ( )
75+ {
76+ var blogPost = new BlogPostBuilder ( ) . WithTitle ( "Title" ) . WithTags ( "Cat" ) . Build ( ) ;
77+ await Repository . StoreAsync ( blogPost ) ;
78+ using var ctx = new BunitContext ( ) ;
79+ RegisterServices ( ctx ) ;
80+
81+ var cut = ctx . Render < SearchPage > ( p => p . Add ( s => s . SearchTerm , "cat" ) ) ;
82+
83+ var blogPostComponent = cut . WaitForComponent < ShortBlogPost > ( ) ;
84+ blogPostComponent . Find ( ".description h4" ) . TextContent . ShouldBe ( "Title" ) ;
85+ }
86+
5987 private void RegisterServices ( BunitContext ctx )
6088 {
6189 ctx . Services . AddScoped ( _ => Repository ) ;
You can’t perform that action at this time.
0 commit comments