File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
LinkDotNet.Blog.IntegrationTests/Web/Pages
LinkDotNet.Blog.Web/Shared Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -46,8 +46,9 @@ public async Task ShouldSubtractLikeOnEvent()
4646 await Repository . StoreAsync ( publishedPost ) ;
4747 using var ctx = new TestContext ( ) ;
4848 var localStorage = new Mock < ILocalStorageService > ( ) ;
49- localStorage . Setup ( l => l . ContainKeyAsync ( "hasLiked" , default ) ) . ReturnsAsync ( true ) ;
50- localStorage . Setup ( l => l . GetItemAsync < bool > ( "hasLiked" , default ) ) . ReturnsAsync ( true ) ;
49+ var hasLikedStorage = $ "hasLiked/{ publishedPost . Id } ";
50+ localStorage . Setup ( l => l . ContainKeyAsync ( hasLikedStorage , default ) ) . ReturnsAsync ( true ) ;
51+ localStorage . Setup ( l => l . GetItemAsync < bool > ( hasLikedStorage , default ) ) . ReturnsAsync ( true ) ;
5152 ctx . JSInterop . Mode = JSRuntimeMode . Loose ;
5253 RegisterComponents ( ctx , localStorage . Object ) ;
5354 ctx . AddTestAuthorization ( ) . SetAuthorized ( "s" ) ;
Original file line number Diff line number Diff line change 4242
4343 HasLiked = ! HasLiked ;
4444 await OnBlogPostLiked .InvokeAsync (HasLiked );
45- await localStorage .SetItemAsync (" hasLiked" , HasLiked );
45+ await localStorage .SetItemAsync ($ " hasLiked/{ BlogPost . Id } " , HasLiked );
4646 }
4747
4848 private async Task <bool > GetHasLiked ()
4949 {
50- if (await localStorage .ContainKeyAsync (" hasLiked" ))
50+ if (await localStorage .ContainKeyAsync ($ " hasLiked/{ BlogPost . Id } " ))
5151 {
52- return await localStorage .GetItemAsync <bool >(" hasLiked" );
52+ return await localStorage .GetItemAsync <bool >($ " hasLiked/{ BlogPost . Id } " );
5353 }
5454
5555 return false ;
You can’t perform that action at this time.
0 commit comments