Skip to content

Commit 7555f2c

Browse files
committed
test: config test and update button test
1 parent 36673e3 commit 7555f2c

File tree

10 files changed

+109
-78
lines changed

10 files changed

+109
-78
lines changed

.babelrc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
{
22
"env": {
33
"test": {
4-
"presets": [["env", { "targets": { "node": "current" } }]],
4+
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]],
55
"plugins": [
6-
"transform-vue-jsx",
7-
"transform-object-assign",
8-
"transform-object-rest-spread",
9-
"transform-class-properties",
10-
"transform-runtime"
6+
"@ant-design-vue/babel-plugin-jsx",
7+
"babel-plugin-inline-import-data-uri",
8+
"@babel/plugin-transform-member-expression-literals",
9+
"@babel/plugin-transform-property-literals",
10+
"@babel/plugin-proposal-export-default-from",
11+
"@babel/plugin-transform-object-assign",
12+
"@babel/plugin-transform-template-literals",
13+
"@babel/plugin-proposal-object-rest-spread",
14+
"@babel/plugin-proposal-class-properties"
1115
]
1216
}
1317
}

.jest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
'^@/(.*)$': '<rootDir>/$1',
2222
'ant-design-vue$': '<rootDir>/components/index.js',
2323
'ant-design-vue/es': '<rootDir>/components',
24-
'^vue$': 'vue/dist/vue.common.js',
24+
// '^vue$': 'vue/dist/vue.global.js',
2525
},
2626
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
2727
collectCoverage: process.env.COVERAGE === 'true',
Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,51 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Button fixbug renders {0} , 0 and {false} 1`] = `<button type="button" class="ant-btn"><span>0</span></button>`;
4-
5-
exports[`Button fixbug renders {0} , 0 and {false} 2`] = `<button type="button" class="ant-btn"><span>0</span></button>`;
6-
7-
exports[`Button fixbug renders {0} , 0 and {false} 3`] = `<button type="button" class="ant-btn"></button>`;
8-
9-
exports[`Button renders Chinese characters correctly 1`] = `<button type="button" class="ant-btn"><span role="img" aria-label="search" class="anticon anticon-search"><svg viewBox="64 64 896 896" focusable="false" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span><span>按钮</span></button>`;
10-
11-
exports[`Button renders Chinese characters correctly 2`] = `<button type="button" class="ant-btn"><span role="img" aria-label="search" class="anticon anticon-search"><svg viewBox="64 64 896 896" focusable="false" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span><span>按钮</span></button>`;
12-
13-
exports[`Button renders Chinese characters correctly 3`] = `<button type="button" class="ant-btn"><span role="img" aria-label="search" class="anticon anticon-search"><svg viewBox="64 64 896 896" focusable="false" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span><span>按钮</span></button>`;
14-
15-
exports[`Button renders Chinese characters correctly 4`] = `<button type="button" class="ant-btn ant-btn-loading"><span role="img" aria-label="loading" class="anticon anticon-loading"><svg viewBox="0 0 1024 1024" focusable="false" data-icon="loading" width="1em" height="1em" fill="currentColor" aria-hidden="true" class="anticon-spin"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg></span><span>按钮</span></button>`;
16-
17-
exports[`Button renders Chinese characters correctly 5`] = `<button type="button" class="ant-btn ant-btn-loading"><span role="img" aria-label="loading" class="anticon anticon-loading"><svg viewBox="0 0 1024 1024" focusable="false" data-icon="loading" width="1em" height="1em" fill="currentColor" aria-hidden="true" class="anticon-spin"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg></span><span>按 钮</span></button>`;
18-
19-
exports[`Button renders correctly 1`] = `<button type="button" class="ant-btn"><span>Follow</span></button>`;
20-
21-
exports[`Button should not render as link button when href is undefined 1`] = `<button type="button" class="ant-btn ant-btn-primary"><span>button</span></button>`;
22-
23-
exports[`Button should support link button 1`] = `<a target="_blank" href="http://ant.design" class="ant-btn"><span>link button</span></a>`;
3+
exports[`Button fixbug renders {0} , 0 and {false} 1`] = `
4+
<button class="ant-btn" type="button">
5+
<!----><span>0</span></button>
6+
`;
7+
8+
exports[`Button fixbug renders {0} , 0 and {false} 2`] = `
9+
<button class="ant-btn" type="button">
10+
<!----><span>0</span></button>
11+
`;
12+
13+
exports[`Button fixbug renders {0} , 0 and {false} 3`] = `
14+
<button class="ant-btn" type="button">
15+
<!---->
16+
<!----></button>
17+
`;
18+
19+
exports[`Button renders Chinese characters correctly 1`] = `
20+
<button class="ant-btn" type="button">
21+
<!----><span class="anticon anticon-search" role="img" aria-label="search" slot="icon"><svg class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896" focusable="false"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span><span>按钮</span></button>
22+
`;
23+
24+
exports[`Button renders Chinese characters correctly 2`] = `
25+
<button class="ant-btn" type="button">
26+
<!----><span class="anticon anticon-search" role="img" aria-label="search"><svg class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896" focusable="false"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span><span>按钮</span></button>
27+
`;
28+
29+
exports[`Button renders Chinese characters correctly 3`] = `
30+
<button class="ant-btn" type="button">
31+
<!----><span class="anticon anticon-search" role="img" aria-label="search" slot="icon"><svg class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896" focusable="false"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span><span>按钮</span></button>
32+
`;
33+
34+
exports[`Button renders Chinese characters correctly 4`] = `<button class="ant-btn ant-btn-loading" type="button"><span class="anticon anticon-loading" role="img" aria-label="loading"><svg class="anticon-spin" data-icon="loading" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="0 0 1024 1024" focusable="false"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg></span><span class="anticon anticon-search" role="img" aria-label="search" slot="icon"><svg class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896" focusable="false"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span><span>按钮</span></button>`;
35+
36+
exports[`Button renders Chinese characters correctly 5`] = `<button class="ant-btn ant-btn-loading" type="button"><span class="anticon anticon-loading" role="img" aria-label="loading"><svg class="anticon-spin" data-icon="loading" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="0 0 1024 1024" focusable="false"><path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path></svg></span><span>按 钮</span></button>`;
37+
38+
exports[`Button renders correctly 1`] = `
39+
<button class="ant-btn" type="button">
40+
<!----><span>Follow</span></button>
41+
`;
42+
43+
exports[`Button should not render as link button when href is undefined 1`] = `
44+
<button class="ant-btn ant-btn-primary" type="button">
45+
<!----><span>button</span></button>
46+
`;
47+
48+
exports[`Button should support link button 1`] = `
49+
<a target="_blank" href="http://ant.design" class="ant-btn">
50+
<!----><span>link button</span></a>
51+
`;

