diff --git a/components/avatar/__tests__/__snapshots__/demo.test.js.snap b/components/avatar/__tests__/__snapshots__/demo.test.js.snap index 5ecb73d8c4..b9c8f8408e 100644 --- a/components/avatar/__tests__/__snapshots__/demo.test.js.snap +++ b/components/avatar/__tests__/__snapshots__/demo.test.js.snap @@ -2,7 +2,7 @@ exports[`renders ./components/avatar/demo/badge.md correctly 1`] = `
-

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

+

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

diff --git a/components/badge/__tests__/__snapshots__/demo.test.js.snap b/components/badge/__tests__/__snapshots__/demo.test.js.snap index d35280249a..6c1b4c45c2 100644 --- a/components/badge/__tests__/__snapshots__/demo.test.js.snap +++ b/components/badge/__tests__/__snapshots__/demo.test.js.snap @@ -1,16 +1,16 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`renders ./components/badge/demo/basic.md correctly 1`] = ` -

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

+

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

-

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

+

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

`; exports[`renders ./components/badge/demo/change.md correctly 1`] = `
-

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

+

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

', + }, + sync: false, + } + const wrapper = mount(Upload, props) + setTimeout(() => { + const mockFile = new File(['foo'], 'foo.png', { + type: 'image/png', + }) + wrapper.find({ name: 'ajaxUploader' }).vm.onChange({ + target: { + files: [mockFile], + }, + }) + }, 0) + }) + + it('should not stop upload when return value of beforeUpload is false', (done) => { + const data = jest.fn() + const props = { + propsData: { + action: 'http://upload.com', + beforeUpload: () => false, + data, + }, + listeners: { + change: ({ file }) => { + expect(file instanceof File).toBe(true) + expect(data).not.toBeCalled() + done() + }, + }, + slots: { + default: '', + }, + sync: false, + } + const wrapper = mount(Upload, props) + setTimeout(() => { + const mockFile = new File(['foo'], 'foo.png', { + type: 'image/png', + }) + wrapper.find({ name: 'ajaxUploader' }).vm.onChange({ + target: { + files: [mockFile], + }, + }) + }, 0) + }) + + it('should increase percent automaticly when call autoUpdateProgress in IE', (done) => { + let uploadInstance + let lastPercent = -1 + const props = { + propsData: { + action: 'http://jsonplaceholder.typicode.com/posts/', + }, + listeners: { + change: ({ file }) => { + if (file.percent === 0 && file.status === 'uploading') { + // manually call it + uploadInstance.autoUpdateProgress(0, file) + } + if (file.status === 'uploading') { + expect(file.percent).toBeGreaterThan(lastPercent) + lastPercent = file.percent + } + if (file.status === 'done' || file.status === 'error') { + done() + } + }, + }, + slots: { + default: '', + }, + sync: false, + } + const wrapper = mount(Upload, props) + setTimeout(() => { + const mockFile = new File(['foo'], 'foo.png', { + type: 'image/png', + }) + wrapper.find({ name: 'ajaxUploader' }).vm.onChange({ + target: { + files: [mockFile], + }, + }) + uploadInstance = wrapper.vm + }, 0) + }) + it('should not stop upload when return value of beforeUpload is not false', (done) => { + const data = jest.fn() + const props = { + propsData: { + action: 'http://upload.com', + beforeUpload () {}, + data, + }, + listeners: { + change: () => { + expect(data).toBeCalled() + done() + }, + }, + slots: { + default: '', + }, + sync: false, + } + + const wrapper = mount(Upload, props) + setTimeout(() => { + const mockFile = new File(['foo'], 'foo.png', { + type: 'image/png', + }) + wrapper.find({ name: 'ajaxUploader' }).vm.onChange({ + target: { + files: [mockFile], + }, + }) + }, 0) + }) + + describe('util', () => { + it('should be able to copy file instance', () => { + const file = new File([], 'aaa.zip') + const copiedFile = fileToObject(file); + ['uid', 'lastModified', 'lastModifiedDate', 'name', 'size', 'type'].forEach((key) => { + expect(key in copiedFile).toBe(true) + }) + }) + }) +}) diff --git a/components/upload/utils.jsx b/components/upload/utils.jsx index 44093e471b..efc82cc0f4 100644 --- a/components/upload/utils.jsx +++ b/components/upload/utils.jsx @@ -38,7 +38,7 @@ export function genPercentAdd () { if (k < 0.001) { k = 0.001 } - return start * 100 + return start } } diff --git a/components/vc-input-number/src/index.js b/components/vc-input-number/src/index.js index 0f14a71c14..f5e8947bf2 100755 --- a/components/vc-input-number/src/index.js +++ b/components/vc-input-number/src/index.js @@ -47,6 +47,7 @@ const inputNumberProps = { // onKeyUp: PropTypes.func, prefixCls: PropTypes.string, tabIndex: PropTypes.string, + placeholder: PropTypes.string, disabled: PropTypes.bool, // onFocus: PropTypes.func, // onBlur: PropTypes.func, diff --git a/components/vc-upload/src/AjaxUploader.jsx b/components/vc-upload/src/AjaxUploader.jsx index f6e5dd9575..51b78ae5b0 100644 --- a/components/vc-upload/src/AjaxUploader.jsx +++ b/components/vc-upload/src/AjaxUploader.jsx @@ -29,6 +29,7 @@ const upLoadPropTypes = { } const AjaxUploader = { + name: 'ajaxUploader', mixins: [BaseMixin], props: upLoadPropTypes, data () { diff --git a/site/routes.js b/site/routes.js index 3f19c9bd40..b66e530cd7 100644 --- a/site/routes.js +++ b/site/routes.js @@ -4,7 +4,7 @@ import Iframe from './components/iframe.vue' const AsyncTestComp = () => { const d = window.location.hash.replace('#', '') return { - component: import(`../components/upload/demo/${d}`), + component: import(`../components/input-number/demo/${d}`), } }