Skip to content

Commit f816fed

Browse files
committed
test: 增加单元测试
1 parent 7629ab1 commit f816fed

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/UnitTest/Components/MultiSelectTest.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,33 @@ public void EnumValue_Ok()
153153
Assert.Contains("multi-select", cut.Markup);
154154
}
155155

156+
[Fact]
157+
public async Task FlagEnum_Ok()
158+
{
159+
var value = MockFlagEnum.One | MockFlagEnum.Two;
160+
var cut = Context.RenderComponent<MultiSelect<MockFlagEnum>>(pb =>
161+
{
162+
pb.Add(a => a.Value, value);
163+
});
164+
var values = cut.FindAll(".multi-select-items .multi-select-item");
165+
Assert.Equal(2, values.Count);
166+
167+
// 选中第四个
168+
var item = cut.FindAll(".dropdown-menu .dropdown-item").Last();
169+
await cut.InvokeAsync(() => item.Click());
170+
values = cut.FindAll(".multi-select-items .multi-select-item");
171+
Assert.Equal(3, values.Count);
172+
}
173+
174+
[Flags]
175+
private enum MockFlagEnum
176+
{
177+
One = 1,
178+
Two = 2,
179+
Three = 4,
180+
Four = 8
181+
}
182+
156183
[Fact]
157184
public void Group_Ok()
158185
{

0 commit comments

Comments
 (0)