components/button/__tests__/index.test.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Button from '../index';
22
import SearchOutlined from '@ant-design/icons-vue/SearchOutlined';
33
import { mount } from '@vue/test-utils';
4-
import Vue from 'vue';
4+
import { nextTick } from 'vue';
55
import { asyncExpect } from '@/tests/utils';
66
import { sleep } from '../../../tests/utils';
77
import mountTest from '../../../tests/shared/mountTest';
@@ -24,7 +24,7 @@ describe('Button', () => {
2424
return <Button type="primary">按钮</Button>;
2525
},
2626
});
27-
expect(wrapper.contains('.ant-btn-primary')).toBe(true);
27+
expect(wrapper.find('.ant-btn-primary').exists()).toBe(true);
2828
});
2929

3030
it('renders Chinese characters correctly', done => {
@@ -99,8 +99,8 @@ describe('Button', () => {
9999
);
100100
},
101101
});
102-
Vue.nextTick(() => {
103-
expect(wrapper6.find('.ant-btn').contains('.ant-btn-two-chinese-chars')).toBe(true);
102+
nextTick(() => {
103+
expect(wrapper6.find('.ant-btn-two-chinese-chars').exists()).toBe(true);
104104
done();
105105
});
106106
});
@@ -160,7 +160,7 @@ describe('Button', () => {
160160
wrapper.trigger('click');
161161
});
162162
await asyncExpect(() => {
163-
expect(wrapper.contains('.ant-btn-loading')).toBe(false);
163+
expect(wrapper.find('.ant-btn-loading').exists()).toBe(false);
164164
});
165165
});
166166
it('should not clickable when button is loading', () => {
@@ -227,24 +227,23 @@ describe('Button', () => {
227227
});
228228

229229
it('should support to change loading', async () => {
230-
const wrapper = mount(Button, {
231-
slots: {
232-
default: ['button'],
233-
},
234-
});
230+
const wrapper = mount(Button);
235231
wrapper.setProps({ loading: true });
232+
await sleep();
236233
expect(wrapper.findAll('.ant-btn-loading').length).toBe(1);
237234
wrapper.setProps({ loading: false });
235+
await sleep();
238236
expect(wrapper.findAll('.ant-btn-loading').length).toBe(0);
239237
wrapper.setProps({ loading: { delay: 50 } });
238+
await sleep();
240239
expect(wrapper.findAll('.ant-btn-loading').length).toBe(0);
241240
await sleep(50);
242241
expect(wrapper.findAll('.ant-btn-loading').length).toBe(1);
243242
wrapper.setProps({ loading: false });
244243
await sleep(50);
245244
expect(wrapper.findAll('.ant-btn-loading').length).toBe(0);
246245
expect(() => {
247-
wrapper.destroy();
246+
wrapper.unmount();
248247
}).not.toThrow();
249248
});
250249
});

