Skip to content

Commit 4b0eabb

Browse files
committed
test: 增加单元测试
1 parent 2f08627 commit 4b0eabb

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
5+
6+
namespace UnitTest.Components;
7+
8+
public class FilterProviderTest : BootstrapBlazorTestBase
9+
{
10+
[Fact]
11+
public async Task FilterProvider_Ok()
12+
{
13+
var cut = Context.RenderComponent<FilterProvider>(pb =>
14+
{
15+
pb.Add(a => a.ShowMoreButton, true);
16+
pb.AddChildContent<MockFilter>();
17+
});
18+
19+
var filter = cut.FindComponent<MockFilter>();
20+
var context = filter.Instance.GetFilterContext();
21+
Assert.NotNull(context);
22+
Assert.Equal(0, context.Count);
23+
24+
// 点击 +
25+
var plus = cut.Find(".card-footer button");
26+
await cut.InvokeAsync(() => plus.Click());
27+
context = filter.Instance.GetFilterContext();
28+
Assert.NotNull(context);
29+
Assert.Equal(1, context.Count);
30+
}
31+
32+
class MockFilter : StringFilter
33+
{
34+
public FilterContext? GetFilterContext() => FilterContext;
35+
}
36+
}

0 commit comments

Comments
 (0)