Skip to content

Commit 1f091d2

Browse files
committed
test: add unit test
1 parent dd30499 commit 1f091d2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/UnitTest/Components/LayoutTest.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,23 @@ public void CollapseBarTemplate_Ok()
673673
Assert.Contains("CollapseBarTemplate-Content", cut.Markup);
674674
}
675675

676+
677+
[Fact]
678+
public void SkipAuthenticate_Ok()
679+
{
680+
// 未授权,通过控制 SkipAuthenticate 属性跳过授权
681+
var cut = Context.RenderComponent<CascadingValue<Task<AuthenticationState>>>(pb =>
682+
{
683+
pb.Add(a => a.Value, Task.FromResult(new AuthenticationState(new ClaimsPrincipal())));
684+
pb.AddChildContent<Layout>(pb =>
685+
{
686+
pb.Add(a => a.SkipAuthenticate, true);
687+
pb.Add(a => a.Main, builder => builder.AddContent(0, "Main"));
688+
});
689+
});
690+
cut.MarkupMatches("<section id:ignore class=\"layout\" style=\"--bb-layout-header-height: 0px; --bb-layout-footer-height: 0px;\"><main class=\"layout-main\">Main</main></section>");
691+
}
692+
676693
private static RenderFragment CreateHeader(string? content = "Header") => builder => builder.AddContent(0, content);
677694

678695
private static RenderFragment CreateFooter(string? content = "Footer") => builder => builder.AddContent(0, content);

0 commit comments

Comments
 (0)