test: add Symbol.iterator support to createMockFileList

Add iterator implementation to createMockFileList so the mock FileList can be
used with for...of loops and spread operations, ensuring full compatibility
with the iterable FileList interface.
This commit is contained in:
Johnpaul
2026-01-25 02:55:29 +01:00
parent 97ecec0cb1
commit f315398b1a

View File

@@ -180,7 +180,10 @@ export function createMockFileList(files: File[]): FileList {
const fileList = {
...files,
length: files.length,
item: (index: number) => files[index] ?? null
item: (index: number) => files[index] ?? null,
[Symbol.iterator]: function* () {
yield* files
}
}
return fileList as FileList
}