Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/BootstrapBlazor/Components/Upload/ButtonUpload.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<BootstrapLabel required="@Required" ShowLabelTooltip="ShowLabelTooltip" Value="@DisplayText" />
}
<div @attributes="@AdditionalAttributes" class="@ClassString" id="@Id">
<Button class="@BrowserButtonClassString" IsDisabled="@CheckStatus()" Size="Size" Icon="@BrowserButtonIcon" Text="@BrowserButtonText" Color="@BrowserButtonColor">
<Button class="@BrowserButtonClassString" IsDisabled="@CheckStatus()" Size="Size" Icon="@BrowserButtonIcon"
Text="@BrowserButtonText" Color="@BrowserButtonColor">
@ChildContent
</Button>
@if (ShowUploadFileList)
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Upload/UploadBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected async Task OnFileChange(InputFileChangeEventArgs args)
fileCount = MaxFileCount.Value;

// 计算剩余可上传数量
fileCount = fileCount - Files.Count;
fileCount -= Files.Count;
if (fileCount <= 0)
{
// 如果剩余可上传数量小于等于 0 则不允许继续上传
Expand Down
9 changes: 8 additions & 1 deletion test/UnitTest/Components/UploadButtonTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void ButtonUpload_IsDisabled_Ok()
}

[Fact]
public void InputUpload_IsMultiple()
public async Task InputUpload_IsMultiple()
{
var cut = Context.RenderComponent<ButtonUpload<string>>(pb =>
{
Expand All @@ -108,6 +108,13 @@ public void InputUpload_IsMultiple()
var button = cut.Find(".btn-browser");
Assert.True(button.IsDisabled());

// 调用 Reset 方法
await cut.InvokeAsync(() => cut.Instance.Reset());

// 重置后上传按钮应该被启用
Comment on lines 108 to +114
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (testing): Consider adding assertions for error conditions and edge cases in the upload reset test.

Please add tests for cases like resetting with no files uploaded or when the upload is already enabled, and verify the uploaded files list is cleared after reset.

button = cut.Find(".btn-browser");
Assert.False(button.IsDisabled());

// 开启多选功能
cut.SetParametersAndRender(pb =>
{
Expand Down
Loading