Skip to content

Commit ddb1b7e

Browse files
committed
test: update test config
1 parent 29366a2 commit ddb1b7e

File tree

9 files changed

+36
-42
lines changed

9 files changed

+36
-42
lines changed

.babelrc

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"env": {
33
"test": {
4-
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]],
4+
"presets": [["env", { "targets": { "node": "current" } }]],
55
"plugins": [
66
["@ant-design-vue/babel-plugin-jsx", { "usePatchFlag": false }],
77
"babel-plugin-inline-import-data-uri",
@@ -11,7 +11,8 @@
1111
"@babel/plugin-transform-object-assign",
1212
"@babel/plugin-transform-template-literals",
1313
"@babel/plugin-proposal-object-rest-spread",
14-
"@babel/plugin-proposal-class-properties"
14+
"@babel/plugin-proposal-class-properties",
15+
"transform-runtime"
1516
]
1617
}
1718
}

antdv-demo

components/affix/index.jsx

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const AffixProps = {
3333
/** 设置 Affix 需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 */
3434
target: PropTypes.func.def(getDefaultTarget),
3535
prefixCls: PropTypes.string,
36+
onChange: PropTypes.func,
37+
onTestUpdatePosition: PropTypes.func,
3638
};
3739
const AffixStatus = {
3840
None: 'none',

components/badge/__tests__/index.test.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { mount } from '@vue/test-utils';
2-
import { render } from '@vue/server-test-utils';
32
import Badge from '../index';
43

54
import { asyncExpect } from '@/tests/utils';
@@ -13,7 +12,7 @@ describe('Badge', () => {
1312
expect(badge.findAll('.ant-card-multiple-words').length).toBe(0);
1413
});
1514
it('badge should support float number', () => {
16-
let wrapper = render({
15+
let wrapper = mount({
1716
render() {
1817
return <Badge count={3.5} />;
1918
},

components/index.js

+10-20
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ import { default as BackTop } from './back-top';
2929

3030
import { default as Badge } from './badge';
3131

32-
import { default as Base } from './base';
33-
3432
import { default as Breadcrumb } from './breadcrumb';
3533

3634
import { default as Button } from './button';
@@ -55,7 +53,6 @@ import { default as Divider } from './divider';
5553

5654
import { default as Dropdown } from './dropdown';
5755

58-
import { default as Form } from './form';
5956
import { default as FormModel } from './form-model';
6057

6158
import { default as Icon } from './icon';
@@ -148,7 +145,6 @@ import { default as Descriptions } from './descriptions';
148145
import { default as PageHeader } from './page-header';
149146

150147
const components = [
151-
Base,
152148
Affix,
153149
Anchor,
154150
AutoComplete,
@@ -168,7 +164,6 @@ const components = [
168164
DatePicker,
169165
Divider,
170166
Dropdown,
171-
Form,
172167
FormModel,
173168
Icon,
174169
Input,
@@ -213,28 +208,24 @@ const components = [
213208
PageHeader,
214209
];
215210

216-
const install = function(Vue) {
211+
const install = function(app) {
217212
components.map(component => {
218-
Vue.use(component);
213+
app.use(component);
219214
});
220215

221-
Vue.prototype.$message = message;
222-
Vue.prototype.$notification = notification;
223-
Vue.prototype.$info = Modal.info;
224-
Vue.prototype.$success = Modal.success;
225-
Vue.prototype.$error = Modal.error;
226-
Vue.prototype.$warning = Modal.warning;
227-
Vue.prototype.$confirm = Modal.confirm;
228-
Vue.prototype.$destroyAll = Modal.destroyAll;
216+
app.config.globalProperties.$message = message;
217+
app.config.globalProperties.$notification = notification;
218+
app.config.globalProperties.$info = Modal.info;
219+
app.config.globalProperties.$success = Modal.success;
220+
app.config.globalProperties.$error = Modal.error;
221+
app.config.globalProperties.$warning = Modal.warning;
222+
app.config.globalProperties.$confirm = Modal.confirm;
223+
app.config.globalProperties.$destroyAll = Modal.destroyAll;
229224
};
230225

231226
/* istanbul ignore if */
232-
if (typeof window !== 'undefined' && window.Vue) {
233-
install(window.Vue);
234-
}
235227

236228
export {
237-
Base,
238229
version,
239230
install,
240231
message,
@@ -258,7 +249,6 @@ export {
258249
DatePicker,
259250
Divider,
260251
Dropdown,
261-
Form,
262252
FormModel,
263253
Icon,
264254
Input,

examples/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</div>
55
</template>
66
<script>
7-
import demo from '../antdv-demo/docs/table/demo/ajax';
7+
import demo from '../antdv-demo/docs/affix/demo/index';
88
99
export default {
1010
components: {

examples/index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'ant-design-vue/style.js';
33
import { createApp, version } from 'vue';
44
import App from './App.vue';
55
import {
6+
Affix,
67
Badge,
78
AutoComplete,
89
Radio,
@@ -45,20 +46,18 @@ import {
4546

4647
// eslint-disable-next-line no-console
4748
console.log('Vue version: ', version);
48-
const basic = {
49-
render() {
50-
return this.$slots?.default();
51-
},
49+
const basic = (_, { slots }) => {
50+
return slots?.default();
5251
};
5352
const app = createApp(App);
5453
app.config.globalProperties.$notification = notification;
5554
app.config.globalProperties.$message = message;
5655
app
57-
.component('demo-sort', { ...basic })
58-
.component('md', { ...basic })
59-
.component('api', { ...basic })
60-
.component('CN', { ...basic })
61-
.component('US', { ...basic })
56+
.component('demo-sort', basic)
57+
.component('md', basic)
58+
.component('api', basic)
59+
.component('CN', basic)
60+
.component('US', basic)
6261
.use(Pagination)
6362
.use(Select)
6463
.use(Spin)
@@ -95,4 +94,5 @@ app
9594
.use(Table)
9695
.use(Tag)
9796
.use(Divider)
97+
.use(Affix)
9898
.mount('#app');

package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
},
5555
"homepage": "https://www.antdv.com/",
5656
"peerDependencies": {
57-
"vue": ">=2.6.0",
58-
"vue-template-compiler": ">=2.6.0"
57+
"vue": ">=3.0.0",
58+
"@vue/compiler-sfc": ">=3.0.0"
5959
},
6060
"devDependencies": {
6161
"@ant-design-vue/babel-plugin-jsx": "^1.0.0-beta.3",
@@ -68,6 +68,7 @@
6868
"@babel/plugin-transform-member-expression-literals": "^7.8.3",
6969
"@babel/plugin-transform-object-assign": "^7.8.3",
7070
"@babel/plugin-transform-property-literals": "^7.8.3",
71+
"@babel/plugin-transform-runtime": "^7.10.5",
7172
"@babel/plugin-transform-template-literals": "^7.8.3",
7273
"@babel/polyfill": "^7.8.7",
7374
"@babel/preset-env": "^7.9.6",
@@ -82,7 +83,7 @@
8283
"acorn": "^7.0.0",
8384
"autoprefixer": "^9.6.0",
8485
"axios": "^0.19.0",
85-
"babel-core": "~7.0.0-bridge.0",
86+
"babel-core": "^7.0.0-bridge.0",
8687
"babel-eslint": "^10.0.1",
8788
"babel-jest": "^23.6.0",
8889
"babel-loader": "^8.0.0",
@@ -151,6 +152,7 @@
151152
"stylelint-config-standard": "^19.0.0",
152153
"terser-webpack-plugin": "^3.0.3",
153154
"through2": "^3.0.0",
155+
"typescript": "^3.9.7",
154156
"url-loader": "^3.0.0",
155157
"vue": "^3.0.0-rc.2",
156158
"vue-antd-md-loader": "^1.1.0",
@@ -159,7 +161,7 @@
159161
"vue-eslint-parser": "^7.0.0",
160162
"vue-i18n": "^8.3.2",
161163
"vue-infinite-scroll": "^2.0.2",
162-
"vue-jest": "^3.0.5",
164+
"vue-jest": "^5.0.0-alpha.1",
163165
"vue-loader": "^16.0.0-beta.4",
164166
"vue-router": "^4.0.0-alpha.12",
165167
"vue-server-renderer": "^2.6.11",

tests/shared/demoTest.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import glob from 'glob';
22
import { mount } from '@vue/test-utils';
33
import MockDate from 'mockdate';
44
import moment from 'moment';
5-
import Vue from 'vue';
5+
import { createApp, nextTick } from 'vue';
66
import antd from 'ant-design-vue';
7-
Vue.use(antd);
87

98
export default function demoTest(component, options = {}) {
109
const suffix = options.suffix || 'md';
@@ -20,7 +19,8 @@ export default function demoTest(component, options = {}) {
2019
const demo = require(`../.${file}`).default || require(`../.${file}`);
2120
document.body.innerHTML = '';
2221
const wrapper = mount(demo, { sync: false, attachToDocument: true });
23-
Vue.nextTick(() => {
22+
createApp(wrapper).use(antd);
23+
nextTick(() => {
2424
// should get dom from element
2525
// snap files copy from antd does not need to change
2626
// or just change a little

0 commit comments

Comments
 (0)