Skip to content

Commit e5ea51a

Browse files
authored
Update uploader.spec.tsx
补充UT
1 parent 6b3d0d3 commit e5ea51a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/uploader.spec.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,32 @@ describe('uploader', () => {
307307
done();
308308
}, 100);
309309
});
310+
311+
it('drag unaccepted type files with multiple false to upload will not trigger onStart ', done => {
312+
const { container } = render(<Upload {...props} multiple={false} />);
313+
314+
const input = container.querySelector('input')!;
315+
const files = [
316+
{
317+
name: 'success.jpg',
318+
toString() {
319+
return this.name;
320+
},
321+
},
322+
];
323+
(files as any).item = (i: number) => files[i];
310324

325+
fireEvent.drop(input, {
326+
dataTransfer: { files },
327+
});
328+
const mockStart = jest.fn();
329+
handlers.onStart = mockStart;
330+
setTimeout(() => {
331+
expect(mockStart.mock.calls.length).toBe(0);
332+
done();
333+
}, 100);
334+
});
335+
311336
it('drag files with multiple false', done => {
312337
const { container } = render(<Upload {...props} multiple={false} />);
313338
const input = container.querySelector('input')!;

0 commit comments

Comments
 (0)