File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
src/BootstrapBlazor/Components/Upload Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ protected async Task OnFileChange(InputFileChangeEventArgs args)
186186 }
187187 else if ( ValueType . IsAssignableTo ( typeof ( IEnumerable < string > ) ) )
188188 {
189- CurrentValue = ( TValue ) ( object ) string . Join ( ";" , items . Select ( f => f . OriginFileName ) ) . ToList ( ) ;
189+ CurrentValue = ( TValue ) ( object ) items . Select ( f => f . OriginFileName ) . ToList ( ) ;
190190 }
191191 else if ( ValueType == typeof ( IBrowserFile ) )
192192 {
@@ -310,6 +310,8 @@ public virtual void Reset()
310310 {
311311 DefaultFileList ? . Clear ( ) ;
312312 UploadFiles . Clear ( ) ;
313+ _filesCache = null ;
314+ CurrentValue = default ;
313315 StateHasChanged ( ) ;
314316 }
315317
Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ public void InputUpload_FileValidate_OK()
145145 }
146146
147147 [ Fact ]
148- public void InputUpload_Value ( )
148+ public async Task InputUpload_Value ( )
149149 {
150150 var cut = Context . RenderComponent < InputUpload < List < string > > > ( pb =>
151151 {
@@ -156,10 +156,18 @@ public void InputUpload_Value()
156156 ] ) ;
157157 } ) ;
158158 Assert . Contains ( "test1.png;test2.png" , cut . Markup ) ;
159+
160+ var input = cut . FindComponent < InputFile > ( ) ;
161+ await cut . InvokeAsync ( ( ) => input . Instance . OnChange . InvokeAsync ( new InputFileChangeEventArgs ( new List < MockBrowserFile > ( )
162+ {
163+ new ( "test3.png" ) ,
164+ new ( "test4.png" )
165+ } ) ) ) ;
166+ Assert . Contains ( "test3.png;test4.png" , cut . Markup ) ;
159167 }
160168
161169 [ Fact ]
162- public void InputUpload_Files ( )
170+ public async Task InputUpload_Files ( )
163171 {
164172 var cut = Context . RenderComponent < InputUpload < List < IBrowserFile > > > ( pb =>
165173 {
@@ -170,6 +178,18 @@ public void InputUpload_Files()
170178 ] ) ;
171179 } ) ;
172180 Assert . Contains ( "test1.png;test2.png" , cut . Markup ) ;
181+
182+ var input = cut . FindComponent < InputFile > ( ) ;
183+ await cut . InvokeAsync ( ( ) => input . Instance . OnChange . InvokeAsync ( new InputFileChangeEventArgs ( new List < MockBrowserFile > ( )
184+ {
185+ new ( "test3.png" ) ,
186+ new ( "test4.png" )
187+ } ) ) ) ;
188+ Assert . Contains ( "test3.png;test4.png" , cut . Markup ) ;
189+
190+ // 重置后不应该包含新上传的文件
191+ await cut . InvokeAsync ( ( ) => cut . Instance . Reset ( ) ) ;
192+ Assert . DoesNotContain ( "test3.png;test4.png" , cut . Markup ) ;
173193 }
174194
175195 [ Fact ]
You can’t perform that action at this time.
0 commit comments