Skip to content

Commit ed2a8d6

Browse files
committed
test: update some not support props
1 parent 5624f92 commit ed2a8d6

File tree

54 files changed

+220
-207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+220
-207
lines changed

.jest.js

+1
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ module.exports = {
3939
'!components/style.js',
4040
'!**/node_modules/**',
4141
],
42+
testEnvironment: 'jest-environment-jsdom-fifteen',
4243
transformIgnorePatterns,
4344
};

components/affix/__tests__/index.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('Affix Render', () => {
7070
jest.runAllTimers();
7171
};
7272
it('Anchor render perfectly', () => {
73-
wrapper = mount(AffixMounter, { attachToDocument: true });
73+
wrapper = mount(AffixMounter, { attachTo: 'body' });
7474
jest.runAllTimers();
7575

7676
movePlaceholder(0);
@@ -84,8 +84,8 @@ describe('Affix Render', () => {
8484
});
8585
it('support offsetBottom', () => {
8686
wrapper = mount(AffixMounter, {
87-
attachToDocument: true,
88-
propsData: {
87+
attachTo: 'body',
88+
props: {
8989
offsetBottom: 0,
9090
},
9191
});
@@ -104,8 +104,8 @@ describe('Affix Render', () => {
104104

105105
// it('updatePosition when offsetTop changed', () => {
106106
// wrapper = mount(AffixMounter, {
107-
// attachToDocument: true,
108-
// propsData: {
107+
// attachTo: 'body',
108+
// props: {
109109
// offsetTop: 0,
110110
// },
111111
// });

components/anchor/Anchor.jsx

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ export const AnchorProps = {
8888
wrapperStyle: PropTypes.object,
8989
getCurrentAnchor: PropTypes.func,
9090
targetOffset: PropTypes.number,
91+
onChange: PropTypes.func,
92+
onClick: PropTypes.func,
9193
};
9294

9395
export default {

components/anchor/__tests__/Anchor.test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { mount } from '@vue/test-utils';
2-
import Vue from 'vue';
2+
import * as Vue from 'vue';
33
import { asyncExpect } from '@/tests/utils';
44
import Anchor from '..';
55

@@ -63,7 +63,7 @@ describe('Anchor Render', () => {
6363
);
6464
},
6565
},
66-
{ sync: false, attachToDocument: true },
66+
{ sync: false, attachTo: 'body' },
6767
);
6868
Vue.nextTick(() => {
6969
wrapper.vm.$refs.anchor.handleScroll();
@@ -87,7 +87,7 @@ describe('Anchor Render', () => {
8787
);
8888
},
8989
},
90-
{ sync: false, attachToDocument: true },
90+
{ sync: false, attachTo: 'body' },
9191
);
9292
await asyncExpect(() => {
9393
wrapper.vm.$refs.anchor.handleScrollTo('##API');
@@ -110,11 +110,11 @@ describe('Anchor Render', () => {
110110
);
111111
},
112112
},
113-
{ sync: false, attachToDocument: true },
113+
{ sync: false, attachTo: 'body' },
114114
);
115115
await asyncExpect(() => {
116116
const removeListenerSpy = jest.spyOn(wrapper.vm.$refs.anchor.scrollEvent, 'remove');
117-
wrapper.destroy();
117+
wrapper.unmount();
118118
expect(removeListenerSpy).toHaveBeenCalled();
119119
});
120120
});
@@ -134,7 +134,7 @@ describe('Anchor Render', () => {
134134
);
135135
},
136136
},
137-
{ sync: false, attachToDocument: true },
137+
{ sync: false, attachTo: 'body' },
138138
);
139139
await asyncExpect(() => {
140140
expect(wrapper.vm.$refs.anchor.links).toEqual(['#API']);
@@ -159,8 +159,8 @@ describe('Anchor Render', () => {
159159
},
160160
{
161161
sync: false,
162-
attachToDocument: true,
163-
propsData: {
162+
attachTo: 'body',
163+
props: {
164164
href: '#API',
165165
},
166166
},

components/auto-complete/__tests__/index.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('AutoComplete with Custom Input Element Render', () => {
1919
);
2020
},
2121
},
22-
{ attachToDocument: true, sync: false },
22+
{ attachTo: 'body', sync: false },
2323
);
2424
expect(wrapper.findAll('input').length).toBe(1);
2525
const input = wrapper.find('input');

components/avatar/__tests__/Avatar.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ describe('Avatar Render', () => {
3838
slots: {
3939
default: 'Fallback',
4040
},
41-
propsData: {
41+
props: {
4242
src: 'http://error.url',
4343
},
4444
sync: false,
45-
attachToDocument: true,
45+
attachTo: 'body',
4646
});
4747
wrapper.vm.setScale = jest.fn(() => {
4848
if (wrapper.vm.scale === 0.5) {
@@ -91,7 +91,7 @@ describe('Avatar Render', () => {
9191
},
9292
};
9393

94-
const wrapper = mount(Foo, { sync: false, attachToDocument: true });
94+
const wrapper = mount(Foo, { sync: false, attachTo: 'body' });
9595
await asyncExpect(() => {
9696
// mock img load Error, since jsdom do not load resource by default
9797
// https://github.com/jsdom/jsdom/issues/1816
@@ -122,7 +122,7 @@ describe('Avatar Render', () => {
122122
},
123123
};
124124

125-
const wrapper = mount(Foo, { sync: false, attachToDocument: true });
125+
const wrapper = mount(Foo, { sync: false, attachTo: 'body' });
126126
await asyncExpect(() => {
127127
wrapper.find('img').trigger('error');
128128
}, 0);

components/back-top/__tests__/index.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { sleep } from '../../../tests/utils';
55
describe('BackTop', () => {
66
it('should scroll to top after click it', async () => {
77
const wrapper = mount(BackTop, {
8-
propsData: {
8+
props: {
99
visibilityHeight: -1,
1010
},
1111
});
@@ -25,7 +25,7 @@ describe('BackTop', () => {
2525
it('support onClick', async () => {
2626
const onClick = jest.fn();
2727
const wrapper = mount(BackTop, {
28-
propsData: {
28+
props: {
2929
visibilityHeight: -1,
3030
},
3131
listeners: {

components/badge/__tests__/index.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('Badge', () => {
6363

6464
it('should render when count is changed', async () => {
6565
const wrapper = mount(Badge, {
66-
propsData: {
66+
props: {
6767
count: 9,
6868
},
6969
sync: false,

components/breadcrumb/__tests__/Breadcrumb.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('Breadcrumb', () => {
9090
breadcrumbName: 'second',
9191
},
9292
];
93-
const wrapper = mount(Breadcrumb, { propsData: { routes } });
93+
const wrapper = mount(Breadcrumb, { props: { routes } });
9494
expect(wrapper.html()).toMatchSnapshot();
9595
});
9696

components/calendar/__tests__/index.test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe('Calendar', () => {
155155
return <Calendar validRange={validRange} />;
156156
},
157157
},
158-
{ sync: false, attachToDocument: true },
158+
{ sync: false, attachTo: 'body' },
159159
);
160160
await asyncExpect(() => {
161161
wrapper.find('.ant-fullcalendar-year-select').trigger('click');
@@ -168,7 +168,7 @@ describe('Calendar', () => {
168168
it('getDateRange should returns a disabledDate function', async () => {
169169
const validRange = [Moment('2018-02-02'), Moment('2018-05-18')];
170170
const wrapper = mount(Calendar, {
171-
propsData: {
171+
props: {
172172
validRange,
173173
defaultValue: Moment('2018-02-02'),
174174
},
@@ -200,7 +200,7 @@ describe('Calendar', () => {
200200
const yearMode = 'year';
201201
const onPanelChangeStub = jest.fn();
202202
const wrapper = mount(Calendar, {
203-
propsData: {
203+
props: {
204204
mode: yearMode,
205205
},
206206
listeners: {
@@ -223,7 +223,7 @@ describe('Calendar', () => {
223223
// eslint-disable-next-line
224224
const zhCN = require('../locale/zh_CN').default;
225225
const wrapper = mount(Calendar, {
226-
propsData: {
226+
props: {
227227
locale: zhCN,
228228
},
229229
sync: false,
@@ -238,7 +238,7 @@ describe('Calendar', () => {
238238
const onPanelChange = jest.fn();
239239
const date = new Moment('1990-09-03');
240240
const wrapper = mount(Calendar, {
241-
propsData: {
241+
props: {
242242
value: date,
243243
},
244244
listeners: {
@@ -259,7 +259,7 @@ describe('Calendar', () => {
259259
const onPanelChange = jest.fn();
260260
const date = new Moment(new Date(Date.UTC(2017, 7, 9, 8)));
261261
const wrapper = mount(Calendar, {
262-
propsData: {
262+
props: {
263263
value: date,
264264
},
265265
listeners: {
@@ -295,7 +295,7 @@ describe('Calendar', () => {
295295
},
296296
{
297297
sync: false,
298-
attachToDocument: true,
298+
attachTo: 'body',
299299
},
300300
);
301301
await sleep(50);
@@ -355,7 +355,7 @@ describe('Calendar', () => {
355355
},
356356
{
357357
sync: false,
358-
attachToDocument: true,
358+
attachTo: 'body',
359359
},
360360
);
361361
await sleep(50);

components/carousel/__tests__/index.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('Carousel', () => {
5959

6060
it('should trigger autoPlay after window resize', async () => {
6161
const props = {
62-
propsData: {
62+
props: {
6363
autoplay: true,
6464
},
6565
slots: {
@@ -77,7 +77,7 @@ describe('Carousel', () => {
7777

7878
it('cancel resize listener when unmount', async () => {
7979
const props = {
80-
propsData: {
80+
props: {
8181
autoplay: true,
8282
},
8383
slots: {
@@ -89,7 +89,7 @@ describe('Carousel', () => {
8989
const { onWindowResized } = wrapper.vm;
9090
const spy = jest.spyOn(wrapper.vm.onWindowResized, 'cancel');
9191
const spy2 = jest.spyOn(window, 'removeEventListener');
92-
wrapper.destroy();
92+
wrapper.unmount();
9393
expect(spy).toHaveBeenCalled();
9494
expect(spy2).toHaveBeenCalledWith('resize', onWindowResized);
9595
});

components/cascader/__tests__/index.test.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('Cascader', () => {
5050
focusTest(Cascader);
5151

5252
it('popup correctly when panel is hidden', async () => {
53-
const wrapper = mount(Cascader, { propsData: { options }, sync: false });
53+
const wrapper = mount(Cascader, { props: { options }, sync: false });
5454
const CascaderWrapper = mount(
5555
{
5656
render() {
@@ -65,7 +65,7 @@ describe('Cascader', () => {
6565
});
6666

6767
it('popup correctly when panel is open', async () => {
68-
const wrapper = mount(Cascader, { propsData: { options }, sync: false });
68+
const wrapper = mount(Cascader, { props: { options }, sync: false });
6969
await asyncExpect(() => {
7070
wrapper.find('input').trigger('click');
7171
});
@@ -86,7 +86,7 @@ describe('Cascader', () => {
8686
});
8787

8888
it('support controlled mode', async () => {
89-
const wrapper = mount(Cascader, { propsData: { options }, sync: false });
89+
const wrapper = mount(Cascader, { props: { options }, sync: false });
9090
await asyncExpect(() => {
9191
wrapper.setProps({
9292
value: ['zhejiang', 'hangzhou', 'xihu'],
@@ -99,7 +99,7 @@ describe('Cascader', () => {
9999

100100
it('popup correctly with defaultValue', async () => {
101101
const wrapper = mount(Cascader, {
102-
propsData: {
102+
props: {
103103
options,
104104
defaultValue: ['zhejiang', 'hangzhou'],
105105
},
@@ -127,7 +127,7 @@ describe('Cascader', () => {
127127
});
128128

129129
it('can be selected', async () => {
130-
const wrapper = mount(Cascader, { propsData: { options }, sync: false });
130+
const wrapper = mount(Cascader, { props: { options }, sync: false });
131131
await asyncExpect(() => {
132132
wrapper.find('input').trigger('click');
133133
});
@@ -229,7 +229,7 @@ describe('Cascader', () => {
229229
});
230230

231231
it('backspace should work with `Cascader[showSearch]`', async () => {
232-
const wrapper = mount(Cascader, { propsData: { options, showSearch: true }, sync: false });
232+
const wrapper = mount(Cascader, { props: { options, showSearch: true }, sync: false });
233233
await asyncExpect(() => {
234234
wrapper.find('input').element.value = '123';
235235
wrapper.find('input').trigger('input');
@@ -258,9 +258,9 @@ describe('Cascader', () => {
258258

259259
it('limit with positive number', async () => {
260260
const wrapper = mount(Cascader, {
261-
propsData: { options, showSearch: { filter, limit: 1 } },
261+
props: { options, showSearch: { filter, limit: 1 } },
262262
sync: false,
263-
attachToDocument: true,
263+
attachTo: 'body',
264264
});
265265
wrapper.find('input').trigger('click');
266266
wrapper.find('input').element.value = 'a';
@@ -272,9 +272,9 @@ describe('Cascader', () => {
272272

273273
it('not limit', async () => {
274274
const wrapper = mount(Cascader, {
275-
propsData: { options, showSearch: { filter, limit: false } },
275+
props: { options, showSearch: { filter, limit: false } },
276276
sync: false,
277-
attachToDocument: true,
277+
attachTo: 'body',
278278
});
279279
wrapper.find('input').trigger('click');
280280
wrapper.find('input').element.value = 'a';
@@ -287,9 +287,9 @@ describe('Cascader', () => {
287287
it('negative limit', async () => {
288288
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
289289
const wrapper = mount(Cascader, {
290-
propsData: { options, showSearch: { filter, limit: -1 } },
290+
props: { options, showSearch: { filter, limit: -1 } },
291291
sync: false,
292-
attachToDocument: true,
292+
attachTo: 'body',
293293
});
294294
wrapper.find('input').trigger('click');
295295
wrapper.find('input').element.value = 'a';

components/checkbox/__tests__/checkbox.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Checkbox', () => {
2929

3030
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
3131
mount(Checkbox, {
32-
propsData: {
32+
props: {
3333
value: 'xxx',
3434
},
3535
});

components/checkbox/__tests__/group.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe('CheckboxGroup', () => {
120120
];
121121

122122
const wrapper = mount(Checkbox.Group, {
123-
propsData: { options },
123+
props: { options },
124124
sync: false,
125125
});
126126

0 commit comments

Comments
 (0)