|
| 1 | +using LinkDotNet.Blog.TestUtilities; |
| 2 | +using LinkDotNet.Blog.Web.Features.Components; |
| 3 | +using LinkDotNet.Blog.Web.Features.SupportMe; |
| 4 | +using LinkDotNet.Blog.Web.Features.SupportMe.Components; |
| 5 | +using Microsoft.Extensions.DependencyInjection; |
| 6 | +using Microsoft.Extensions.Options; |
| 7 | + |
| 8 | +namespace LinkDotNet.Blog.UnitTests.Web.Features.SupportMe; |
| 9 | + |
| 10 | +public class SupportMePageTests : BunitContext |
| 11 | +{ |
| 12 | + [Fact] |
| 13 | + public void ShouldRenderSupportMePage() |
| 14 | + { |
| 15 | + Services.AddScoped(_ => Options.Create(new ProfileInformationBuilder().Build())); |
| 16 | + var supportMe = new SupportMeConfigurationBuilder() |
| 17 | + .WithShowSupportMePage() |
| 18 | + .WithSupportMePageDescription("**FooBar**") |
| 19 | + .Build(); |
| 20 | + Services.AddScoped(_ => Options.Create(supportMe)); |
| 21 | + |
| 22 | + var cut = Render<SupportMePage>(); |
| 23 | + |
| 24 | + cut.HasComponent<DonationSection>().ShouldBeTrue(); |
| 25 | + cut.Find(".container > div").TextContent.ShouldContain("FooBar"); |
| 26 | + } |
| 27 | + |
| 28 | + [Fact] |
| 29 | + public void PageDescriptionCanHandleMarkup() |
| 30 | + { |
| 31 | + Services.AddScoped(_ => Options.Create(new ProfileInformationBuilder().Build())); |
| 32 | + var supportMe = new SupportMeConfigurationBuilder() |
| 33 | + .WithShowSupportMePage() |
| 34 | + .WithSupportMePageDescription("**FooBar**") |
| 35 | + .Build(); |
| 36 | + Services.AddScoped(_ => Options.Create(supportMe)); |
| 37 | + |
| 38 | + var cut = Render<SupportMePage>(); |
| 39 | + |
| 40 | + cut.Find(".container > div").InnerHtml.ShouldContain("<strong>FooBar</strong>"); |
| 41 | + } |
| 42 | + |
| 43 | + [Fact] |
| 44 | + public void ShouldSetOgDataForSupportPage() |
| 45 | + { |
| 46 | + var profile = new ProfileInformationBuilder() |
| 47 | + .WithName("LinkDotNet") |
| 48 | + .Build(); |
| 49 | + Services.AddScoped(_ => Options.Create(profile)); |
| 50 | + var supportMe = new SupportMeConfigurationBuilder() |
| 51 | + .WithShowSupportMePage() |
| 52 | + .Build(); |
| 53 | + Services.AddScoped(_ => Options.Create(supportMe)); |
| 54 | + |
| 55 | + var cut = Render<SupportMePage>(); |
| 56 | + |
| 57 | + var ogData = cut.FindComponent<OgData>(); |
| 58 | + ogData.Instance.Title.ShouldBe("Support Me - LinkDotNet"); |
| 59 | + ogData.Instance.Description.ShouldBe("Support Me - LinkDotNet"); |
| 60 | + ogData.Instance.Keywords.ShouldNotBeNull(); |
| 61 | + ogData.Instance.Keywords.ShouldContain("Support"); |
| 62 | + ogData.Instance.Keywords.ShouldContain("Donation"); |
| 63 | + ogData.Instance.Keywords.ShouldContain("LinkDotNet"); |
| 64 | + } |
| 65 | +} |
0 commit comments