From 83ab9b19170368237d715b49a3148dadf89baa12 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 27 Jun 2018 11:56:14 +0800 Subject: [PATCH] bump vue-test-utils (#1338) --- package.json | 4 ++-- packages/actionsheet/test/index.spec.js | 4 ++-- packages/address-edit/index.vue | 6 +++--- packages/address-edit/test/index.spec.js | 3 +-- packages/area/test/index.spec.js | 3 +-- packages/badge/test/index.spec.js | 2 +- packages/cell-swipe/test/index.spec.js | 3 +-- packages/cell/test/index.spec.js | 2 +- packages/checkbox/test/index.spec.js | 2 +- packages/collapse/test/index.spec.js | 2 +- packages/contact-card/test/index.spec.js | 3 +-- packages/coupon-list/test/index.spec.js | 2 +- packages/dialog/test/index.spec.js | 3 +-- packages/field/test/index.spec.js | 3 +-- packages/goods-action/test/index.spec.js | 2 +- packages/image-preview/test/index.spec.js | 3 +-- packages/list/test/index.spec.js | 3 +-- packages/number-keyboard/test/index.spec.js | 2 +- packages/picker/PickerColumn.vue | 4 ++-- packages/picker/test/index.spec.js | 3 +-- packages/popup/test/index.spec.js | 6 ++---- packages/progress/test/index.spec.js | 2 +- packages/pull-refresh/test/index.spec.js | 3 +-- packages/rate/test/index.spec.js | 2 +- packages/search/test/index.spec.js | 2 +- packages/slider/test/index.spec.js | 3 +-- packages/stepper/test/index.spec.js | 2 +- packages/submit-bar/test/index.spec.js | 2 +- packages/swipe/test/index.spec.js | 3 +-- packages/switch-cell/test/index.spec.js | 2 +- packages/switch/test/index.spec.js | 2 +- packages/tree-select/test/index.spec.js | 2 +- packages/uploader/test/index.spec.js | 3 +-- test/utils.js | 9 ++++++++- yarn.lock | 12 ++++++------ 35 files changed, 53 insertions(+), 61 deletions(-) diff --git a/package.json b/package.json index e4c01d1e9..a0e8b08c9 100644 --- a/package.json +++ b/package.json @@ -56,8 +56,8 @@ "vue": ">= 2.5.0" }, "devDependencies": { - "@vue/server-test-utils": "^1.0.0-beta.16", - "@vue/test-utils": "^1.0.0-beta.16", + "@vue/server-test-utils": "^1.0.0-beta.20", + "@vue/test-utils": "^1.0.0-beta.20", "autoprefixer": "^8.6.4", "babel-cli": "^6.26.0", "babel-core": "^6.26.3", diff --git a/packages/actionsheet/test/index.spec.js b/packages/actionsheet/test/index.spec.js index 95fb76c44..2b5f7c11b 100644 --- a/packages/actionsheet/test/index.spec.js +++ b/packages/actionsheet/test/index.spec.js @@ -1,9 +1,9 @@ -import { shallowMount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; import Actionsheet from '../'; test('callback events', () => { const callback = jest.fn(); - const wrapper = shallowMount(Actionsheet, { + const wrapper = mount(Actionsheet, { propsData: { actions: [ { name: 'Option', callback }, diff --git a/packages/address-edit/index.vue b/packages/address-edit/index.vue index cf580d3d8..d40f987cd 100644 --- a/packages/address-edit/index.vue +++ b/packages/address-edit/index.vue @@ -216,9 +216,9 @@ export default create({ assignAreaValues(values) { Object.assign(this.data, { - province: values[0].name, - city: values[1].name, - county: values[2].name + province: values[0] ? values[0].name : '', + city: values[1] ? values[1].name : '', + county: values[2] ? values[2].name : '' }); }, diff --git a/packages/address-edit/test/index.spec.js b/packages/address-edit/test/index.spec.js index 4a19cae44..204c1f6b6 100644 --- a/packages/address-edit/test/index.spec.js +++ b/packages/address-edit/test/index.spec.js @@ -1,9 +1,8 @@ /* eslint-disable camelcase */ -import { mount } from '@vue/test-utils'; import { renderToString } from '@vue/server-test-utils'; import AddressEdit from '../'; import areaList from '../../area/demo/area.simple'; -import { later, transitionStub } from '../../../test/utils'; +import { mount, later, transitionStub } from '../../../test/utils'; transitionStub(); diff --git a/packages/area/test/index.spec.js b/packages/area/test/index.spec.js index e78302280..07722ef1d 100644 --- a/packages/area/test/index.spec.js +++ b/packages/area/test/index.spec.js @@ -1,7 +1,6 @@ import Area from '..'; -import { mount } from '@vue/test-utils'; import areaList from '../demo/area.simple'; -import { later, triggerDrag } from '../../../test/utils'; +import { mount, later, triggerDrag } from '../../../test/utils'; const firstOption = [ { code: '110000', name: '北京市' }, diff --git a/packages/badge/test/index.spec.js b/packages/badge/test/index.spec.js index 9b3afe957..1c7d9c28b 100644 --- a/packages/badge/test/index.spec.js +++ b/packages/badge/test/index.spec.js @@ -1,4 +1,4 @@ -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; import Badge from '../'; import BadgeGroup from '../../badge-group'; diff --git a/packages/cell-swipe/test/index.spec.js b/packages/cell-swipe/test/index.spec.js index 288707f31..a58787832 100644 --- a/packages/cell-swipe/test/index.spec.js +++ b/packages/cell-swipe/test/index.spec.js @@ -1,6 +1,5 @@ import CellSwipe from '..'; -import { mount } from '@vue/test-utils'; -import { triggerDrag } from '../../../test/utils'; +import { mount, triggerDrag } from '../../../test/utils'; const defaultProps = { propsData: { diff --git a/packages/cell/test/index.spec.js b/packages/cell/test/index.spec.js index d11079c19..73dd6cfee 100644 --- a/packages/cell/test/index.spec.js +++ b/packages/cell/test/index.spec.js @@ -1,5 +1,5 @@ import Cell from '..'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; test('click event', () => { const wrapper = mount(Cell); diff --git a/packages/checkbox/test/index.spec.js b/packages/checkbox/test/index.spec.js index 1b4f43c07..77d5478cd 100644 --- a/packages/checkbox/test/index.spec.js +++ b/packages/checkbox/test/index.spec.js @@ -1,6 +1,6 @@ import Checkbox from '..'; import CheckboxGroup from '../../checkbox-group'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; test('switch checkbox', () => { const wrapper = mount(Checkbox); diff --git a/packages/collapse/test/index.spec.js b/packages/collapse/test/index.spec.js index dc46f74cd..85fba216c 100644 --- a/packages/collapse/test/index.spec.js +++ b/packages/collapse/test/index.spec.js @@ -1,6 +1,6 @@ import Collapse from '..'; import CollapseItem from '../../collapse-item'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; const component = { template: ` diff --git a/packages/contact-card/test/index.spec.js b/packages/contact-card/test/index.spec.js index 4c93867dc..b5df80cc6 100644 --- a/packages/contact-card/test/index.spec.js +++ b/packages/contact-card/test/index.spec.js @@ -1,8 +1,7 @@ import ContactCard from '..'; import ContactList from '../../contact-list'; import ContactEdit from '../../contact-edit'; -import { mount } from '@vue/test-utils'; -import { later } from '../../../test/utils'; +import { mount, later } from '../../../test/utils'; const contactInfo = { name: 'test', diff --git a/packages/coupon-list/test/index.spec.js b/packages/coupon-list/test/index.spec.js index f3f15a78d..c5438a4e9 100644 --- a/packages/coupon-list/test/index.spec.js +++ b/packages/coupon-list/test/index.spec.js @@ -1,6 +1,6 @@ import CouponList from '../../coupon-list'; import CouponCell from '../../coupon-cell'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; test('exchange coupon', () => { const wrapper = mount(CouponList); diff --git a/packages/dialog/test/index.spec.js b/packages/dialog/test/index.spec.js index 560504c6d..7b22b10cc 100644 --- a/packages/dialog/test/index.spec.js +++ b/packages/dialog/test/index.spec.js @@ -1,8 +1,7 @@ import Vue from 'vue'; import Dialog from '..'; import DialogVue from '../dialog'; -import { mount } from '@vue/test-utils'; -import { later, transitionStub } from '../../../test/utils'; +import { mount, later, transitionStub } from '../../../test/utils'; transitionStub(); diff --git a/packages/field/test/index.spec.js b/packages/field/test/index.spec.js index 9919743be..ce554c5fe 100644 --- a/packages/field/test/index.spec.js +++ b/packages/field/test/index.spec.js @@ -1,6 +1,5 @@ import Field from '../'; -import { mount } from '@vue/test-utils'; -import { later } from '../../../test/utils'; +import { mount, later } from '../../../test/utils'; test('input event', () => { const wrapper = mount(Field); diff --git a/packages/goods-action/test/index.spec.js b/packages/goods-action/test/index.spec.js index ff503bbb6..244380dbc 100644 --- a/packages/goods-action/test/index.spec.js +++ b/packages/goods-action/test/index.spec.js @@ -1,6 +1,6 @@ import BigBtn from '../../goods-action-big-btn'; import SmallBtn from '../../goods-action-mini-btn'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; test('big btn click event', () => { const wrapper = mount(BigBtn); diff --git a/packages/image-preview/test/index.spec.js b/packages/image-preview/test/index.spec.js index c2bc347dd..0cc312cd0 100644 --- a/packages/image-preview/test/index.spec.js +++ b/packages/image-preview/test/index.spec.js @@ -1,8 +1,7 @@ import Vue from 'vue'; import ImagePreview from '..'; import ImagePreviewVue from '../image-preview'; -import { mount } from '@vue/test-utils'; -import { triggerDrag } from '../../../test/utils'; +import { mount, triggerDrag } from '../../../test/utils'; const images = [ 'https://img.yzcdn.cn/1.png', diff --git a/packages/list/test/index.spec.js b/packages/list/test/index.spec.js index 3d3cec470..3c8c47a79 100644 --- a/packages/list/test/index.spec.js +++ b/packages/list/test/index.spec.js @@ -1,6 +1,5 @@ import List from '..'; -import { mount } from '@vue/test-utils'; -import { later } from '../../../test/utils'; +import { mount, later } from '../../../test/utils'; test('load event', async() => { const wrapper = mount(List); diff --git a/packages/number-keyboard/test/index.spec.js b/packages/number-keyboard/test/index.spec.js index 7be8d9ea5..49491c585 100644 --- a/packages/number-keyboard/test/index.spec.js +++ b/packages/number-keyboard/test/index.spec.js @@ -1,5 +1,5 @@ import NumberKeyboard from '../'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; function mockTouch(wrapper, event, keyIndex) { const key = wrapper.element.querySelectorAll('.van-key')[keyIndex]; diff --git a/packages/picker/PickerColumn.vue b/packages/picker/PickerColumn.vue index 680c3500c..92b484b43 100644 --- a/packages/picker/PickerColumn.vue +++ b/packages/picker/PickerColumn.vue @@ -59,7 +59,7 @@ export default create({ }, created() { - this.$parent && this.$parent.children.push(this); + this.$parent.children && this.$parent.children.push(this); }, mounted() { @@ -67,7 +67,7 @@ export default create({ }, destroyed() { - this.$parent && this.$parent.children.splice(this.$parent.children.indexOf(this), 1); + this.$parent.children && this.$parent.children.splice(this.$parent.children.indexOf(this), 1); }, watch: { diff --git a/packages/picker/test/index.spec.js b/packages/picker/test/index.spec.js index 2e25987c5..4303020ce 100644 --- a/packages/picker/test/index.spec.js +++ b/packages/picker/test/index.spec.js @@ -1,7 +1,6 @@ import Picker from '../'; import PickerColumn from '../PickerColumn'; -import { mount } from '@vue/test-utils'; -import { triggerDrag } from '../../../test/utils'; +import { mount, triggerDrag } from '../../../test/utils'; const simpleColumn = ['1990', '1991', '1992', '1993', '1994', '1995']; const columns = [ diff --git a/packages/popup/test/index.spec.js b/packages/popup/test/index.spec.js index 56c401aaf..ba780cb63 100644 --- a/packages/popup/test/index.spec.js +++ b/packages/popup/test/index.spec.js @@ -1,9 +1,7 @@ -import Vue from 'vue'; import Popup from '../'; -import { mount, TransitionStub } from '@vue/test-utils'; -import { triggerDrag } from '../../../test/utils'; +import { mount, triggerDrag, transitionStub } from '../../../test/utils'; -Vue.component('transition', TransitionStub); +transitionStub(); let wrapper; afterEach(() => { diff --git a/packages/progress/test/index.spec.js b/packages/progress/test/index.spec.js index 46d5cff96..d379deef9 100644 --- a/packages/progress/test/index.spec.js +++ b/packages/progress/test/index.spec.js @@ -1,5 +1,5 @@ import Progress from '../'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; test('calc width', () => { const wrapper = mount(Progress, { diff --git a/packages/pull-refresh/test/index.spec.js b/packages/pull-refresh/test/index.spec.js index 8b5085b0f..60569ede7 100644 --- a/packages/pull-refresh/test/index.spec.js +++ b/packages/pull-refresh/test/index.spec.js @@ -1,6 +1,5 @@ import PullRefresh from '..'; -import { mount } from '@vue/test-utils'; -import { trigger, triggerDrag } from '../../../test/utils'; +import { mount, trigger, triggerDrag } from '../../../test/utils'; test('change head content when pulling down', () => { const wrapper = mount(PullRefresh, { diff --git a/packages/rate/test/index.spec.js b/packages/rate/test/index.spec.js index 581cb588d..92c4fa3a5 100644 --- a/packages/rate/test/index.spec.js +++ b/packages/rate/test/index.spec.js @@ -1,5 +1,5 @@ import Rate from '../'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; test('change event', () => { const wrapper = mount(Rate, { diff --git a/packages/search/test/index.spec.js b/packages/search/test/index.spec.js index 21c58755a..d403e5198 100644 --- a/packages/search/test/index.spec.js +++ b/packages/search/test/index.spec.js @@ -1,5 +1,5 @@ import Search from '..'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; test('listen input event', () => { const wrapper = mount(Search); diff --git a/packages/slider/test/index.spec.js b/packages/slider/test/index.spec.js index 6623a3494..682754841 100644 --- a/packages/slider/test/index.spec.js +++ b/packages/slider/test/index.spec.js @@ -1,6 +1,5 @@ import Slider from '..'; -import { mount } from '@vue/test-utils'; -import { triggerDrag, trigger } from '../../../test/utils'; +import { mount, triggerDrag, trigger } from '../../../test/utils'; Element.prototype.getBoundingClientRect = jest.fn(() => ({ width: 100, left: 0 })); diff --git a/packages/stepper/test/index.spec.js b/packages/stepper/test/index.spec.js index 97d9e79a3..94de6407a 100644 --- a/packages/stepper/test/index.spec.js +++ b/packages/stepper/test/index.spec.js @@ -1,5 +1,5 @@ import Stepper from '..'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; test('disabled stepper', () => { const wrapper = mount(Stepper, { diff --git a/packages/submit-bar/test/index.spec.js b/packages/submit-bar/test/index.spec.js index 5901d2d0a..0f8881826 100644 --- a/packages/submit-bar/test/index.spec.js +++ b/packages/submit-bar/test/index.spec.js @@ -1,5 +1,5 @@ import SubmitBar from '../'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; test('submit', () => { const wrapper = mount(SubmitBar, { diff --git a/packages/swipe/test/index.spec.js b/packages/swipe/test/index.spec.js index 79001d1fb..d04be5a1c 100644 --- a/packages/swipe/test/index.spec.js +++ b/packages/swipe/test/index.spec.js @@ -1,7 +1,6 @@ import Swipe from '..'; import SwipeItem from '../../swipe-item'; -import { mount } from '@vue/test-utils'; -import { triggerDrag, later } from '../../../test/utils'; +import { mount, triggerDrag, later } from '../../../test/utils'; const Component = { template: ` diff --git a/packages/switch-cell/test/index.spec.js b/packages/switch-cell/test/index.spec.js index 7e2658396..ff1f0248a 100644 --- a/packages/switch-cell/test/index.spec.js +++ b/packages/switch-cell/test/index.spec.js @@ -1,5 +1,5 @@ import SwitchCell from '..'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; test('emit event', () => { const wrapper = mount(SwitchCell); diff --git a/packages/switch/test/index.spec.js b/packages/switch/test/index.spec.js index 3d9e3095e..f164787b3 100644 --- a/packages/switch/test/index.spec.js +++ b/packages/switch/test/index.spec.js @@ -1,5 +1,5 @@ import Switch from '..'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; test('emit event', () => { const wrapper = mount(Switch); diff --git a/packages/tree-select/test/index.spec.js b/packages/tree-select/test/index.spec.js index d84c06e1c..edcd391c2 100644 --- a/packages/tree-select/test/index.spec.js +++ b/packages/tree-select/test/index.spec.js @@ -1,5 +1,5 @@ import TreeSelect from '../'; -import { mount } from '@vue/test-utils'; +import { mount } from '../../../test/utils'; test('empty list', () => { expect(mount(TreeSelect)).toMatchSnapshot(); diff --git a/packages/uploader/test/index.spec.js b/packages/uploader/test/index.spec.js index c25a26ffe..483d37d9a 100644 --- a/packages/uploader/test/index.spec.js +++ b/packages/uploader/test/index.spec.js @@ -1,6 +1,5 @@ import Uploader from '..'; -import { mount } from '@vue/test-utils'; -import { later } from '../../../test/utils'; +import { mount, later } from '../../../test/utils'; window.File = function() { this.size = 10000; diff --git a/test/utils.js b/test/utils.js index d801f8690..2d8417bab 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,5 +1,12 @@ import Vue from 'vue'; -import { TransitionStub } from '@vue/test-utils'; +import { mount, TransitionStub } from '@vue/test-utils'; + +// prevent vue warning log +Vue.config.silent = true; + +export { + mount +}; // Trigger pointer/touch event export function trigger(wrapper, eventName, x = 0, y = 0) { diff --git a/yarn.lock b/yarn.lock index bc7958bc8..11e2a252e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -137,15 +137,15 @@ source-map "^0.5.6" vue-template-es2015-compiler "^1.6.0" -"@vue/server-test-utils@^1.0.0-beta.16": - version "1.0.0-beta.16" - resolved "https://registry.yarnpkg.com/@vue/server-test-utils/-/server-test-utils-1.0.0-beta.16.tgz#6fee1d086171b5581321de54b21ed16ef464813f" +"@vue/server-test-utils@^1.0.0-beta.20": + version "1.0.0-beta.20" + resolved "https://registry.yarnpkg.com/@vue/server-test-utils/-/server-test-utils-1.0.0-beta.20.tgz#d71e3bacfc381a65b8c262a1787b1518b5017f35" dependencies: cheerio "^1.0.0-rc.2" -"@vue/test-utils@^1.0.0-beta.16": - version "1.0.0-beta.16" - resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-1.0.0-beta.16.tgz#dcf7a30304391422e382b5f97db6eb9508112906" +"@vue/test-utils@^1.0.0-beta.20": + version "1.0.0-beta.20" + resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-1.0.0-beta.20.tgz#ef4505341b802f3de1c06b3cb8651378c87371fa" dependencies: lodash "^4.17.4"