test: config test and update button test
parent
36673e3d03
commit
7555f2c65b
16
.babelrc
16
.babelrc
|
@ -1,13 +1,17 @@
|
|||
{
|
||||
"env": {
|
||||
"test": {
|
||||
"presets": [["env", { "targets": { "node": "current" } }]],
|
||||
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]],
|
||||
"plugins": [
|
||||
"transform-vue-jsx",
|
||||
"transform-object-assign",
|
||||
"transform-object-rest-spread",
|
||||
"transform-class-properties",
|
||||
"transform-runtime"
|
||||
"@ant-design-vue/babel-plugin-jsx",
|
||||
"babel-plugin-inline-import-data-uri",
|
||||
"@babel/plugin-transform-member-expression-literals",
|
||||
"@babel/plugin-transform-property-literals",
|
||||
"@babel/plugin-proposal-export-default-from",
|
||||
"@babel/plugin-transform-object-assign",
|
||||
"@babel/plugin-transform-template-literals",
|
||||
"@babel/plugin-proposal-object-rest-spread",
|
||||
"@babel/plugin-proposal-class-properties"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
2
.jest.js
2
.jest.js
|
@ -21,7 +21,7 @@ module.exports = {
|
|||
'^@/(.*)$': '<rootDir>/$1',
|
||||
'ant-design-vue$': '<rootDir>/components/index.js',
|
||||
'ant-design-vue/es': '<rootDir>/components',
|
||||
'^vue$': 'vue/dist/vue.common.js',
|
||||
// '^vue$': 'vue/dist/vue.global.js',
|
||||
},
|
||||
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
|
||||
collectCoverage: process.env.COVERAGE === 'true',
|
||||
|
|
|
@ -1,23 +1,51 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Button fixbug renders {0} , 0 and {false} 1`] = `<button type="button" class="ant-btn"><span>0</span></button>`;
|
||||
exports[`Button fixbug renders {0} , 0 and {false} 1`] = `
|
||||
<button class="ant-btn" type="button">
|
||||
<!----><span>0</span></button>
|
||||
`;
|
||||
|
||||
exports[`Button fixbug renders {0} , 0 and {false} 2`] = `<button type="button" class="ant-btn"><span>0</span></button>`;
|
||||
exports[`Button fixbug renders {0} , 0 and {false} 2`] = `
|
||||
<button class="ant-btn" type="button">
|
||||
<!----><span>0</span></button>
|
||||
`;
|
||||
|
||||
exports[`Button fixbug renders {0} , 0 and {false} 3`] = `<button type="button" class="ant-btn"></button>`;
|
||||
exports[`Button fixbug renders {0} , 0 and {false} 3`] = `
|
||||
<button class="ant-btn" type="button">
|
||||
<!---->
|
||||
<!----></button>
|
||||
`;
|
||||
|
||||
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>`;
|
||||
exports[`Button renders Chinese characters correctly 1`] = `
|
||||
<button class="ant-btn" type="button">
|
||||
<!----><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>
|
||||
`;
|
||||
|
||||
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>`;
|
||||
exports[`Button renders Chinese characters correctly 2`] = `
|
||||
<button class="ant-btn" type="button">
|
||||
<!----><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>
|
||||
`;
|
||||
|
||||
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>`;
|
||||
exports[`Button renders Chinese characters correctly 3`] = `
|
||||
<button class="ant-btn" type="button">
|
||||
<!----><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>
|
||||
`;
|
||||
|
||||
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>`;
|
||||
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>`;
|
||||
|
||||
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>`;
|
||||
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>`;
|
||||
|
||||
exports[`Button renders correctly 1`] = `<button type="button" class="ant-btn"><span>Follow</span></button>`;
|
||||
exports[`Button renders correctly 1`] = `
|
||||
<button class="ant-btn" type="button">
|
||||
<!----><span>Follow</span></button>
|
||||
`;
|
||||
|
||||
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>`;
|
||||
exports[`Button should not render as link button when href is undefined 1`] = `
|
||||
<button class="ant-btn ant-btn-primary" type="button">
|
||||
<!----><span>button</span></button>
|
||||
`;
|
||||
|
||||
exports[`Button should support link button 1`] = `<a target="_blank" href="http://ant.design" class="ant-btn"><span>link button</span></a>`;
|
||||
exports[`Button should support link button 1`] = `
|
||||
<a target="_blank" href="http://ant.design" class="ant-btn">
|
||||
<!----><span>link button</span></a>
|
||||
`;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Button from '../index';
|
||||
import SearchOutlined from '@ant-design/icons-vue/SearchOutlined';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import Vue from 'vue';
|
||||
import { nextTick } from 'vue';
|
||||
import { asyncExpect } from '@/tests/utils';
|
||||
import { sleep } from '../../../tests/utils';
|
||||
import mountTest from '../../../tests/shared/mountTest';
|
||||
|
@ -24,7 +24,7 @@ describe('Button', () => {
|
|||
return <Button type="primary">按钮</Button>;
|
||||
},
|
||||
});
|
||||
expect(wrapper.contains('.ant-btn-primary')).toBe(true);
|
||||
expect(wrapper.find('.ant-btn-primary').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('renders Chinese characters correctly', done => {
|
||||
|
@ -99,8 +99,8 @@ describe('Button', () => {
|
|||
);
|
||||
},
|
||||
});
|
||||
Vue.nextTick(() => {
|
||||
expect(wrapper6.find('.ant-btn').contains('.ant-btn-two-chinese-chars')).toBe(true);
|
||||
nextTick(() => {
|
||||
expect(wrapper6.find('.ant-btn-two-chinese-chars').exists()).toBe(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -160,7 +160,7 @@ describe('Button', () => {
|
|||
wrapper.trigger('click');
|
||||
});
|
||||
await asyncExpect(() => {
|
||||
expect(wrapper.contains('.ant-btn-loading')).toBe(false);
|
||||
expect(wrapper.find('.ant-btn-loading').exists()).toBe(false);
|
||||
});
|
||||
});
|
||||
it('should not clickable when button is loading', () => {
|
||||
|
@ -227,16 +227,15 @@ describe('Button', () => {
|
|||
});
|
||||
|
||||
it('should support to change loading', async () => {
|
||||
const wrapper = mount(Button, {
|
||||
slots: {
|
||||
default: ['button'],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(Button);
|
||||
wrapper.setProps({ loading: true });
|
||||
await sleep();
|
||||
expect(wrapper.findAll('.ant-btn-loading').length).toBe(1);
|
||||
wrapper.setProps({ loading: false });
|
||||
await sleep();
|
||||
expect(wrapper.findAll('.ant-btn-loading').length).toBe(0);
|
||||
wrapper.setProps({ loading: { delay: 50 } });
|
||||
await sleep();
|
||||
expect(wrapper.findAll('.ant-btn-loading').length).toBe(0);
|
||||
await sleep(50);
|
||||
expect(wrapper.findAll('.ant-btn-loading').length).toBe(1);
|
||||
|
@ -244,7 +243,7 @@ describe('Button', () => {
|
|||
await sleep(50);
|
||||
expect(wrapper.findAll('.ant-btn-loading').length).toBe(0);
|
||||
expect(() => {
|
||||
wrapper.destroy();
|
||||
wrapper.unmount();
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ export default {
|
|||
name: 'AButtonGroup',
|
||||
props: ButtonGroupProps,
|
||||
setup() {
|
||||
const configProvider = inject('configProvider') || ConfigConsumerProps;
|
||||
const configProvider = inject('configProvider', ConfigConsumerProps);
|
||||
return {
|
||||
configProvider,
|
||||
};
|
||||
|
|
|
@ -20,6 +20,7 @@ export default {
|
|||
};
|
||||
},
|
||||
data() {
|
||||
this.children = [];
|
||||
return {
|
||||
sizeMap: {
|
||||
large: 'lg',
|
||||
|
@ -66,7 +67,6 @@ export default {
|
|||
ghost,
|
||||
block,
|
||||
icon,
|
||||
$slots,
|
||||
$attrs,
|
||||
} = this;
|
||||
const getPrefixCls = this.configProvider.getPrefixCls;
|
||||
|
@ -87,14 +87,13 @@ export default {
|
|||
break;
|
||||
}
|
||||
const iconType = sLoading ? 'loading' : icon;
|
||||
const children = filterEmpty($slots.default());
|
||||
return {
|
||||
[$attrs.class]: $attrs.class,
|
||||
[`${prefixCls}`]: true,
|
||||
[`${prefixCls}-${type}`]: type,
|
||||
[`${prefixCls}-${shape}`]: shape,
|
||||
[`${prefixCls}-${sizeCls}`]: sizeCls,
|
||||
[`${prefixCls}-icon-only`]: children.length === 0 && iconType,
|
||||
[`${prefixCls}-icon-only`]: this.children.length === 0 && iconType,
|
||||
[`${prefixCls}-loading`]: sLoading,
|
||||
[`${prefixCls}-background-ghost`]: ghost || type === 'ghost',
|
||||
[`${prefixCls}-two-chinese-chars`]: hasTwoCNChar && autoInsertSpace,
|
||||
|
@ -125,8 +124,8 @@ export default {
|
|||
},
|
||||
insertSpace(child, needInserted) {
|
||||
const SPACE = needInserted ? ' ' : '';
|
||||
if (typeof child.text === 'string') {
|
||||
let text = child.text.trim();
|
||||
if (typeof child.children === 'string') {
|
||||
let text = child.children.trim();
|
||||
if (isTwoCNChar(text)) {
|
||||
text = text.split('').join(SPACE);
|
||||
}
|
||||
|
@ -135,15 +134,17 @@ export default {
|
|||
return child;
|
||||
},
|
||||
isNeedInserted() {
|
||||
const { icon, $slots, type } = this;
|
||||
const children = filterEmpty($slots.default());
|
||||
return children && children.length === 1 && !icon && type !== 'link';
|
||||
const { icon, type } = this;
|
||||
return this.children.length === 1 && !icon && type !== 'link';
|
||||
},
|
||||
},
|
||||
render() {
|
||||
this.icon = this.$slots.icon && this.$slots.icon();
|
||||
const classes = this.getClasses();
|
||||
const { type, htmlType, icon, disabled, handleClick, sLoading, $slots, $attrs } = this;
|
||||
const children = filterEmpty($slots.default && $slots.default());
|
||||
this.children = children;
|
||||
const classes = this.getClasses();
|
||||
|
||||
const buttonProps = {
|
||||
...$attrs,
|
||||
disabled,
|
||||
|
@ -151,7 +152,7 @@ export default {
|
|||
onClick: handleClick,
|
||||
};
|
||||
const iconNode = sLoading ? <LoadingOutlined /> : icon;
|
||||
const children = $slots.default();
|
||||
|
||||
const autoInsertSpace = this.configProvider.autoInsertSpaceInButton !== false;
|
||||
const kids = children.map(child =>
|
||||
this.insertSpace(child, this.isNeedInserted() && autoInsertSpace),
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
"@ant-design-vue/babel-plugin-jsx": "^1.0.0-alpha.3",
|
||||
"@babel/cli": "^7.8.4",
|
||||
"@babel/core": "^7.9.6",
|
||||
"@babel/runtime": "^7.10.1",
|
||||
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
||||
"@babel/plugin-proposal-export-default-from": "^7.8.3",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.9.6",
|
||||
|
@ -76,10 +77,11 @@
|
|||
"@vue/cli-plugin-eslint": "^4.0.0",
|
||||
"@vue/compiler-sfc": "^3.0.0-beta.14",
|
||||
"@vue/server-test-utils": "1.0.0-beta.16",
|
||||
"@vue/test-utils": "1.0.0-beta.16",
|
||||
"@vue/test-utils": "^2.0.0-alpha.6",
|
||||
"acorn": "^7.0.0",
|
||||
"autoprefixer": "^9.6.0",
|
||||
"axios": "^0.19.0",
|
||||
"babel-core": "~7.0.0-bridge.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-jest": "^23.6.0",
|
||||
"babel-loader": "^8.0.0",
|
||||
|
@ -113,7 +115,7 @@
|
|||
"html-webpack-plugin": "^3.2.0",
|
||||
"husky": "^4.0.0",
|
||||
"istanbul-instrumenter-loader": "^3.0.0",
|
||||
"jest": "^24.0.0",
|
||||
"jest": "^25.4.0",
|
||||
"jest-serializer-vue": "^2.0.0",
|
||||
"jest-transform-stub": "^2.0.0",
|
||||
"js-base64": "^2.4.8",
|
||||
|
@ -156,7 +158,7 @@
|
|||
"vue-eslint-parser": "^7.0.0",
|
||||
"vue-i18n": "^8.3.2",
|
||||
"vue-infinite-scroll": "^2.0.2",
|
||||
"vue-jest": "^2.5.0",
|
||||
"vue-jest": "^3.0.5",
|
||||
"vue-loader": "^16.0.0-beta.2",
|
||||
"vue-router": "^4.0.0-alpha.12",
|
||||
"vue-server-renderer": "^2.6.11",
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import Vue from 'vue';
|
||||
import Base from '../components/base';
|
||||
// Vue.config.silent = true
|
||||
|
||||
/* eslint-disable global-require */
|
||||
|
@ -26,24 +24,23 @@ const mockMath = Object.create(global.Math);
|
|||
mockMath.random = () => 0.5;
|
||||
global.Math = mockMath;
|
||||
|
||||
Vue.use(Base);
|
||||
Vue.component('transition-group', {
|
||||
props: ['tag'],
|
||||
render(createElement) {
|
||||
return createElement(this.tag || 'div', null, this.$slots.default);
|
||||
},
|
||||
});
|
||||
// Vue.component('transition-group', {
|
||||
// props: ['tag'],
|
||||
// render(createElement) {
|
||||
// return createElement(this.tag || 'div', null, this.$slots.default);
|
||||
// },
|
||||
// });
|
||||
|
||||
Vue.prototype.$emit = function() {
|
||||
const vm = this;
|
||||
const args = [].slice.call(arguments, 0);
|
||||
const filterEvent = [];
|
||||
const eventName = args[0];
|
||||
if (args.length && vm.$listeners[eventName]) {
|
||||
if (filterEvent.includes(eventName)) {
|
||||
vm.$emit(eventName, ...args.slice(1));
|
||||
} else {
|
||||
vm.$listeners[eventName](...args.slice(1));
|
||||
}
|
||||
}
|
||||
};
|
||||
// Vue.prototype.$emit = function() {
|
||||
// const vm = this;
|
||||
// const args = [].slice.call(arguments, 0);
|
||||
// const filterEvent = [];
|
||||
// const eventName = args[0];
|
||||
// if (args.length && vm.$listeners[eventName]) {
|
||||
// if (filterEvent.includes(eventName)) {
|
||||
// vm.$emit(eventName, ...args.slice(1));
|
||||
// } else {
|
||||
// vm.$listeners[eventName](...args.slice(1));
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
|
|
@ -6,7 +6,7 @@ export default function mountTest(Component) {
|
|||
const wrapper = mount(Component, { sync: false });
|
||||
expect(() => {
|
||||
wrapper.vm.$forceUpdate();
|
||||
wrapper.destroy();
|
||||
wrapper.unmount();
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import moment from 'moment';
|
||||
import MockDate from 'mockdate';
|
||||
import Vue from 'vue';
|
||||
import { nextTick } from 'vue';
|
||||
|
||||
export function setMockDate(dateString = '2017-09-18T03:30:07.795') {
|
||||
MockDate.set(moment(dateString));
|
||||
|
@ -18,7 +18,7 @@ export function asyncExpect(fn, timeout) {
|
|||
resolve();
|
||||
}, timeout);
|
||||
} else {
|
||||
Vue.nextTick(() => {
|
||||
nextTick(() => {
|
||||
fn();
|
||||
resolve();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue