Skip to content

Commit a34c442

Browse files
committed
Added tests for comment section
1 parent d20b530 commit a34c442

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Bunit;
2+
using FluentAssertions;
3+
using LinkDotNet.Blog.Web;
4+
using LinkDotNet.Blog.Web.Shared;
5+
using LinkDotNet.Blog.Web.Shared.Services;
6+
using Microsoft.Extensions.DependencyInjection;
7+
using Xunit;
8+
9+
namespace LinkDotNet.Blog.UnitTests.Web.Shared;
10+
11+
public class CommentSectionTests : TestContext
12+
{
13+
[Fact]
14+
public void ShouldShowDisqusWhenConfigured()
15+
{
16+
Services.AddScoped(_ => new AppConfiguration { DisqusConfiguration = new DisqusConfiguration() });
17+
JSInterop.Mode = JSRuntimeMode.Loose;
18+
19+
var cut = RenderComponent<CommentSection>();
20+
21+
cut.FindComponents<Disqus>().Should().NotBeEmpty();
22+
}
23+
24+
[Fact]
25+
public void ShouldShowGiscusWhenConfigured()
26+
{
27+
Services.AddScoped(_ => new AppConfiguration { GiscusConfiguration = new GiscusConfiguration() });
28+
JSInterop.Mode = JSRuntimeMode.Loose;
29+
30+
var cut = RenderComponent<CommentSection>();
31+
32+
cut.FindComponents<Giscus>().Should().NotBeEmpty();
33+
}
34+
35+
[Fact]
36+
public void ShouldShowAlertWhenMultipleRegistered()
37+
{
38+
Services.AddScoped(_ => new AppConfiguration
39+
{ DisqusConfiguration = new DisqusConfiguration(), GiscusConfiguration = new GiscusConfiguration() });
40+
JSInterop.Mode = JSRuntimeMode.Loose;
41+
42+
var cut = RenderComponent<CommentSection>();
43+
44+
cut.FindAll(".alert-danger").Should().NotBeEmpty();
45+
}
46+
}

0 commit comments

Comments
 (0)