components/button/button-group.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default {
1616
name: 'AButtonGroup',
1717
props: ButtonGroupProps,
1818
setup() {
19-
const configProvider = inject('configProvider') || ConfigConsumerProps;
19+
const configProvider = inject('configProvider', ConfigConsumerProps);
2020
return {
2121
configProvider,
2222
};

components/button/button.jsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default {
2020
};
2121
},
2222
data() {
23+
this.children = [];
2324
return {
2425
sizeMap: {
2526
large: 'lg',
@@ -66,7 +67,6 @@ export default {
6667
ghost,
6768
block,
6869
icon,
69-
$slots,
7070
$attrs,
7171
} = this;
7272
const getPrefixCls = this.configProvider.getPrefixCls;
@@ -87,14 +87,13 @@ export default {
8787
break;
8888
}
8989
const iconType = sLoading ? 'loading' : icon;
90-
const children = filterEmpty($slots.default());
9190
return {
9291
[$attrs.class]: $attrs.class,
9392
[`${prefixCls}`]: true,
9493
[`${prefixCls}-${type}`]: type,
9594
[`${prefixCls}-${shape}`]: shape,
9695
[`${prefixCls}-${sizeCls}`]: sizeCls,
97-
[`${prefixCls}-icon-only`]: children.length === 0 && iconType,
96+
[`${prefixCls}-icon-only`]: this.children.length === 0 && iconType,
9897
[`${prefixCls}-loading`]: sLoading,
9998
[`${prefixCls}-background-ghost`]: ghost || type === 'ghost',
10099
[`${prefixCls}-two-chinese-chars`]: hasTwoCNChar && autoInsertSpace,
@@ -125,8 +124,8 @@ export default {
125124
},
126125
insertSpace(child, needInserted) {
127126
const SPACE = needInserted ? ' ' : '';
128-
if (typeof child.text === 'string') {
129-
let text = child.text.trim();
127+
if (typeof child.children === 'string') {
128+
let text = child.children.trim();
130129
if (isTwoCNChar(text)) {
131130
text = text.split('').join(SPACE);
132131
}
@@ -135,23 +134,25 @@ export default {
135134
return child;
136135
},
137136
isNeedInserted() {
138-
const { icon, $slots, type } = this;
139-
const children = filterEmpty($slots.default());
140-
return children && children.length === 1 && !icon && type !== 'link';
137+
const { icon, type } = this;
138+
return this.children.length === 1 && !icon && type !== 'link';
141139
},
142140
},
143141
render() {
144142
this.icon = this.$slots.icon && this.$slots.icon();
145-
const classes = this.getClasses();
146143
const { type, htmlType, icon, disabled, handleClick, sLoading, $slots, $attrs } = this;
144+
const children = filterEmpty($slots.default && $slots.default());
145+
this.children = children;
146+
const classes = this.getClasses();
147+
147148
const buttonProps = {
148149
...$attrs,
149150
disabled,
150151
class: classes,
151152
onClick: handleClick,
152153
};
153154
const iconNode = sLoading ? <LoadingOutlined /> : icon;
154-
const children = $slots.default();
155+
155156
const autoInsertSpace = this.configProvider.autoInsertSpaceInButton !== false;
156157
const kids = children.map(child =>
157158
this.insertSpace(child, this.isNeedInserted() && autoInsertSpace),

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"@ant-design-vue/babel-plugin-jsx": "^1.0.0-alpha.3",
6262
"@babel/cli": "^7.8.4",
6363
"@babel/core": "^7.9.6",
64+
"@babel/runtime": "^7.10.1",
6465
"@babel/plugin-proposal-class-properties": "^7.8.3",
6566
"@babel/plugin-proposal-export-default-from": "^7.8.3",
6667
"@babel/plugin-proposal-object-rest-spread": "^7.9.6",
@@ -76,10 +77,11 @@
7677
"@vue/cli-plugin-eslint": "^4.0.0",
7778
"@vue/compiler-sfc": "^3.0.0-beta.14",
7879
"@vue/server-test-utils": "1.0.0-beta.16",
79-
"@vue/test-utils": "1.0.0-beta.16",
80+
"@vue/test-utils": "^2.0.0-alpha.6",
8081
"acorn": "^7.0.0",
8182
"autoprefixer": "^9.6.0",
8283
"axios": "^0.19.0",
84+
"babel-core": "~7.0.0-bridge.0",
8385
"babel-eslint": "^10.0.1",
8486
"babel-jest": "^23.6.0",
8587
"babel-loader": "^8.0.0",
@@ -113,7 +115,7 @@
113115
"html-webpack-plugin": "^3.2.0",
114116
"husky": "^4.0.0",
115117
"istanbul-instrumenter-loader": "^3.0.0",
116-
"jest": "^24.0.0",
118+
"jest": "^25.4.0",
117119
"jest-serializer-vue": "^2.0.0",
118120
"jest-transform-stub": "^2.0.0",
119121
"js-base64": "^2.4.8",
@@ -156,7 +158,7 @@
156158
"vue-eslint-parser": "^7.0.0",
157159
"vue-i18n": "^8.3.2",
158160
"vue-infinite-scroll": "^2.0.2",
159-
"vue-jest": "^2.5.0",
161+
"vue-jest": "^3.0.5",
160162
"vue-loader": "^16.0.0-beta.2",
161163
"vue-router": "^4.0.0-alpha.12",
162164
"vue-server-renderer": "^2.6.11",

tests/setup.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import Vue from 'vue';
2-
import Base from '../components/base';
31
// Vue.config.silent = true
42

53
/* eslint-disable global-require */
@@ -26,24 +24,23 @@ const mockMath = Object.create(global.Math);
2624
mockMath.random = () => 0.5;
2725
global.Math = mockMath;
2826

29-
Vue.use(Base);
30-
Vue.component('transition-group', {
31-
props: ['tag'],
32-
render(createElement) {
33-
return createElement(this.tag || 'div', null, this.$slots.default);
34-
},
35-
});
27+
// Vue.component('transition-group', {
28+
// props: ['tag'],
29+
// render(createElement) {
30+
// return createElement(this.tag || 'div', null, this.$slots.default);
31+
// },
32+
// });
3633

37-
Vue.prototype.$emit = function() {
38-
const vm = this;
39-
const args = [].slice.call(arguments, 0);
40-
const filterEvent = [];
41-
const eventName = args[0];
42-
if (args.length && vm.$listeners[eventName]) {
43-
if (filterEvent.includes(eventName)) {
44-
vm.$emit(eventName, ...args.slice(1));
45-
} else {
46-
vm.$listeners[eventName](...args.slice(1));
47-
}
48-
}
49-
};
34+
// Vue.prototype.$emit = function() {
35+
// const vm = this;
36+
// const args = [].slice.call(arguments, 0);
37+
// const filterEvent = [];
38+
// const eventName = args[0];
39+
// if (args.length && vm.$listeners[eventName]) {
40+
// if (filterEvent.includes(eventName)) {
41+
// vm.$emit(eventName, ...args.slice(1));
42+
// } else {
43+
// vm.$listeners[eventName](...args.slice(1));
44+
// }
45+
// }
46+
// };

tests/shared/mountTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default function mountTest(Component) {
66
const wrapper = mount(Component, { sync: false });
77
expect(() => {
88
wrapper.vm.$forceUpdate();
9-
wrapper.destroy();
9+
wrapper.unmount();
1010
}).not.toThrow();
1111
});
1212
});

0 commit comments

Comments
 (0)