diff --git a/tests/uploader.spec.tsx b/tests/uploader.spec.tsx index efcb70d6..68a82084 100644 --- a/tests/uploader.spec.tsx +++ b/tests/uploader.spec.tsx @@ -369,6 +369,31 @@ describe('uploader', () => { await new Promise(resolve => setTimeout(resolve, 100)); await new Promise(resolve => setTimeout(resolve, 2000)); }); + + it('should pass file to request', done => { + const fakeRequest = jest.fn((file) => { + expect(file).toEqual(expect.objectContaining({ + filename: 'file', // <= https://github.com/react-component/upload/pull/574 + file: expect.any(File), + method: 'post', + onError: expect.any(Function), + onProgress: expect.any(Function), + onSuccess: expect.any(Function), + data: expect.anything(), + })); + + done(); + }); + + const { container } = render(); + const input = container.querySelector('input')!; + const files = [new File([''], 'success.png', { type: 'image/png' })]; + Object.defineProperty(files, 'item', { + value: i => files[i], + }); + + fireEvent.change(input, { target: { files } }); + }); }); describe('directory uploader', () => {