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',
'!**/node_modules/**',
],
testEnvironment: 'jest-environment-jsdom-fifteen',
transformIgnorePatterns,
};

View File

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

View File

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

View File

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

View File

@ -38,11 +38,11 @@ describe('Avatar Render', () => {
slots: {
default: 'Fallback',
},
propsData: {
props: {
src: 'http://error.url',
},
sync: false,
attachToDocument: true,
attachTo: 'body',
});
wrapper.vm.setScale = jest.fn(() => {
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(() => {
// mock img load Error, since jsdom do not load resource by default
// 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(() => {
wrapper.find('img').trigger('error');
}, 0);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -49,7 +49,7 @@ describe('Picker format by locale', () => {
describe('MonthPicker and WeekPicker', () => {
it('render MonthPicker', async () => {
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(() => {
wrapper.setProps({ value: birthday });
});
@ -69,7 +69,7 @@ describe('MonthPicker and WeekPicker', () => {
it('render WeekPicker', async () => {
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(() => {
wrapper.setProps({ value: birthday });
});

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -189,7 +189,7 @@ describe('Locale Provider', () => {
);
},
},
{ sync: false, attachToDocument: true },
{ sync: false, attachTo: 'body' },
);
Vue.nextTick(() => {
expect(wrapper.html()).toMatchSnapshot();
@ -221,7 +221,7 @@ describe('Locale Provider', () => {
);
},
},
{ sync: false, attachToDocument: true },
{ sync: false, attachTo: 'body' },
);
await sleep();
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);
expect(document.body.innerHTML).toMatchSnapshot();
wrapper.setData({ locale: frFR });

View File

@ -54,7 +54,7 @@ describe('Menu', () => {
);
},
},
{ attachToDocument: true, sync: false },
{ attachTo: 'body', sync: false },
);
await asyncExpect(() => {
expect($$('.ant-menu-submenu-selected').length).toBe(1);
@ -75,7 +75,7 @@ describe('Menu', () => {
);
},
},
{ attachToDocument: true, sync: false },
{ attachTo: 'body', sync: false },
);
await asyncExpect(() => {
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(() => {
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(() => {
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(() => {
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(() => {
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(() => {
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();
// just expect no error emit
@ -285,7 +285,7 @@ describe('Menu', () => {
);
},
},
{ attachToDocument: true, sync: false },
{ attachTo: 'body', sync: false },
);
await asyncExpect(() => {
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(() => {
expect(
@ -399,7 +399,7 @@ describe('Menu', () => {
);
},
},
{ attachToDocument: true, sync: false },
{ attachTo: 'body', sync: false },
);
await asyncExpect(() => {
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(() => {
expect($$('.ant-menu-sub').length).toBe(0);
@ -495,7 +495,7 @@ describe('Menu', () => {
);
},
},
{ attachToDocument: true, sync: false },
{ attachTo: 'body', sync: false },
);
await asyncExpect(() => {
expect($$('.ant-menu-sub').length).toBe(0);
@ -526,7 +526,7 @@ describe('Menu', () => {
);
},
},
{ attachToDocument: true, sync: false },
{ attachTo: 'body', sync: false },
);
await asyncExpect(() => {
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');

View File

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

View File

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

View File

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

View File

@ -24,7 +24,7 @@ describe('Result', () => {
});
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);
wrapper.setProps({

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,7 @@ describe('Tag', () => {
return <Tag closable onClose={onClose} />;
},
},
{ sync: false, attachToDocument: true },
{ sync: false, attachTo: 'body' },
);
await asyncExpect(() => {
expect(wrapper.findAll('.anticon-close').length).toBe(1);
@ -50,7 +50,7 @@ describe('Tag', () => {
});
describe('visibility', () => {
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(() => {
expect(wrapper.html()).toMatchSnapshot();
wrapper.setProps({ visible: false });
@ -65,7 +65,7 @@ describe('Tag', () => {
});
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(() => {
expect(wrapper.html()).toMatchSnapshot();
wrapper.setProps({ visible: true });

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -116,6 +116,7 @@
"husky": "^4.0.0",
"istanbul-instrumenter-loader": "^3.0.0",
"jest": "^25.4.0",
"jest-environment-jsdom-fifteen": "^1.0.2",
"jest-serializer-vue": "^2.0.0",
"jest-transform-stub": "^2.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.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()

View File

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