Skip to content

Commit e35830f

Browse files
committed
Added test for structured data
1 parent ac4478d commit e35830f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/LinkDotNet.Blog.IntegrationTests/Web/Features/ShowBlogPost/ShowBlogPostPageTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,29 @@ public async Task ShouldSetTagsWhenAvailable()
7575
ogData.Instance.Keywords.Should().Be("Tag1,Tag2");
7676
}
7777

78+
[Fact]
79+
public async Task ShouldSetStructuredData()
80+
{
81+
var post = new BlogPostBuilder()
82+
.WithTitle("Title")
83+
.WithPreviewImageUrl("image1")
84+
.WithPreviewImageUrlFallback("image2")
85+
.Build();
86+
await Repository.StoreAsync(post);
87+
using var ctx = new TestContext();
88+
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
89+
ctx.AddTestAuthorization();
90+
RegisterComponents(ctx);
91+
var cut = ctx.RenderComponent<ShowBlogPostPage>(
92+
p => p.Add(b => b.BlogPostId, post.Id));
93+
94+
var structuredData = cut.FindComponent<StructuredData>();
95+
96+
structuredData.Instance.Headline.Should().Be("Title");
97+
structuredData.Instance.PreviewImage.Should().Be("image1");
98+
structuredData.Instance.PreviewFallbackImage.Should().Be("image2");
99+
}
100+
78101
private void RegisterComponents(TestContextBase ctx, ILocalStorageService localStorageService = null)
79102
{
80103
ctx.Services.AddScoped(_ => Repository);

0 commit comments

Comments
 (0)