Skip to content

Commit

Permalink
test: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-Digital committed Jan 16, 2025
1 parent b917d57 commit 65c3876
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Extensions.Configuration;
using System.Text.Json;
using FamilyHubs.SharedKernel.Razor.FamilyHubsUi.Options.Configure;
using FamilyHubs.SharedKernel.Razor.FeatureFlags;
using FamilyHubs.SharedKernel.Razor.UnitTests.FamilyHubsUi.Configure.Helpers;
using FluentAssertions;
using Microsoft.FeatureManagement;
Expand All @@ -11,12 +12,17 @@ namespace FamilyHubs.SharedKernel.Razor.UnitTests.FamilyHubsUi.Configure;
public class FamilyHubsUiOptionsConfigureTests : FamilyHubsUiOptionsTestBase
{
private readonly IConfiguration _configuration;
private readonly IFeatureManager _featureManager;
private readonly FamilyHubsUiOptionsConfigure _familyHubsUiOptionsConfigure;

public FamilyHubsUiOptionsConfigureTests()
{
_configuration = Substitute.For<IConfiguration>();
_familyHubsUiOptionsConfigure = new FamilyHubsUiOptionsConfigure(_configuration, Substitute.For<IFeatureManager>());
_featureManager = Substitute.For<IFeatureManager>();

_featureManager.IsEnabledAsync(FeatureFlag.ConnectDashboard).Returns(true);

_familyHubsUiOptionsConfigure = new FamilyHubsUiOptionsConfigure(_configuration, _featureManager);
}

[Fact]
Expand All @@ -30,6 +36,27 @@ public void Configure_NoMutationTest()
FamilyHubsUiOptions.Should().BeEquivalentTo(expectedFamilyHubsUiOptions);
}

[Fact]
public void Configure_FeatureFlag_ConnectDashboard_Enabled()
{
_familyHubsUiOptionsConfigure.Configure(FamilyHubsUiOptions);

FamilyHubsUiOptions.Header.NavigationLinks.Should().HaveCount(2);
FamilyHubsUiOptions.Header.NavigationLinks[0].Text.Should().Be("Search for a Service");
FamilyHubsUiOptions.Header.NavigationLinks[1].Text.Should().Be("My Requests");
}

[Fact]
public void Configure_FeatureFlag_ConnectDashboard_Disabled()
{
_featureManager.IsEnabledAsync(FeatureFlag.ConnectDashboard).Returns(false);

_familyHubsUiOptionsConfigure.Configure(FamilyHubsUiOptions);

FamilyHubsUiOptions.Header.NavigationLinks.Should().HaveCount(1);
FamilyHubsUiOptions.Header.NavigationLinks[0].Text.Should().Be("Search for a Service");
}

[Theory]
[InlineData("/lower", "lower")]
[InlineData("/mix", "MiX")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ public FamilyHubsUiOptionsTestBase()
{
new FhLinkOptions
{
Text = "header navigation link",
Url = "https://example.com/navigation",
Text = "Search for a Service",
Url = "https://example.com/first",
ConfigUrl = null
},
new FhLinkOptions
{
Text = "My Requests",
Url = "https://example.com/second",
ConfigUrl = null
}
},
Expand Down

0 comments on commit 65c3876

Please sign in to comment.