Skip to content

Commit 4f83a7e

Browse files
committed
Added test for Page title
1 parent d0e1f9a commit 4f83a7e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/LinkDotNet.Blog.Web/Shared/AccessControl.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<li><h6 class="dropdown-header">Others</h6></li>
1717
<li><a class="dropdown-item" href="Sitemap">Sitemap</a></li>
1818
<li><hr class="dropdown-divider"></li>
19-
<li><a class="dropdown-item" target="_blank" href="https://github.com/linkdotnet/Blog/releases">Version 3.1</a></li>
19+
<li><a class="dropdown-item" target="_blank" href="https://github.com/linkdotnet/Blog/releases">Version 3.2</a></li>
2020
</ul>
2121
</li>
2222
<li class="nav-item"><a class="nav-link" href="logout?redirectUri=@CurrentUri">Log out</a></li>

tests/LinkDotNet.Blog.IntegrationTests/Web/Pages/SearchByTagTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
using System.Linq;
33
using System.Threading.Tasks;
44
using Bunit;
5+
using Bunit.TestDoubles;
56
using LinkDotNet.Blog.Domain;
67
using LinkDotNet.Blog.Infrastructure.Persistence;
78
using LinkDotNet.Blog.TestUtilities;
89
using LinkDotNet.Blog.Web.Pages;
910
using LinkDotNet.Blog.Web.Shared.Services;
11+
using Microsoft.AspNetCore.Components.Web;
1012
using Microsoft.Extensions.DependencyInjection;
1113

1214
namespace LinkDotNet.Blog.IntegrationTests.Web.Pages;
@@ -45,6 +47,21 @@ public async Task ShouldHandleSpecialCharacters()
4547
tags.Should().HaveCount(1);
4648
}
4749

50+
[Fact]
51+
public void ShouldSetTitleToTag()
52+
{
53+
using var ctx = new TestContext();
54+
ctx.Services.AddScoped<IRepository<BlogPost>>(_ => Repository);
55+
ctx.Services.AddScoped(_ => Mock.Of<IUserRecordService>());
56+
ctx.ComponentFactories.AddStub<PageTitle>();
57+
58+
var cut = ctx.RenderComponent<SearchByTag>(p => p.Add(s => s.Tag, "Tag"));
59+
60+
var pageTitleStub = cut.FindComponent<Stub<PageTitle>>();
61+
var pageTitle = ctx.Render(pageTitleStub.Instance.Parameters.Get(p => p.ChildContent));
62+
pageTitle.Markup.Should().Be("Search for tag: Tag");
63+
}
64+
4865
private async Task AddBlogPostWithTagAsync(string tag)
4966
{
5067
var blogPost = new BlogPostBuilder().WithTags(tag).Build();

0 commit comments

Comments
 (0)