Skip to content

Commit 7f97d7a

Browse files
committed
test: 增加单元测试
1 parent b8fe562 commit 7f97d7a

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/UnitTest/Components/UploadInputTest.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

6+
using AngleSharp.Dom;
67
using Microsoft.AspNetCore.Components.Forms;
78
using System.ComponentModel.DataAnnotations;
89

@@ -171,6 +172,41 @@ public void InputUpload_Files()
171172
Assert.Contains("test1.png;test2.png", cut.Markup);
172173
}
173174

175+
[Fact]
176+
public void InputUpload_IsMultiple()
177+
{
178+
var cut = Context.RenderComponent<InputUpload<List<string>>>(pb =>
179+
{
180+
pb.Add(a => a.IsMultiple, false);
181+
});
182+
183+
// 禁用多选功能
184+
cut.DoesNotContain("multiple=\"multiple\"");
185+
186+
// 给定已上传文件后上传按钮应该被禁用
187+
cut.SetParametersAndRender(pb =>
188+
{
189+
pb.Add(a => a.DefaultFileList,
190+
[
191+
new UploadFile() { FileName = "test1.png" },
192+
new UploadFile() { FileName = "test2.png" }
193+
]);
194+
});
195+
var button = cut.Find(".btn-browser");
196+
Assert.True(button.IsDisabled());
197+
198+
// 开启多选功能
199+
cut.SetParametersAndRender(pb =>
200+
{
201+
pb.Add(a => a.IsMultiple, true);
202+
});
203+
cut.Contains("multiple=\"multiple\"");
204+
205+
// 给定已上传文件后上传按钮不应该被禁用
206+
button = cut.Find(".btn-browser");
207+
Assert.False(button.IsDisabled());
208+
}
209+
174210
private class Person
175211
{
176212
[Required]

0 commit comments

Comments
 (0)