test: update some not support props

pull/2682/head
tangjinzhou 2020-07-25 15:46:49 +08:00
parent 5624f92a33
commit ed2a8d6cef
54 changed files with 220 additions and 207 deletions

View File

@ -39,5 +39,6 @@ module.exports = {
'!components/style.js', '!components/style.js',
'!**/node_modules/**', '!**/node_modules/**',
], ],
testEnvironment: 'jest-environment-jsdom-fifteen',
transformIgnorePatterns, transformIgnorePatterns,
}; };

View File

@ -70,7 +70,7 @@ describe('Affix Render', () => {
jest.runAllTimers(); jest.runAllTimers();
}; };
it('Anchor render perfectly', () => { it('Anchor render perfectly', () => {
wrapper = mount(AffixMounter, { attachToDocument: true }); wrapper = mount(AffixMounter, { attachTo: 'body' });
jest.runAllTimers(); jest.runAllTimers();
movePlaceholder(0); movePlaceholder(0);
@ -84,8 +84,8 @@ describe('Affix Render', () => {
}); });
it('support offsetBottom', () => { it('support offsetBottom', () => {
wrapper = mount(AffixMounter, { wrapper = mount(AffixMounter, {
attachToDocument: true, attachTo: 'body',
propsData: { props: {
offsetBottom: 0, offsetBottom: 0,
}, },
}); });
@ -104,8 +104,8 @@ describe('Affix Render', () => {
// it('updatePosition when offsetTop changed', () => { // it('updatePosition when offsetTop changed', () => {
// wrapper = mount(AffixMounter, { // wrapper = mount(AffixMounter, {
// attachToDocument: true, // attachTo: 'body',
// propsData: { // props: {
// offsetTop: 0, // offsetTop: 0,
// }, // },
// }); // });

View File

@ -88,6 +88,8 @@ export const AnchorProps = {
wrapperStyle: PropTypes.object, wrapperStyle: PropTypes.object,
getCurrentAnchor: PropTypes.func, getCurrentAnchor: PropTypes.func,
targetOffset: PropTypes.number, targetOffset: PropTypes.number,
onChange: PropTypes.func,
onClick: PropTypes.func,
}; };
export default { export default {

View File

@ -1,5 +1,5 @@
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import Vue from 'vue'; import * as Vue from 'vue';
import { asyncExpect } from '@/tests/utils'; import { asyncExpect } from '@/tests/utils';
import Anchor from '..'; import Anchor from '..';
@ -63,7 +63,7 @@ describe('Anchor Render', () => {
); );
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
Vue.nextTick(() => { Vue.nextTick(() => {
wrapper.vm.$refs.anchor.handleScroll(); wrapper.vm.$refs.anchor.handleScroll();
@ -87,7 +87,7 @@ describe('Anchor Render', () => {
); );
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(() => { await asyncExpect(() => {
wrapper.vm.$refs.anchor.handleScrollTo('##API'); wrapper.vm.$refs.anchor.handleScrollTo('##API');
@ -110,11 +110,11 @@ describe('Anchor Render', () => {
); );
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(() => { await asyncExpect(() => {
const removeListenerSpy = jest.spyOn(wrapper.vm.$refs.anchor.scrollEvent, 'remove'); const removeListenerSpy = jest.spyOn(wrapper.vm.$refs.anchor.scrollEvent, 'remove');
wrapper.destroy(); wrapper.unmount();
expect(removeListenerSpy).toHaveBeenCalled(); expect(removeListenerSpy).toHaveBeenCalled();
}); });
}); });
@ -134,7 +134,7 @@ describe('Anchor Render', () => {
); );
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect(wrapper.vm.$refs.anchor.links).toEqual(['#API']); expect(wrapper.vm.$refs.anchor.links).toEqual(['#API']);
@ -159,8 +159,8 @@ describe('Anchor Render', () => {
}, },
{ {
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
propsData: { props: {
href: '#API', href: '#API',
}, },
}, },

View File

@ -19,7 +19,7 @@ describe('AutoComplete with Custom Input Element Render', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
expect(wrapper.findAll('input').length).toBe(1); expect(wrapper.findAll('input').length).toBe(1);
const input = wrapper.find('input'); const input = wrapper.find('input');

View File

@ -38,11 +38,11 @@ describe('Avatar Render', () => {
slots: { slots: {
default: 'Fallback', default: 'Fallback',
}, },
propsData: { props: {
src: 'http://error.url', src: 'http://error.url',
}, },
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}); });
wrapper.vm.setScale = jest.fn(() => { wrapper.vm.setScale = jest.fn(() => {
if (wrapper.vm.scale === 0.5) { if (wrapper.vm.scale === 0.5) {
@ -91,7 +91,7 @@ describe('Avatar Render', () => {
}, },
}; };
const wrapper = mount(Foo, { sync: false, attachToDocument: true }); const wrapper = mount(Foo, { sync: false, attachTo: 'body' });
await asyncExpect(() => { await asyncExpect(() => {
// mock img load Error, since jsdom do not load resource by default // mock img load Error, since jsdom do not load resource by default
// https://github.com/jsdom/jsdom/issues/1816 // https://github.com/jsdom/jsdom/issues/1816
@ -122,7 +122,7 @@ describe('Avatar Render', () => {
}, },
}; };
const wrapper = mount(Foo, { sync: false, attachToDocument: true }); const wrapper = mount(Foo, { sync: false, attachTo: 'body' });
await asyncExpect(() => { await asyncExpect(() => {
wrapper.find('img').trigger('error'); wrapper.find('img').trigger('error');
}, 0); }, 0);

View File

@ -5,7 +5,7 @@ import { sleep } from '../../../tests/utils';
describe('BackTop', () => { describe('BackTop', () => {
it('should scroll to top after click it', async () => { it('should scroll to top after click it', async () => {
const wrapper = mount(BackTop, { const wrapper = mount(BackTop, {
propsData: { props: {
visibilityHeight: -1, visibilityHeight: -1,
}, },
}); });
@ -25,7 +25,7 @@ describe('BackTop', () => {
it('support onClick', async () => { it('support onClick', async () => {
const onClick = jest.fn(); const onClick = jest.fn();
const wrapper = mount(BackTop, { const wrapper = mount(BackTop, {
propsData: { props: {
visibilityHeight: -1, visibilityHeight: -1,
}, },
listeners: { listeners: {

View File

@ -63,7 +63,7 @@ describe('Badge', () => {
it('should render when count is changed', async () => { it('should render when count is changed', async () => {
const wrapper = mount(Badge, { const wrapper = mount(Badge, {
propsData: { props: {
count: 9, count: 9,
}, },
sync: false, sync: false,

View File

@ -90,7 +90,7 @@ describe('Breadcrumb', () => {
breadcrumbName: 'second', breadcrumbName: 'second',
}, },
]; ];
const wrapper = mount(Breadcrumb, { propsData: { routes } }); const wrapper = mount(Breadcrumb, { props: { routes } });
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
}); });

View File

@ -155,7 +155,7 @@ describe('Calendar', () => {
return <Calendar validRange={validRange} />; return <Calendar validRange={validRange} />;
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(() => { await asyncExpect(() => {
wrapper.find('.ant-fullcalendar-year-select').trigger('click'); wrapper.find('.ant-fullcalendar-year-select').trigger('click');
@ -168,7 +168,7 @@ describe('Calendar', () => {
it('getDateRange should returns a disabledDate function', async () => { it('getDateRange should returns a disabledDate function', async () => {
const validRange = [Moment('2018-02-02'), Moment('2018-05-18')]; const validRange = [Moment('2018-02-02'), Moment('2018-05-18')];
const wrapper = mount(Calendar, { const wrapper = mount(Calendar, {
propsData: { props: {
validRange, validRange,
defaultValue: Moment('2018-02-02'), defaultValue: Moment('2018-02-02'),
}, },
@ -200,7 +200,7 @@ describe('Calendar', () => {
const yearMode = 'year'; const yearMode = 'year';
const onPanelChangeStub = jest.fn(); const onPanelChangeStub = jest.fn();
const wrapper = mount(Calendar, { const wrapper = mount(Calendar, {
propsData: { props: {
mode: yearMode, mode: yearMode,
}, },
listeners: { listeners: {
@ -223,7 +223,7 @@ describe('Calendar', () => {
// eslint-disable-next-line // eslint-disable-next-line
const zhCN = require('../locale/zh_CN').default; const zhCN = require('../locale/zh_CN').default;
const wrapper = mount(Calendar, { const wrapper = mount(Calendar, {
propsData: { props: {
locale: zhCN, locale: zhCN,
}, },
sync: false, sync: false,
@ -238,7 +238,7 @@ describe('Calendar', () => {
const onPanelChange = jest.fn(); const onPanelChange = jest.fn();
const date = new Moment('1990-09-03'); const date = new Moment('1990-09-03');
const wrapper = mount(Calendar, { const wrapper = mount(Calendar, {
propsData: { props: {
value: date, value: date,
}, },
listeners: { listeners: {
@ -259,7 +259,7 @@ describe('Calendar', () => {
const onPanelChange = jest.fn(); const onPanelChange = jest.fn();
const date = new Moment(new Date(Date.UTC(2017, 7, 9, 8))); const date = new Moment(new Date(Date.UTC(2017, 7, 9, 8)));
const wrapper = mount(Calendar, { const wrapper = mount(Calendar, {
propsData: { props: {
value: date, value: date,
}, },
listeners: { listeners: {
@ -295,7 +295,7 @@ describe('Calendar', () => {
}, },
{ {
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}, },
); );
await sleep(50); await sleep(50);
@ -355,7 +355,7 @@ describe('Calendar', () => {
}, },
{ {
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}, },
); );
await sleep(50); await sleep(50);

View File

@ -59,7 +59,7 @@ describe('Carousel', () => {
it('should trigger autoPlay after window resize', async () => { it('should trigger autoPlay after window resize', async () => {
const props = { const props = {
propsData: { props: {
autoplay: true, autoplay: true,
}, },
slots: { slots: {
@ -77,7 +77,7 @@ describe('Carousel', () => {
it('cancel resize listener when unmount', async () => { it('cancel resize listener when unmount', async () => {
const props = { const props = {
propsData: { props: {
autoplay: true, autoplay: true,
}, },
slots: { slots: {
@ -89,7 +89,7 @@ describe('Carousel', () => {
const { onWindowResized } = wrapper.vm; const { onWindowResized } = wrapper.vm;
const spy = jest.spyOn(wrapper.vm.onWindowResized, 'cancel'); const spy = jest.spyOn(wrapper.vm.onWindowResized, 'cancel');
const spy2 = jest.spyOn(window, 'removeEventListener'); const spy2 = jest.spyOn(window, 'removeEventListener');
wrapper.destroy(); wrapper.unmount();
expect(spy).toHaveBeenCalled(); expect(spy).toHaveBeenCalled();
expect(spy2).toHaveBeenCalledWith('resize', onWindowResized); expect(spy2).toHaveBeenCalledWith('resize', onWindowResized);
}); });

View File

@ -50,7 +50,7 @@ describe('Cascader', () => {
focusTest(Cascader); focusTest(Cascader);
it('popup correctly when panel is hidden', async () => { it('popup correctly when panel is hidden', async () => {
const wrapper = mount(Cascader, { propsData: { options }, sync: false }); const wrapper = mount(Cascader, { props: { options }, sync: false });
const CascaderWrapper = mount( const CascaderWrapper = mount(
{ {
render() { render() {
@ -65,7 +65,7 @@ describe('Cascader', () => {
}); });
it('popup correctly when panel is open', async () => { it('popup correctly when panel is open', async () => {
const wrapper = mount(Cascader, { propsData: { options }, sync: false }); const wrapper = mount(Cascader, { props: { options }, sync: false });
await asyncExpect(() => { await asyncExpect(() => {
wrapper.find('input').trigger('click'); wrapper.find('input').trigger('click');
}); });
@ -86,7 +86,7 @@ describe('Cascader', () => {
}); });
it('support controlled mode', async () => { it('support controlled mode', async () => {
const wrapper = mount(Cascader, { propsData: { options }, sync: false }); const wrapper = mount(Cascader, { props: { options }, sync: false });
await asyncExpect(() => { await asyncExpect(() => {
wrapper.setProps({ wrapper.setProps({
value: ['zhejiang', 'hangzhou', 'xihu'], value: ['zhejiang', 'hangzhou', 'xihu'],
@ -99,7 +99,7 @@ describe('Cascader', () => {
it('popup correctly with defaultValue', async () => { it('popup correctly with defaultValue', async () => {
const wrapper = mount(Cascader, { const wrapper = mount(Cascader, {
propsData: { props: {
options, options,
defaultValue: ['zhejiang', 'hangzhou'], defaultValue: ['zhejiang', 'hangzhou'],
}, },
@ -127,7 +127,7 @@ describe('Cascader', () => {
}); });
it('can be selected', async () => { it('can be selected', async () => {
const wrapper = mount(Cascader, { propsData: { options }, sync: false }); const wrapper = mount(Cascader, { props: { options }, sync: false });
await asyncExpect(() => { await asyncExpect(() => {
wrapper.find('input').trigger('click'); wrapper.find('input').trigger('click');
}); });
@ -229,7 +229,7 @@ describe('Cascader', () => {
}); });
it('backspace should work with `Cascader[showSearch]`', async () => { it('backspace should work with `Cascader[showSearch]`', async () => {
const wrapper = mount(Cascader, { propsData: { options, showSearch: true }, sync: false }); const wrapper = mount(Cascader, { props: { options, showSearch: true }, sync: false });
await asyncExpect(() => { await asyncExpect(() => {
wrapper.find('input').element.value = '123'; wrapper.find('input').element.value = '123';
wrapper.find('input').trigger('input'); wrapper.find('input').trigger('input');
@ -258,9 +258,9 @@ describe('Cascader', () => {
it('limit with positive number', async () => { it('limit with positive number', async () => {
const wrapper = mount(Cascader, { const wrapper = mount(Cascader, {
propsData: { options, showSearch: { filter, limit: 1 } }, props: { options, showSearch: { filter, limit: 1 } },
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}); });
wrapper.find('input').trigger('click'); wrapper.find('input').trigger('click');
wrapper.find('input').element.value = 'a'; wrapper.find('input').element.value = 'a';
@ -272,9 +272,9 @@ describe('Cascader', () => {
it('not limit', async () => { it('not limit', async () => {
const wrapper = mount(Cascader, { const wrapper = mount(Cascader, {
propsData: { options, showSearch: { filter, limit: false } }, props: { options, showSearch: { filter, limit: false } },
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}); });
wrapper.find('input').trigger('click'); wrapper.find('input').trigger('click');
wrapper.find('input').element.value = 'a'; wrapper.find('input').element.value = 'a';
@ -287,9 +287,9 @@ describe('Cascader', () => {
it('negative limit', async () => { it('negative limit', async () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const wrapper = mount(Cascader, { const wrapper = mount(Cascader, {
propsData: { options, showSearch: { filter, limit: -1 } }, props: { options, showSearch: { filter, limit: -1 } },
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}); });
wrapper.find('input').trigger('click'); wrapper.find('input').trigger('click');
wrapper.find('input').element.value = 'a'; wrapper.find('input').element.value = 'a';

View File

@ -29,7 +29,7 @@ describe('Checkbox', () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
mount(Checkbox, { mount(Checkbox, {
propsData: { props: {
value: 'xxx', value: 'xxx',
}, },
}); });

View File

@ -120,7 +120,7 @@ describe('CheckboxGroup', () => {
]; ];
const wrapper = mount(Checkbox.Group, { const wrapper = mount(Checkbox.Group, {
propsData: { options }, props: { options },
sync: false, sync: false,
}); });

View File

@ -9,11 +9,11 @@ describe('ColorPicker', () => {
return <ColorPicker default-value="#cd0200" getPopupContainer={p => p}></ColorPicker>; return <ColorPicker default-value="#cd0200" getPopupContainer={p => p}></ColorPicker>;
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
wrapper.destroy(); wrapper.unmount();
}, 1000); }, 1000);
}); });
it('should support v-model', async () => { it('should support v-model', async () => {
@ -32,12 +32,12 @@ describe('ColorPicker', () => {
this.color = 'rgba(110, 120, 130, 1)'; this.color = 'rgba(110, 120, 130, 1)';
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
wrapper.destroy(); wrapper.unmount();
}, 1000); }, 1000);
}); });
it('should support disabled', async () => { it('should support disabled', async () => {
@ -55,13 +55,13 @@ describe('ColorPicker', () => {
this.disabled = true; this.disabled = true;
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(async () => { await asyncExpect(async () => {
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
await asyncExpect(() => { await asyncExpect(() => {
wrapper.destroy(); wrapper.unmount();
}); });
}, 1000); }, 1000);
}); });
@ -80,13 +80,13 @@ describe('ColorPicker', () => {
this.format = 'HEX'; this.format = 'HEX';
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(async () => { await asyncExpect(async () => {
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
await asyncExpect(() => { await asyncExpect(() => {
wrapper.destroy(); wrapper.unmount();
}); });
}, 1000); }, 1000);
}); });
@ -119,12 +119,12 @@ describe('ColorPicker', () => {
}; };
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(async () => { await asyncExpect(async () => {
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
await asyncExpect(() => { await asyncExpect(() => {
wrapper.destroy(); wrapper.unmount();
}); });
}, 1000); }, 1000);
}); });
@ -142,13 +142,13 @@ describe('ColorPicker', () => {
}, },
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(async () => { await asyncExpect(async () => {
wrapper.find('.pcr-save').trigger('click'); wrapper.find('.pcr-save').trigger('click');
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
await asyncExpect(() => { await asyncExpect(() => {
wrapper.destroy(); wrapper.unmount();
}); });
}, 1000); }, 1000);
}); });

View File

@ -109,7 +109,7 @@ describe('DatePicker', () => {
}, },
}; };
const wrapper = mount(Test, { sync: false, attachToDocument: true }); const wrapper = mount(Test, { sync: false, attachTo: 'body' });
await asyncExpect(() => { await asyncExpect(() => {
// clear input // clear input
clearInput(wrapper); clearInput(wrapper);
@ -143,7 +143,7 @@ describe('DatePicker', () => {
return <DatePicker onChange={handleChange} />; return <DatePicker onChange={handleChange} />;
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(() => { await asyncExpect(() => {
openPanel(wrapper); openPanel(wrapper);
@ -169,7 +169,7 @@ describe('DatePicker', () => {
}); });
it('clear input', async () => { it('clear input', async () => {
const wrapper = mount(DatePicker, { sync: false, attachToDocument: true }); const wrapper = mount(DatePicker, { sync: false, attachTo: 'body' });
await asyncExpect(() => { await asyncExpect(() => {
openPanel(wrapper); openPanel(wrapper);
}, 0); }, 0);

View File

@ -11,9 +11,9 @@ describe('MonthPicker', () => {
focusTest(MonthPicker); focusTest(MonthPicker);
it('reset select item when popup close', async () => { it('reset select item when popup close', async () => {
const wrapper = mount(MonthPicker, { const wrapper = mount(MonthPicker, {
propsData: { value: moment('2018-07-01') }, props: { value: moment('2018-07-01') },
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}); });
await asyncExpect(() => { await asyncExpect(() => {
openPanel(wrapper); openPanel(wrapper);

View File

@ -23,7 +23,7 @@ describe('RangePicker', () => {
it('show month panel according to value', async () => { it('show month panel according to value', async () => {
const birthday = moment('2000-01-01', 'YYYY-MM-DD').locale('zh-cn'); const birthday = moment('2000-01-01', 'YYYY-MM-DD').locale('zh-cn');
const wrapper = mount(RangePicker, { const wrapper = mount(RangePicker, {
propsData: { props: {
getCalendarContainer: trigger => trigger, getCalendarContainer: trigger => trigger,
format: 'YYYY/MM/DD', format: 'YYYY/MM/DD',
showTime: true, showTime: true,
@ -166,7 +166,7 @@ describe('RangePicker', () => {
it('should not throw error when value is reset to `[]`', async () => { it('should not throw error when value is reset to `[]`', async () => {
const birthday = moment('2000-01-01', 'YYYY-MM-DD'); const birthday = moment('2000-01-01', 'YYYY-MM-DD');
const wrapper = mount(RangePicker, { const wrapper = mount(RangePicker, {
propsData: { props: {
getCalendarContainer: trigger => trigger, getCalendarContainer: trigger => trigger,
value: [birthday, birthday], value: [birthday, birthday],
open: true, open: true,
@ -196,7 +196,7 @@ describe('RangePicker', () => {
// issue: https://github.com/ant-design/ant-design/issues/7077 // issue: https://github.com/ant-design/ant-design/issues/7077
it('should not throw error when select after clear', async () => { it('should not throw error when select after clear', async () => {
const wrapper = mount(RangePicker, { const wrapper = mount(RangePicker, {
propsData: { props: {
getCalendarContainer: trigger => trigger, getCalendarContainer: trigger => trigger,
open: true, open: true,
}, },
@ -247,7 +247,7 @@ describe('RangePicker', () => {
); );
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(() => { await asyncExpect(() => {
wrapper.find('.ant-calendar-picker-input').trigger('click'); wrapper.find('.ant-calendar-picker-input').trigger('click');
@ -277,12 +277,12 @@ describe('RangePicker', () => {
const range = [moment().subtract(2, 'd'), moment()]; const range = [moment().subtract(2, 'd'), moment()];
const format = 'YYYY-MM-DD HH:mm:ss'; const format = 'YYYY-MM-DD HH:mm:ss';
const wrapper = mount(RangePicker, { const wrapper = mount(RangePicker, {
propsData: { props: {
ranges: { 'recent two days': range }, ranges: { 'recent two days': range },
format, format,
}, },
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}); });
await asyncExpect(() => { await asyncExpect(() => {
wrapper.find('.ant-calendar-picker-input').trigger('click'); wrapper.find('.ant-calendar-picker-input').trigger('click');
@ -306,12 +306,12 @@ describe('RangePicker', () => {
const range = [moment().subtract(2, 'd'), moment()]; const range = [moment().subtract(2, 'd'), moment()];
const format = 'YYYY-MM-DD HH:mm:ss'; const format = 'YYYY-MM-DD HH:mm:ss';
const wrapper = mount(RangePicker, { const wrapper = mount(RangePicker, {
propsData: { props: {
ranges: { 'recent two days': () => range }, ranges: { 'recent two days': () => range },
format, format,
}, },
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}); });
await asyncExpect(() => { await asyncExpect(() => {
wrapper.find('.ant-calendar-picker-input').trigger('click'); wrapper.find('.ant-calendar-picker-input').trigger('click');
@ -333,7 +333,7 @@ describe('RangePicker', () => {
// https://github.com/ant-design/ant-design/issues/6999 // https://github.com/ant-design/ant-design/issues/6999
it('input date manually', async () => { it('input date manually', async () => {
mount(RangePicker, { propsData: { open: true }, sync: false, attachToDocument: true }); mount(RangePicker, { props: { open: true }, sync: false, attachTo: 'body' });
const dateString = '2008-12-31'; const dateString = '2008-12-31';
let input = null; let input = null;
await asyncExpect(() => { await asyncExpect(() => {
@ -347,12 +347,12 @@ describe('RangePicker', () => {
const handleOk = jest.fn(); const handleOk = jest.fn();
const range = [moment().subtract(2, 'd'), moment()]; const range = [moment().subtract(2, 'd'), moment()];
const wrapper = mount(RangePicker, { const wrapper = mount(RangePicker, {
propsData: { props: {
ranges: { 'recent two days': range }, ranges: { 'recent two days': range },
}, },
listeners: { ok: handleOk }, listeners: { ok: handleOk },
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}); });
await asyncExpect(() => { await asyncExpect(() => {
@ -368,7 +368,7 @@ describe('RangePicker', () => {
// https://github.com/ant-design/ant-design/issues/9267 // https://github.com/ant-design/ant-design/issues/9267
it('invali end date not throw error', async () => { it('invali end date not throw error', async () => {
const wrapper = mount(RangePicker, { sync: false, attachToDocument: true }); const wrapper = mount(RangePicker, { sync: false, attachTo: 'body' });
await asyncExpect(() => { await asyncExpect(() => {
wrapper.find('.ant-calendar-picker-input').trigger('click'); wrapper.find('.ant-calendar-picker-input').trigger('click');
}); });
@ -401,7 +401,7 @@ describe('RangePicker', () => {
}, },
{ {
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}, },
); );
await asyncExpect(() => { await asyncExpect(() => {

View File

@ -49,7 +49,7 @@ describe('Picker format by locale', () => {
describe('MonthPicker and WeekPicker', () => { describe('MonthPicker and WeekPicker', () => {
it('render MonthPicker', async () => { it('render MonthPicker', async () => {
const birthday = moment('2000-01-01', 'YYYY-MM-DD').locale('zh-cn'); const birthday = moment('2000-01-01', 'YYYY-MM-DD').locale('zh-cn');
const wrapper = mount(MonthPicker, { propsData: { open: true }, sync: false }); const wrapper = mount(MonthPicker, { props: { open: true }, sync: false });
await asyncExpect(() => { await asyncExpect(() => {
wrapper.setProps({ value: birthday }); wrapper.setProps({ value: birthday });
}); });
@ -69,7 +69,7 @@ describe('MonthPicker and WeekPicker', () => {
it('render WeekPicker', async () => { it('render WeekPicker', async () => {
const birthday = moment('2000-01-01', 'YYYY-MM-DD').locale('zh-cn'); const birthday = moment('2000-01-01', 'YYYY-MM-DD').locale('zh-cn');
const wrapper = mount(WeekPicker, { propsData: { open: true }, sync: false }); const wrapper = mount(WeekPicker, { props: { open: true }, sync: false });
await asyncExpect(() => { await asyncExpect(() => {
wrapper.setProps({ value: birthday }); wrapper.setProps({ value: birthday });
}); });

View File

@ -48,12 +48,12 @@ describe('Descriptions', () => {
); );
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect(wrapper.vm.$refs.descriptions.getColumn()).toBe(8); expect(wrapper.vm.$refs.descriptions.getColumn()).toBe(8);
}, 100); }, 100);
wrapper.destroy(); wrapper.unmount();
}); });
it('column is number', () => { it('column is number', () => {
@ -71,7 +71,7 @@ describe('Descriptions', () => {
}, },
}); });
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
wrapper.destroy(); wrapper.unmount();
}); });
it('warning if ecceed the row span', () => { it('warning if ecceed the row span', () => {
@ -112,7 +112,7 @@ describe('Descriptions', () => {
}, },
}); });
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
wrapper.destroy(); wrapper.unmount();
}); });
it('vertical layout', () => { it('vertical layout', () => {
@ -130,7 +130,7 @@ describe('Descriptions', () => {
}, },
}); });
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
wrapper.destroy(); wrapper.unmount();
}); });
it('Descriptions.Item support className', () => { it('Descriptions.Item support className', () => {
@ -191,7 +191,7 @@ describe('Descriptions', () => {
); );
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect(wrapper.findAll('tr')).toHaveLength(5); expect(wrapper.findAll('tr')).toHaveLength(5);
@ -199,7 +199,7 @@ describe('Descriptions', () => {
}); });
enquire.callunmatch(); enquire.callunmatch();
wrapper.destroy(); wrapper.unmount();
}); });
it('when max-width: 575pxcolumn=2', async () => { it('when max-width: 575pxcolumn=2', async () => {
@ -218,13 +218,13 @@ describe('Descriptions', () => {
); );
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(() => {}); await asyncExpect(() => {});
expect(wrapper.findAll('tr')).toHaveLength(2); expect(wrapper.findAll('tr')).toHaveLength(2);
enquire.callunmatch(); enquire.callunmatch();
wrapper.destroy(); wrapper.unmount();
await asyncExpect(() => {}); await asyncExpect(() => {});
await asyncExpect(() => {}); await asyncExpect(() => {});

View File

@ -37,7 +37,7 @@ const DrawerCom = {
describe('Drawer', () => { describe('Drawer', () => {
it('render correctly', async () => { it('render correctly', async () => {
const props = { const props = {
propsData: { props: {
visible: true, visible: true,
width: 400, width: 400,
getContainer: false, getContainer: false,
@ -55,7 +55,7 @@ describe('Drawer', () => {
it('render top drawer', async () => { it('render top drawer', async () => {
const props = { const props = {
propsData: { props: {
visible: true, visible: true,
height: 400, height: 400,
placement: 'top', placement: 'top',
@ -74,7 +74,7 @@ describe('Drawer', () => {
it('have a title', async () => { it('have a title', async () => {
const props = { const props = {
propsData: { props: {
visible: true, visible: true,
title: 'Test Title', title: 'Test Title',
getContainer: false, getContainer: false,
@ -92,7 +92,7 @@ describe('Drawer', () => {
it('closable is false', async () => { it('closable is false', async () => {
const props = { const props = {
propsData: { props: {
visible: true, visible: true,
closable: false, closable: false,
getContainer: false, getContainer: false,
@ -110,7 +110,7 @@ describe('Drawer', () => {
it('destroyOnClose is true', async () => { it('destroyOnClose is true', async () => {
const props = { const props = {
propsData: { props: {
destroyOnClose: true, destroyOnClose: true,
closable: false, closable: false,
getContainer: false, getContainer: false,
@ -128,7 +128,7 @@ describe('Drawer', () => {
it('class is test_drawer', async () => { it('class is test_drawer', async () => {
const props = { const props = {
propsData: { props: {
wrapClassName: 'test_drawer', wrapClassName: 'test_drawer',
}, },
sync: false, sync: false,

View File

@ -97,7 +97,7 @@ describe('Drawer', () => {
it('maskClosable no trigger onClose', async () => { it('maskClosable no trigger onClose', async () => {
const wrapper = mount(DrawerEventTester, { const wrapper = mount(DrawerEventTester, {
propsData: { props: {
maskClosable: false, maskClosable: false,
}, },
sync: false, sync: false,
@ -113,7 +113,7 @@ describe('Drawer', () => {
it('destroyOnClose is true onClose', async () => { it('destroyOnClose is true onClose', async () => {
const wrapper = mount(DrawerEventTester, { const wrapper = mount(DrawerEventTester, {
propsData: { props: {
destroyOnClose: true, destroyOnClose: true,
}, },
sync: false, sync: false,
@ -134,7 +134,7 @@ describe('Drawer', () => {
it('no mask and no closable', async () => { it('no mask and no closable', async () => {
const wrapper = mount(DrawerEventTester, { const wrapper = mount(DrawerEventTester, {
propsData: { props: {
destroyOnClose: true, destroyOnClose: true,
}, },
sync: false, sync: false,

View File

@ -114,7 +114,7 @@ const MultiDrawer = {
describe('Drawer', () => { describe('Drawer', () => {
it('render right MultiDrawer', async () => { it('render right MultiDrawer', async () => {
const wrapper = mount(MultiDrawer, { const wrapper = mount(MultiDrawer, {
propsData: { props: {
placement: 'right', placement: 'right',
}, },
sync: false, sync: false,
@ -135,7 +135,7 @@ describe('Drawer', () => {
it('render left MultiDrawer', async () => { it('render left MultiDrawer', async () => {
document.body.innerHTML = ''; document.body.innerHTML = '';
const wrapper = mount(MultiDrawer, { const wrapper = mount(MultiDrawer, {
propsData: { props: {
placement: 'left', placement: 'left',
}, },
sync: false, sync: false,
@ -155,7 +155,7 @@ describe('Drawer', () => {
it('render top MultiDrawer', async () => { it('render top MultiDrawer', async () => {
const wrapper = mount(MultiDrawer, { const wrapper = mount(MultiDrawer, {
propsData: { props: {
placement: 'top', placement: 'top',
}, },
sync: false, sync: false,

View File

@ -14,7 +14,7 @@ describe('DropdownButton', () => {
}; };
const wrapper = mount(Dropdown.Button, { const wrapper = mount(Dropdown.Button, {
propsData: props, props,
listeners: { listeners: {
visibleChange: () => {}, visibleChange: () => {},
}, },

View File

@ -23,7 +23,7 @@ describe('Form', () => {
it('hideRequiredMark', () => { it('hideRequiredMark', () => {
const wrapper = mount(Form, { const wrapper = mount(Form, {
propsData: { props: {
hideRequiredMark: true, hideRequiredMark: true,
}, },
}); });
@ -45,7 +45,7 @@ describe('Form', () => {
const Wrapped = Form.create()(TestForm); const Wrapped = Form.create()(TestForm);
let form; let form;
mount(Wrapped, { mount(Wrapped, {
propsData: { props: {
wrappedComponentRef: node => { wrappedComponentRef: node => {
form = node; form = node;
}, },

View File

@ -205,7 +205,7 @@ describe('Form', () => {
}, },
}); });
const wrapper = mount(Form1, { sync: false, attachToDocument: true }); const wrapper = mount(Form1, { sync: false, attachTo: 'body' });
await asyncExpect(() => { await asyncExpect(() => {
expect(() => { expect(() => {
wrapper wrapper

View File

@ -24,7 +24,7 @@ describe('Input', () => {
it('should not support allowClear when it is disabled', () => { it('should not support allowClear when it is disabled', () => {
const wrapper = mount(Input, { const wrapper = mount(Input, {
propsData: { allowClear: true, defaultValue: '111', disabled: true }, props: { allowClear: true, defaultValue: '111', disabled: true },
sync: false, sync: false,
}); });
expect(wrapper.findAll('.ant-input-clear-icon').length).toBe(0); expect(wrapper.findAll('.ant-input-clear-icon').length).toBe(0);
@ -36,7 +36,7 @@ focusTest(TextArea);
describe('TextArea', () => { describe('TextArea', () => {
it('should auto calculate height according to content length', async () => { it('should auto calculate height according to content length', async () => {
const wrapper = mount(TextArea, { const wrapper = mount(TextArea, {
propsData: { value: '', readonly: true, autoSize: true }, props: { value: '', readonly: true, autoSize: true },
sync: false, sync: false,
}); });
@ -57,7 +57,7 @@ describe('TextArea', () => {
}); });
it('should support disabled', async () => { it('should support disabled', async () => {
const wrapper = mount(TextArea, { propsData: { disabled: true }, sync: false }); const wrapper = mount(TextArea, { props: { disabled: true }, sync: false });
await asyncExpect(() => { await asyncExpect(() => {
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
}); });
@ -115,7 +115,7 @@ describe('As Form Control', () => {
describe('Input.Search', () => { describe('Input.Search', () => {
it('should support suffix', async () => { it('should support suffix', async () => {
const wrapper = mount(Input.Search, { propsData: { suffix: 'suffix' }, sync: false }); const wrapper = mount(Input.Search, { props: { suffix: 'suffix' }, sync: false });
await asyncExpect(() => { await asyncExpect(() => {
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
}); });

View File

@ -189,7 +189,7 @@ describe('Locale Provider', () => {
); );
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
Vue.nextTick(() => { Vue.nextTick(() => {
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
@ -221,7 +221,7 @@ describe('Locale Provider', () => {
); );
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await sleep(); await sleep();
const currentConfirmNode = document.querySelectorAll('.ant-modal-confirm')[ const currentConfirmNode = document.querySelectorAll('.ant-modal-confirm')[
@ -258,7 +258,7 @@ describe('Locale Provider', () => {
); );
}, },
}; };
const wrapper = mount(Test, { sync: false, attachToDocument: true }); const wrapper = mount(Test, { sync: false, attachTo: 'body' });
await sleep(50); await sleep(50);
expect(document.body.innerHTML).toMatchSnapshot(); expect(document.body.innerHTML).toMatchSnapshot();
wrapper.setData({ locale: frFR }); wrapper.setData({ locale: frFR });

View File

@ -54,7 +54,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect($$('.ant-menu-submenu-selected').length).toBe(1); expect($$('.ant-menu-submenu-selected').length).toBe(1);
@ -75,7 +75,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect($$('.ant-menu-sub')[0].parentElement.style.display).not.toBe('none'); expect($$('.ant-menu-sub')[0].parentElement.style.display).not.toBe('none');
@ -97,7 +97,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect($$('.ant-menu-sub')[0].parentElement.style.display).not.toBe('none'); expect($$('.ant-menu-sub')[0].parentElement.style.display).not.toBe('none');
@ -119,7 +119,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect($$('.ant-menu-sub')[0].parentElement.style.display).not.toBe('none'); expect($$('.ant-menu-sub')[0].parentElement.style.display).not.toBe('none');
@ -149,7 +149,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect($$('.ant-menu-sub')[0].parentElement.style.display).not.toBe('none'); expect($$('.ant-menu-sub')[0].parentElement.style.display).not.toBe('none');
@ -188,7 +188,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect($$('.ant-menu-sub')[0].style.display).not.toBe('none'); expect($$('.ant-menu-sub')[0].style.display).not.toBe('none');
@ -226,7 +226,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect($$('.ant-menu-sub')[0].parentElement.style.display).not.toBe('none'); expect($$('.ant-menu-sub')[0].parentElement.style.display).not.toBe('none');
@ -258,7 +258,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
wrapper.vm.$forceUpdate(); wrapper.vm.$forceUpdate();
// just expect no error emit // just expect no error emit
@ -285,7 +285,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect($$('ul.ant-menu-sub')[0].style.display).not.toBe('none'); expect($$('ul.ant-menu-sub')[0].style.display).not.toBe('none');
@ -329,7 +329,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect( expect(
@ -399,7 +399,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect(wrapper.findAll('.ant-menu-sub').length).toBe(0); expect(wrapper.findAll('.ant-menu-sub').length).toBe(0);
@ -464,7 +464,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect($$('.ant-menu-sub').length).toBe(0); expect($$('.ant-menu-sub').length).toBe(0);
@ -495,7 +495,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect($$('.ant-menu-sub').length).toBe(0); expect($$('.ant-menu-sub').length).toBe(0);
@ -526,7 +526,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ attachToDocument: true, sync: false }, { attachTo: 'body', sync: false },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect($$('.ant-menu-sub').length).toBe(0); expect($$('.ant-menu-sub').length).toBe(0);
@ -564,7 +564,7 @@ describe('Menu', () => {
); );
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
wrapper.find('.ant-menu-item').trigger('mouseenter'); wrapper.find('.ant-menu-item').trigger('mouseenter');

View File

@ -37,7 +37,7 @@ describe('Modal', () => {
}, },
{ {
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}, },
); );
await asyncExpect(() => { await asyncExpect(() => {
@ -46,7 +46,7 @@ describe('Modal', () => {
// https://github.com/vuejs/vue-test-utils/issues/624 // https://github.com/vuejs/vue-test-utils/issues/624
const wrapper1 = mount(ModalTester, { const wrapper1 = mount(ModalTester, {
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}); });
wrapper1.setProps({ visible: true }); wrapper1.setProps({ visible: true });
await asyncExpect(() => { await asyncExpect(() => {
@ -61,7 +61,7 @@ describe('Modal', () => {
return <ModalTester visible footer={null} />; return <ModalTester visible footer={null} />;
}, },
}, },
{ attachToDocument: true, sync: true }, { attachTo: 'body', sync: true },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();

View File

@ -29,7 +29,7 @@ describe('Popconfirm', () => {
); );
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
let triggerNode = null; let triggerNode = null;
await asyncExpect(() => { await asyncExpect(() => {

View File

@ -223,7 +223,7 @@ describe('Radio', () => {
]; ];
const wrapper = mount(RadioGroup, { const wrapper = mount(RadioGroup, {
propsData: { props: {
prefixCls: 'my-radio', prefixCls: 'my-radio',
options, options,
}, },

View File

@ -24,7 +24,7 @@ describe('Result', () => {
}); });
it('🙂 different status, different class', () => { it('🙂 different status, different class', () => {
const wrapper = mount(Result, { propsData: { status: 'warning' } }); const wrapper = mount(Result, { props: { status: 'warning' } });
expect(wrapper.findAll('.ant-result-warning')).toHaveLength(1); expect(wrapper.findAll('.ant-result-warning')).toHaveLength(1);
wrapper.setProps({ wrapper.setProps({

View File

@ -11,7 +11,7 @@ describe('Select', () => {
it('should have default notFoundContent', async () => { it('should have default notFoundContent', async () => {
const wrapper = mount(Select, { const wrapper = mount(Select, {
propsData: { props: {
mode: 'multiple', mode: 'multiple',
}, },
sync: false, sync: false,
@ -41,7 +41,7 @@ describe('Select', () => {
it('should support set notFoundContent to null', async () => { it('should support set notFoundContent to null', async () => {
const wrapper = mount(Select, { const wrapper = mount(Select, {
propsData: { props: {
mode: 'multiple', mode: 'multiple',
notFoundContent: null, notFoundContent: null,
}, },
@ -65,7 +65,7 @@ describe('Select', () => {
it('should not have default notFoundContent when mode is combobox', async () => { it('should not have default notFoundContent when mode is combobox', async () => {
const wrapper = mount(Select, { const wrapper = mount(Select, {
propsData: { props: {
mode: Select.SECRET_COMBOBOX_MODE_DO_NOT_USE, mode: Select.SECRET_COMBOBOX_MODE_DO_NOT_USE,
}, },
sync: false, sync: false,
@ -89,7 +89,7 @@ describe('Select', () => {
it('should not have notFoundContent when mode is combobox and notFoundContent is set', async () => { it('should not have notFoundContent when mode is combobox and notFoundContent is set', async () => {
const wrapper = mount(Select, { const wrapper = mount(Select, {
propsData: { props: {
mode: Select.SECRET_COMBOBOX_MODE_DO_NOT_USE, mode: Select.SECRET_COMBOBOX_MODE_DO_NOT_USE,
notFoundContent: 'not at all', notFoundContent: 'not at all',
}, },

View File

@ -6,7 +6,7 @@ import mountTest from '../../../tests/shared/mountTest';
describe('Skeleton', () => { describe('Skeleton', () => {
const genSkeleton = props => { const genSkeleton = props => {
const skeletonProps = { const skeletonProps = {
propsData: { props: {
loading: true, loading: true,
...props, ...props,
}, },

View File

@ -7,7 +7,7 @@ describe('Slider', () => {
mountTest(Slider); mountTest(Slider);
it('should show tooltip when hovering slider handler', async () => { it('should show tooltip when hovering slider handler', async () => {
const wrapper = mount(Slider, { const wrapper = mount(Slider, {
propsData: { props: {
defaultValue: 30, defaultValue: 30,
}, },
sync: false, sync: false,

View File

@ -5,7 +5,7 @@ import Spin from '..';
describe('delay spinning', () => { describe('delay spinning', () => {
it("should render with delay when it's mounted with spinning=true and delay", async () => { it("should render with delay when it's mounted with spinning=true and delay", async () => {
const props = { const props = {
propsData: { props: {
delay: 500, delay: 500,
spinning: true, spinning: true,
}, },
@ -24,7 +24,7 @@ describe('delay spinning', () => {
it('should render when delay is init set', async () => { it('should render when delay is init set', async () => {
const props = { const props = {
propsData: { props: {
delay: 100, delay: 100,
spinning: true, spinning: true,
}, },
@ -55,7 +55,7 @@ describe('delay spinning', () => {
it('should cancel debounce function when unmount', async () => { it('should cancel debounce function when unmount', async () => {
const props = { const props = {
propsData: { props: {
delay: 100, delay: 100,
spinning: true, spinning: true,
}, },

View File

@ -34,7 +34,7 @@ describe('Spin', () => {
it('should be controlled by spinning', async () => { it('should be controlled by spinning', async () => {
const props = { const props = {
propsData: { props: {
spinning: false, spinning: false,
}, },
sync: false, sync: false,

View File

@ -20,7 +20,7 @@ describe('Statistic', () => {
it('customize formatter', () => { it('customize formatter', () => {
const formatter = jest.fn(() => 93); const formatter = jest.fn(() => 93);
const props = { const props = {
propsData: { props: {
value: 1128, value: 1128,
formatter, formatter,
}, },
@ -32,7 +32,7 @@ describe('Statistic', () => {
it('groupSeparator', () => { it('groupSeparator', () => {
const props = { const props = {
propsData: { props: {
value: 1128, value: 1128,
groupSeparator: '__TEST__', groupSeparator: '__TEST__',
}, },
@ -43,7 +43,7 @@ describe('Statistic', () => {
it('not a number', () => { it('not a number', () => {
const props = { const props = {
propsData: { props: {
value: 'bamboo', value: 'bamboo',
}, },
}; };
@ -53,7 +53,7 @@ describe('Statistic', () => {
it('support negetive number', () => { it('support negetive number', () => {
const props = { const props = {
propsData: { props: {
title: 'Account Balance (CNY)', title: 'Account Balance (CNY)',
value: -112893.12345, value: -112893.12345,
precision: 2, precision: 2,
@ -79,7 +79,7 @@ describe('Statistic', () => {
['DD-HH:mm:ss', '02-11:28:09'], ['DD-HH:mm:ss', '02-11:28:09'],
].forEach(([format, value]) => { ].forEach(([format, value]) => {
const props = { const props = {
propsData: { props: {
format, format,
value: now, value: now,
}, },
@ -92,7 +92,7 @@ describe('Statistic', () => {
it('time going', async () => { it('time going', async () => {
const now = Date.now() + 1000; const now = Date.now() + 1000;
const props = { const props = {
propsData: { props: {
value: now, value: now,
}, },
}; };

View File

@ -13,7 +13,7 @@ const getDefaultStore = selectedRowKeys => {
describe('SelectionBox', () => { describe('SelectionBox', () => {
it('unchecked by selectedRowKeys ', () => { it('unchecked by selectedRowKeys ', () => {
const wrapper = mount(SelectionBox, { const wrapper = mount(SelectionBox, {
propsData: { props: {
store: getDefaultStore(), store: getDefaultStore(),
rowIndex: '1', rowIndex: '1',
disabled: false, disabled: false,
@ -31,7 +31,7 @@ describe('SelectionBox', () => {
it('checked by selectedRowKeys ', () => { it('checked by selectedRowKeys ', () => {
const wrapper = mount(SelectionBox, { const wrapper = mount(SelectionBox, {
propsData: { props: {
store: getDefaultStore(['1']), store: getDefaultStore(['1']),
rowIndex: '1', rowIndex: '1',
disabled: false, disabled: false,
@ -49,7 +49,7 @@ describe('SelectionBox', () => {
it('checked by defaultSelection', () => { it('checked by defaultSelection', () => {
const wrapper = mount(SelectionBox, { const wrapper = mount(SelectionBox, {
propsData: { props: {
store: getDefaultStore(), store: getDefaultStore(),
rowIndex: '1', rowIndex: '1',
disabled: false, disabled: false,
@ -68,7 +68,7 @@ describe('SelectionBox', () => {
it('checked when store change', () => { it('checked when store change', () => {
const store = getDefaultStore(); const store = getDefaultStore();
const wrapper = mount(SelectionBox, { const wrapper = mount(SelectionBox, {
propsData: { props: {
store, store,
rowIndex: '1', rowIndex: '1',
disabled: false, disabled: false,
@ -94,7 +94,7 @@ describe('SelectionBox', () => {
id: 'testId', id: 'testId',
}; };
const wrapper = mount(SelectionBox, { const wrapper = mount(SelectionBox, {
propsData: { props: {
store: getDefaultStore(), store: getDefaultStore(),
rowIndex: '1', rowIndex: '1',
disabled: false, disabled: false,
@ -121,7 +121,7 @@ describe('SelectionBox', () => {
id: 'testId', id: 'testId',
}; };
const wrapper = mount(SelectionBox, { const wrapper = mount(SelectionBox, {
propsData: { props: {
store: getDefaultStore(), store: getDefaultStore(),
rowIndex: '1', rowIndex: '1',
disabled: false, disabled: false,

View File

@ -41,7 +41,7 @@ describe('Table.filter', () => {
function getTableOptions(props = {}, listeners = {}) { function getTableOptions(props = {}, listeners = {}) {
return { return {
propsData: { props: {
columns: [column], columns: [column],
dataSource: data, dataSource: data,
pagination: false, pagination: false,
@ -51,7 +51,7 @@ describe('Table.filter', () => {
...listeners, ...listeners,
}, },
sync: false, sync: false,
attachToDocument: true, attachTo: 'body',
}; };
} }
@ -374,7 +374,7 @@ describe('Table.filter', () => {
return wrapper.find({ name: 'Trigger' }).vm.getComponent(); return wrapper.find({ name: 'Trigger' }).vm.getComponent();
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(() => { await asyncExpect(() => {
dropdownWrapper.find({ name: 'MenuItem' }).trigger('click'); dropdownWrapper.find({ name: 'MenuItem' }).trigger('click');
@ -421,7 +421,7 @@ describe('Table.filter', () => {
{ key: 3, name: 'Jerry', age: 22 }, { key: 3, name: 'Jerry', age: 22 },
]; ];
const wrapper = mount(Table, { const wrapper = mount(Table, {
propsData: { props: {
columns, columns,
dataSource: testData, dataSource: testData,
}, },
@ -450,7 +450,7 @@ describe('Table.filter', () => {
}, },
{ change: handleChange }, { change: handleChange },
), ),
attachToDocument: true, attachTo: 'body',
}); });
await asyncExpect(() => { await asyncExpect(() => {
wrapper.find('.ant-dropdown-trigger').trigger('click'); wrapper.find('.ant-dropdown-trigger').trigger('click');

View File

@ -22,7 +22,7 @@ describe('Table.pagination', () => {
function getTableOptions(props = {}, listeners = {}) { function getTableOptions(props = {}, listeners = {}) {
return { return {
propsData: { props: {
columns, columns,
dataSource: data, dataSource: data,
pagination, pagination,

View File

@ -18,7 +18,7 @@ describe('Table.rowSelection', () => {
]; ];
function getTableOptions(props = {}, listeners = {}) { function getTableOptions(props = {}, listeners = {}) {
return { return {
propsData: { props: {
columns, columns,
dataSource: data, dataSource: data,
rowSelection: {}, rowSelection: {},
@ -489,7 +489,7 @@ describe('Table.rowSelection', () => {
// https://github.com/ant-design/ant-design/issues/10629 // https://github.com/ant-design/ant-design/issues/10629
it('should keep all checked state when remove item from dataSource', async () => { it('should keep all checked state when remove item from dataSource', async () => {
const wrapper = mount(Table, { const wrapper = mount(Table, {
propsData: { props: {
columns, columns,
dataSource: data, dataSource: data,
rowSelection: { rowSelection: {
@ -527,7 +527,7 @@ describe('Table.rowSelection', () => {
// https://github.com/ant-design/ant-design/issues/11042 // https://github.com/ant-design/ant-design/issues/11042
it('add columnTitle for rowSelection', async () => { it('add columnTitle for rowSelection', async () => {
const wrapper = mount(Table, { const wrapper = mount(Table, {
propsData: { props: {
columns, columns,
dataSource: data, dataSource: data,
rowSelection: { rowSelection: {
@ -589,7 +589,7 @@ describe('Table.rowSelection', () => {
}; };
const wrapper = mount(Table, { const wrapper = mount(Table, {
propsData: { props: {
columns: filterColumns, columns: filterColumns,
dataSource: data, dataSource: data,
rowSelection, rowSelection,
@ -691,7 +691,7 @@ describe('Table.rowSelection', () => {
]; ];
const wrapper = mount(Table, { const wrapper = mount(Table, {
propsData: { props: {
columns, columns,
dataSource: newDatas, dataSource: newDatas,
rowSelection: {}, rowSelection: {},

View File

@ -21,7 +21,7 @@ describe('Table.sorter', () => {
function getTableOptions(props = {}, columnProps = {}, listeners = {}) { function getTableOptions(props = {}, columnProps = {}, listeners = {}) {
return { return {
propsData: { props: {
columns: [ columns: [
{ {
...column, ...column,
@ -179,7 +179,7 @@ describe('Table.sorter', () => {
{ key: 3, name: 'Jerry', age: 22 }, { key: 3, name: 'Jerry', age: 22 },
]; ];
const wrapper = mount(Table, { const wrapper = mount(Table, {
propsData: { props: {
columns, columns,
dataSource: testData, dataSource: testData,
}, },

View File

@ -55,7 +55,7 @@ describe('Table', () => {
}, },
]; ];
const wrapper = shallow(Table, { const wrapper = shallow(Table, {
propsData: { props: {
columns, columns,
}, },
sync: false, sync: false,
@ -80,7 +80,7 @@ describe('Table', () => {
delay: 500, delay: 500,
}; };
const wrapper = mount(Table, { const wrapper = mount(Table, {
propsData: { props: {
loading, loading,
}, },
sync: false, sync: false,
@ -117,7 +117,7 @@ describe('Table', () => {
}, },
]; ];
const wrapper = mount(Table, { const wrapper = mount(Table, {
propsData: { props: {
columns, columns,
dataSource: data, dataSource: data,
}, },

View File

@ -14,7 +14,7 @@ describe('Tag', () => {
return <Tag closable onClose={onClose} />; return <Tag closable onClose={onClose} />;
}, },
}, },
{ sync: false, attachToDocument: true }, { sync: false, attachTo: 'body' },
); );
await asyncExpect(() => { await asyncExpect(() => {
expect(wrapper.findAll('.anticon-close').length).toBe(1); expect(wrapper.findAll('.anticon-close').length).toBe(1);
@ -50,7 +50,7 @@ describe('Tag', () => {
}); });
describe('visibility', () => { describe('visibility', () => {
it('can be controlled by visible with visible as initial value', async () => { it('can be controlled by visible with visible as initial value', async () => {
const wrapper = mount(Tag, { propsData: { visible: true }, sync: false }); const wrapper = mount(Tag, { props: { visible: true }, sync: false });
await asyncExpect(() => { await asyncExpect(() => {
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
wrapper.setProps({ visible: false }); wrapper.setProps({ visible: false });
@ -65,7 +65,7 @@ describe('Tag', () => {
}); });
it('can be controlled by visible with hidden as initial value', async () => { it('can be controlled by visible with hidden as initial value', async () => {
const wrapper = mount(Tag, { propsData: { visible: false }, sync: false }); const wrapper = mount(Tag, { props: { visible: false }, sync: false });
await asyncExpect(() => { await asyncExpect(() => {
expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.html()).toMatchSnapshot();
wrapper.setProps({ visible: true }); wrapper.setProps({ visible: true });

View File

@ -91,7 +91,7 @@ describe('Transfer', () => {
mountTest(Transfer); mountTest(Transfer);
it('should render correctly', () => { it('should render correctly', () => {
const props = { const props = {
propsData: listCommonProps, props: listCommonProps,
}; };
const wrapper = renderToString(Transfer, props); const wrapper = renderToString(Transfer, props);
expect(wrapper).toMatchSnapshot(); expect(wrapper).toMatchSnapshot();
@ -100,7 +100,7 @@ describe('Transfer', () => {
it('should move selected keys to corresponding list', done => { it('should move selected keys to corresponding list', done => {
const handleChange = jest.fn(); const handleChange = jest.fn();
const wrapper = mount(Transfer, { const wrapper = mount(Transfer, {
propsData: listCommonProps, props: listCommonProps,
listeners: { listeners: {
change: handleChange, change: handleChange,
}, },
@ -118,7 +118,7 @@ describe('Transfer', () => {
it('should move selected keys expect disabled to corresponding list', done => { it('should move selected keys expect disabled to corresponding list', done => {
const handleChange = jest.fn(); const handleChange = jest.fn();
const wrapper = mount(Transfer, { const wrapper = mount(Transfer, {
propsData: listDisabledProps, props: listDisabledProps,
listeners: { listeners: {
change: handleChange, change: handleChange,
}, },
@ -137,7 +137,7 @@ describe('Transfer', () => {
it('should uncheck checkbox when click on checked item', done => { it('should uncheck checkbox when click on checked item', done => {
const handleSelectChange = jest.fn(); const handleSelectChange = jest.fn();
const wrapper = mount(Transfer, { const wrapper = mount(Transfer, {
propsData: listCommonProps, props: listCommonProps,
listeners: { listeners: {
selectChange: handleSelectChange, selectChange: handleSelectChange,
}, },
@ -158,7 +158,7 @@ describe('Transfer', () => {
it('should check checkbox when click on unchecked item', done => { it('should check checkbox when click on unchecked item', done => {
const handleSelectChange = jest.fn(); const handleSelectChange = jest.fn();
const wrapper = mount(Transfer, { const wrapper = mount(Transfer, {
propsData: listCommonProps, props: listCommonProps,
listeners: { listeners: {
selectChange: handleSelectChange, selectChange: handleSelectChange,
}, },
@ -179,7 +179,7 @@ describe('Transfer', () => {
it('should not check checkbox when click on disabled item', done => { it('should not check checkbox when click on disabled item', done => {
const handleSelectChange = jest.fn(); const handleSelectChange = jest.fn();
const wrapper = mount(Transfer, { const wrapper = mount(Transfer, {
propsData: listCommonProps, props: listCommonProps,
listeners: { listeners: {
selectChange: handleSelectChange, selectChange: handleSelectChange,
}, },
@ -200,7 +200,7 @@ describe('Transfer', () => {
it('should check all item when click on check all', done => { it('should check all item when click on check all', done => {
const handleSelectChange = jest.fn(); const handleSelectChange = jest.fn();
const wrapper = mount(Transfer, { const wrapper = mount(Transfer, {
propsData: listCommonProps, props: listCommonProps,
listeners: { listeners: {
selectChange: handleSelectChange, selectChange: handleSelectChange,
}, },
@ -221,7 +221,7 @@ describe('Transfer', () => {
it('should uncheck all item when click on uncheck all', done => { it('should uncheck all item when click on uncheck all', done => {
const handleSelectChange = jest.fn(); const handleSelectChange = jest.fn();
const wrapper = mount(Transfer, { const wrapper = mount(Transfer, {
propsData: listCommonProps, props: listCommonProps,
listeners: { listeners: {
selectChange: handleSelectChange, selectChange: handleSelectChange,
}, },
@ -242,7 +242,7 @@ describe('Transfer', () => {
it('should call `filterOption` when use input in search box', done => { it('should call `filterOption` when use input in search box', done => {
const filterOption = (inputValue, option) => inputValue === option.title; const filterOption = (inputValue, option) => inputValue === option.title;
const wrapper = mount(Transfer, { const wrapper = mount(Transfer, {
propsData: { props: {
...listCommonProps, ...listCommonProps,
showSearch: true, showSearch: true,
filterOption, filterOption,
@ -270,7 +270,7 @@ describe('Transfer', () => {
const filterOption = (inputValue, option) => option.description.indexOf(inputValue) > -1; const filterOption = (inputValue, option) => option.description.indexOf(inputValue) > -1;
const renderFunc = item => item.title; const renderFunc = item => item.title;
const wrapper = mount(Transfer, { const wrapper = mount(Transfer, {
propsData: { props: {
...searchTransferProps, ...searchTransferProps,
showSearch: true, showSearch: true,
filterOption, filterOption,
@ -302,7 +302,7 @@ describe('Transfer', () => {
const renderFunc = item => item.title; const renderFunc = item => item.title;
const handleSelectChange = jest.fn(); const handleSelectChange = jest.fn();
const wrapper = mount(Transfer, { const wrapper = mount(Transfer, {
propsData: { props: {
...searchTransferProps, ...searchTransferProps,
showSearch: true, showSearch: true,
filterOption, filterOption,
@ -342,7 +342,7 @@ describe('Transfer', () => {
}); });
}; };
const wrapper = mount(Transfer, { const wrapper = mount(Transfer, {
propsData: { props: {
...searchTransferProps, ...searchTransferProps,
showSearch: true, showSearch: true,
filterOption, filterOption,
@ -385,7 +385,7 @@ describe('Transfer', () => {
delete newProps.selectedKeys; delete newProps.selectedKeys;
const handleSelectChange = jest.fn(); const handleSelectChange = jest.fn();
const wrapper = mount(Transfer, { const wrapper = mount(Transfer, {
propsData: { props: {
...newProps, ...newProps,
showSearch: true, showSearch: true,
render: item => item.title, render: item => item.title,
@ -448,7 +448,7 @@ describe('Transfer', () => {
}; };
const props = { const props = {
propsData: { props: {
...sortedTargetKeyProps, ...sortedTargetKeyProps,
render: item => item.title, render: item => item.title,
}, },

View File

@ -27,7 +27,7 @@ const listCommonProps = {
describe('List', () => { describe('List', () => {
it('should render correctly', () => { it('should render correctly', () => {
const props = { const props = {
propsData: listCommonProps, props: listCommonProps,
}; };
const wrapper = renderToString(List, props); const wrapper = renderToString(List, props);
expect(wrapper).toMatchSnapshot(); expect(wrapper).toMatchSnapshot();
@ -35,7 +35,7 @@ describe('List', () => {
it('should check top Checkbox while all available items are checked', () => { it('should check top Checkbox while all available items are checked', () => {
const props = { const props = {
propsData: { props: {
...listCommonProps, ...listCommonProps,
checkedKeys: ['a', 'b'], checkedKeys: ['a', 'b'],
}, },

View File

@ -16,7 +16,7 @@ describe('Search', () => {
it('should show cross icon when input value exists', () => { it('should show cross icon when input value exists', () => {
const props = { const props = {
propsData: { props: {
value: '', value: '',
}, },
}; };

View File

@ -31,7 +31,7 @@ describe('Upload', () => {
it('return promise in beforeUpload', done => { it('return promise in beforeUpload', done => {
const data = jest.fn(); const data = jest.fn();
const props = { const props = {
propsData: { props: {
action: 'http://upload.com', action: 'http://upload.com',
beforeUpload: () => new Promise(resolve => setTimeout(() => resolve('success'), 100)), beforeUpload: () => new Promise(resolve => setTimeout(() => resolve('success'), 100)),
data, data,
@ -62,7 +62,7 @@ describe('Upload', () => {
it('upload promise return file in beforeUpload', done => { it('upload promise return file in beforeUpload', done => {
const data = jest.fn(); const data = jest.fn();
const props = { const props = {
propsData: { props: {
action: 'http://upload.com', action: 'http://upload.com',
beforeUpload: file => beforeUpload: file =>
new Promise(resolve => new Promise(resolve =>
@ -103,7 +103,7 @@ describe('Upload', () => {
it('should not stop upload when return value of beforeUpload is false', done => { it('should not stop upload when return value of beforeUpload is false', done => {
const data = jest.fn(); const data = jest.fn();
const props = { const props = {
propsData: { props: {
action: 'http://upload.com', action: 'http://upload.com',
beforeUpload: () => false, beforeUpload: () => false,
data, data,
@ -137,7 +137,7 @@ describe('Upload', () => {
let uploadInstance; let uploadInstance;
let lastPercent = -1; let lastPercent = -1;
const props = { const props = {
propsData: { props: {
action: 'http://upload.com', action: 'http://upload.com',
}, },
listeners: { listeners: {
@ -176,7 +176,7 @@ describe('Upload', () => {
it('should not stop upload when return value of beforeUpload is not false', done => { it('should not stop upload when return value of beforeUpload is not false', done => {
const data = jest.fn(); const data = jest.fn();
const props = { const props = {
propsData: { props: {
action: 'http://upload.com', action: 'http://upload.com',
beforeUpload() {}, beforeUpload() {},
data, data,
@ -296,7 +296,7 @@ describe('Upload', () => {
}, },
]; ];
const props = { const props = {
propsData: { props: {
fileList, fileList,
}, },
sync: false, sync: false,
@ -324,7 +324,7 @@ describe('Upload', () => {
}, },
]; ];
const props = { const props = {
propsData: { props: {
fileList, fileList,
}, },
sync: false, sync: false,

View File

@ -38,7 +38,7 @@ describe('Upload List', () => {
}); });
it('should use file.thumbUrl for <img /> in priority', done => { it('should use file.thumbUrl for <img /> in priority', done => {
const props = { const props = {
propsData: { props: {
defaultFileList: fileList, defaultFileList: fileList,
listType: 'picture', listType: 'picture',
action: '', action: '',
@ -79,7 +79,7 @@ describe('Upload List', () => {
}, },
]; ];
const props = { const props = {
propsData: { props: {
defaultFileList: list, defaultFileList: list,
action: '', action: '',
}, },
@ -105,7 +105,7 @@ describe('Upload List', () => {
it('should be uploading when upload a file', done => { it('should be uploading when upload a file', done => {
const props = { const props = {
propsData: { props: {
action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76', action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
customRequest: successRequest, customRequest: successRequest,
}, },
@ -141,7 +141,7 @@ describe('Upload List', () => {
it('handle error', done => { it('handle error', done => {
const props = { const props = {
propsData: { props: {
action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76', action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
customRequest: errorRequest, customRequest: errorRequest,
}, },
@ -174,7 +174,7 @@ describe('Upload List', () => {
it('does concat filelist when beforeUpload returns false', done => { it('does concat filelist when beforeUpload returns false', done => {
const handleChange = jest.fn(); const handleChange = jest.fn();
const props = { const props = {
propsData: { props: {
action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76', action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
listType: 'picture', listType: 'picture',
defaultFileList: fileList, defaultFileList: fileList,
@ -279,7 +279,7 @@ describe('Upload List', () => {
it('should support onPreview', done => { it('should support onPreview', done => {
const handlePreview = jest.fn(); const handlePreview = jest.fn();
const props = { const props = {
propsData: { props: {
defaultFileList: fileList, defaultFileList: fileList,
listType: 'picture-card', listType: 'picture-card',
action: '', action: '',
@ -312,7 +312,7 @@ describe('Upload List', () => {
const handleRemove = jest.fn(); const handleRemove = jest.fn();
const handleChange = jest.fn(); const handleChange = jest.fn();
const props = { const props = {
propsData: { props: {
defaultFileList: fileList, defaultFileList: fileList,
listType: 'picture-card', listType: 'picture-card',
action: '', action: '',
@ -352,7 +352,7 @@ describe('Upload List', () => {
delete newFile.thumbUrl; delete newFile.thumbUrl;
newFileList.push(newFile); newFileList.push(newFile);
const props = { const props = {
propsData: { props: {
defaultFileList: newFileList, defaultFileList: newFileList,
listType: 'picture-card', listType: 'picture-card',
action: '', action: '',
@ -438,7 +438,7 @@ describe('Upload List', () => {
}, },
]; ];
const props = { const props = {
propsData: { props: {
defaultFileList: list, defaultFileList: list,
listType: 'picture', listType: 'picture',
action: '', action: '',

View File

@ -116,6 +116,7 @@
"husky": "^4.0.0", "husky": "^4.0.0",
"istanbul-instrumenter-loader": "^3.0.0", "istanbul-instrumenter-loader": "^3.0.0",
"jest": "^25.4.0", "jest": "^25.4.0",
"jest-environment-jsdom-fifteen": "^1.0.2",
"jest-serializer-vue": "^2.0.0", "jest-serializer-vue": "^2.0.0",
"jest-transform-stub": "^2.0.0", "jest-transform-stub": "^2.0.0",
"js-base64": "^3.0.0", "js-base64": "^3.0.0",

View File

@ -8,6 +8,15 @@ if (typeof window !== 'undefined') {
global.window.dispatchEvent(new Event('resize')); global.window.dispatchEvent(new Event('resize'));
}; };
global.window.scrollTo = () => {}; global.window.scrollTo = () => {};
if (!window.matchMedia) {
Object.defineProperty(global.window, 'matchMedia', {
value: jest.fn(query => ({
matches: query.includes('max-width'),
addListener: jest.fn(),
removeListener: jest.fn(),
})),
});
}
} }
// The built-in requestAnimationFrame and cancelAnimationFrame not working with jest.runFakeTimes() // The built-in requestAnimationFrame and cancelAnimationFrame not working with jest.runFakeTimes()

View File

@ -27,7 +27,7 @@ export default function demoTest(component, options = {}) {
const dom = options.getDomFromElement ? wrapper.element : wrapper.html(); const dom = options.getDomFromElement ? wrapper.element : wrapper.html();
expect(dom).toMatchSnapshot(); expect(dom).toMatchSnapshot();
MockDate.reset(); MockDate.reset();
wrapper.destroy(); wrapper.unmount();
document.body.innerHTML = ''; document.body.innerHTML = '';
done(); done();
}); });