diff --git a/components/upload/__tests__/__snapshots__/uploadlist.test.js.snap b/components/upload/__tests__/__snapshots__/uploadlist.test.js.snap index 3f0d028144..dd0cf87581 100644 --- a/components/upload/__tests__/__snapshots__/uploadlist.test.js.snap +++ b/components/upload/__tests__/__snapshots__/uploadlist.test.js.snap @@ -1,5 +1,79 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Upload List handle error 1`] = ` + +
+ + + + +
+
+
+
+ + + + foo.png + + +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ +`; + exports[`Upload List should be uploading when upload a file 1`] = `
{ + setTimeout(() => { + onSuccess(null, file); + }); +}; + +export const errorRequest = ({ onError }) => { + setTimeout(() => { + onError(); + }); +}; diff --git a/components/upload/__tests__/uploadlist.test.js b/components/upload/__tests__/uploadlist.test.js index ba0e07739d..004ac48d4d 100644 --- a/components/upload/__tests__/uploadlist.test.js +++ b/components/upload/__tests__/uploadlist.test.js @@ -1,6 +1,7 @@ import React from 'react'; import { mount } from 'enzyme'; import Upload from '..'; +import { errorRequest, successRequest } from './requests'; const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout)); @@ -62,23 +63,47 @@ describe('Upload List', () => { it('should be uploading when upload a file', (done) => { let wrapper; - let finished; const onChange = ({ file }) => { - if (finished) { - done(); - return; - } if (file.status === 'uploading') { expect(wrapper.render()).toMatchSnapshot(); } - if (file.status === 'error') { + if (file.status === 'done') { + expect(wrapper.render()).toMatchSnapshot(); + done(); + } + }; + wrapper = mount( + + + + ); + wrapper.find('input').simulate('change', { + target: { + files: [ + { filename: 'foo.png' }, + ], + }, + }); + }); + + it('handle error', (done) => { + let wrapper; + const onChange = ({ file }) => { + if (file.status !== 'uploading') { expect(wrapper.render()).toMatchSnapshot(); - finished = true; done(); } }; wrapper = mount( - + );