Skip to content

Commit 4b0ff0e

Browse files
committed
test: UploadDrop 增加 OnCancel 单元测试
1 parent 431cc1b commit 4b0ff0e

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/UnitTest/Components/UploadDropTest.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,39 @@ public async Task ShowUploadList_Ok()
103103
Assert.NotNull(file);
104104
}
105105

106+
[Fact]
107+
public async Task DropUpload_ShowProgress_Ok()
108+
{
109+
var cancel = false;
110+
var cut = Context.RenderComponent<DropUpload>(pb =>
111+
{
112+
pb.Add(a => a.ShowProgress, true);
113+
pb.Add(a => a.OnChange, async file =>
114+
{
115+
await Task.Delay(100);
116+
await file.SaveToFileAsync("1.txt");
117+
});
118+
pb.Add(a => a.OnCancel, file =>
119+
{
120+
cancel = true;
121+
return Task.CompletedTask;
122+
});
123+
});
124+
var input = cut.FindComponent<InputFile>();
125+
await cut.InvokeAsync(async () =>
126+
{
127+
_ = input.Instance.OnChange.InvokeAsync(new InputFileChangeEventArgs(new List<MockBrowserFile>()
128+
{
129+
new()
130+
}));
131+
132+
var button = cut.Find(".cancel-icon");
133+
Assert.NotNull(button);
134+
await cut.InvokeAsync(() => button.Click());
135+
Assert.True(cancel);
136+
});
137+
}
138+
106139
[Fact]
107140
public void ButtonUpload_OnGetFileFormat_Ok()
108141
{

0 commit comments

Comments
 (0)