Skip to content

Commit 1703c2f

Browse files
committed
test: 增加 IsImage 扩展方法单元测试
1 parent 4c9f1aa commit 1703c2f

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/BootstrapBlazor/Components/Upload/UploadFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public class UploadFile
8181
/// 获得 UploadFile 文件名
8282
/// </summary>
8383
/// <returns></returns>
84-
public string? GetFileName() => FileName ?? OriginFileName;
84+
public string? GetFileName() => FileName ?? OriginFileName ?? File?.Name;
8585

8686
/// <summary>
8787
/// 获得 UploadFile 文件扩展名

test/UnitTest/Components/UploadCardTest.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,21 @@ public void AllowExtensions_Ok()
151151
var cut = Context.RenderComponent<CardUpload<string>>(pb =>
152152
{
153153
pb.Add(a => a.AllowExtensions, [".dba"]);
154-
pb.Add(a => a.DefaultFileList, new List<UploadFile>()
155-
{
154+
pb.Add(a => a.DefaultFileList,
155+
[
156156
new() { FileName = "test.dba" }
157-
});
157+
]);
158158
});
159-
160159
cut.Contains("<span>test.dba</span> (0 B)");
160+
161+
cut.SetParametersAndRender(pb =>
162+
{
163+
pb.Add(a => a.DefaultFileList,
164+
[
165+
new() { File = new MockBrowserFile("demo.dba") }
166+
]);
167+
});
168+
cut.Contains("<span>demo.dba</span> (0 B)");
161169
}
162170

163171
[Fact]

0 commit comments

Comments
 (0)