Skip to content

Commit 2cb6b62

Browse files
committed
test: 补充单元测试
1 parent b086afd commit 2cb6b62

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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([email protected]) Website: https://www.blazor.zone
5+
6+
namespace UnitTest.Components;
7+
8+
public class TableNotSupportFilterTest : BootstrapBlazorTestBase
9+
{
10+
[Fact]
11+
public void OnFilterAsync_Ok()
12+
{
13+
var cut = Context.RenderComponent<TableColumnFilter>(pb =>
14+
{
15+
pb.Add(a => a.Table, new MockTable());
16+
pb.Add(a => a.Column, new MockColumn());
17+
});
18+
19+
cut.Contains("不支持的类型,请使用 FilterTemplate 自定义过滤组件");
20+
21+
var filter = cut.FindComponent<NotSupportFilter>();
22+
var conditions = filter.Instance.GetFilterConditions();
23+
Assert.Empty(conditions.Filters);
24+
25+
filter.Instance.Reset();
26+
}
27+
28+
class MockTable : ITable
29+
{
30+
public Dictionary<string, IFilterAction> Filters { get; set; } = [];
31+
32+
public Func<Task>? OnFilterAsync { get; set; }
33+
34+
public List<ITableColumn> Columns => [];
35+
36+
public IEnumerable<ITableColumn> GetVisibleColumns() => Columns;
37+
}
38+
39+
class MockColumn : TableColumn<Foo, List<string>>
40+
{
41+
public MockColumn()
42+
{
43+
PropertyType = typeof(List<string>);
44+
FieldName = "Double";
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)