From aee1091c5cdf591227e1e1c3d2719b7c921d9bcf Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 13 Nov 2019 16:46:01 +0800 Subject: [PATCH] chore: adjust path of test utils (#4997) --- jest.config.js | 4 +-- src/action-sheet/test/demo.spec.js | 4 +-- src/action-sheet/test/index.spec.js | 2 +- src/address-edit/test/demo.spec.js | 4 +-- src/address-edit/test/index.spec.js | 2 +- src/address-list/test/demo.spec.js | 4 +-- src/address-list/test/index.spec.js | 2 +- src/area/test/demo.spec.js | 4 +-- src/area/test/index.spec.js | 2 +- src/button/test/demo.spec.js | 4 +-- src/button/test/index.spec.js | 2 +- src/card/test/demo.spec.js | 4 +-- src/card/test/index.spec.js | 2 +- src/cell/test/demo.spec.js | 4 +-- src/cell/test/index.spec.js | 2 +- src/checkbox/test/demo.spec.js | 4 +-- src/checkbox/test/index.spec.js | 2 +- src/circle/test/demo.spec.js | 4 +-- src/circle/test/index.spec.js | 2 +- src/col/test/demo.spec.js | 4 +-- src/col/test/index.spec.js | 2 +- src/collapse/test/demo.spec.js | 4 +-- src/collapse/test/index.spec.js | 2 +- src/contact-card/test/demo.spec.js | 4 +-- src/contact-card/test/index.spec.js | 2 +- src/count-down/test/index.spec.js | 2 +- src/coupon-list/test/demo.spec.js | 4 +-- src/coupon-list/test/index.spec.js | 2 +- src/datetime-picker/test/date-picker.spec.js | 2 +- .../test/datetime-picker.spec.js | 2 +- src/datetime-picker/test/demo.spec.js | 4 +-- src/datetime-picker/test/time-picker.spec.js | 2 +- src/dialog/test/demo.spec.js | 4 +-- src/dialog/test/index.spec.js | 2 +- src/divider/test/demo.spec.js | 4 +-- src/dropdown-menu/test/demo.spec.js | 4 +-- src/dropdown-menu/test/index.spec.js | 2 +- src/field/test/demo.spec.js | 4 +-- src/field/test/index.spec.js | 2 +- src/goods-action/test/demo.spec.js | 4 +-- src/goods-action/test/index.spec.js | 2 +- src/grid/test/demo.spec.js | 4 +-- src/grid/test/index.spec.js | 2 +- src/icon/test/index.spec.js | 2 +- src/image-preview/test/index.spec.js | 2 +- src/image/test/demo.spec.js | 4 +-- src/image/test/index.spec.js | 2 +- src/index-bar/test/demo.spec.js | 4 +-- src/index-bar/test/index.spec.js | 2 +- src/info/test/index.spec.js | 2 +- src/list/test/demo.spec.js | 4 +-- src/list/test/index.spec.js | 2 +- src/loading/test/demo.spec.js | 4 +-- src/loading/test/index.spec.js | 2 +- src/nav-bar/test/demo.spec.js | 4 +-- src/nav-bar/test/index.spec.js | 2 +- src/notice-bar/test/demo.spec.js | 4 +-- src/notice-bar/test/index.spec.js | 2 +- src/notify/test/demo.spec.js | 4 +-- src/notify/test/index.spec.js | 2 +- src/number-keyboard/test/demo.spec.js | 4 +-- src/number-keyboard/test/index.spec.js | 2 +- src/overlay/test/demo.spec.js | 4 +-- src/overlay/test/index.spec.js | 2 +- src/pagination/test/demo.spec.js | 4 +-- src/panel/test/demo.spec.js | 4 +-- src/password-input/test/demo.spec.js | 4 +-- src/password-input/test/index.spec.js | 2 +- src/picker/test/demo.spec.js | 4 +-- src/picker/test/index.spec.js | 2 +- src/popup/test/demo.spec.js | 4 +-- src/popup/test/index.spec.js | 2 +- src/progress/test/demo.spec.js | 4 +-- src/progress/test/index.spec.js | 2 +- src/pull-refresh/test/demo.spec.js | 4 +-- src/pull-refresh/test/index.spec.js | 2 +- src/radio/test/demo.spec.js | 4 +-- src/radio/test/index.spec.js | 2 +- src/rate/test/demo.spec.js | 4 +-- src/rate/test/index.spec.js | 2 +- src/search/test/demo.spec.js | 4 +-- src/search/test/index.spec.js | 2 +- src/sidebar/test/demo.spec.js | 4 +-- src/sidebar/test/index.spec.js | 2 +- src/skeleton/test/demo.spec.js | 4 +-- src/skeleton/test/index.spec.js | 2 +- src/sku/test/demo.spec.js | 4 +-- src/slider/test/demo.spec.js | 4 +-- src/slider/test/index.spec.js | 2 +- src/stepper/test/demo.spec.js | 4 +-- src/stepper/test/index.spec.js | 2 +- src/steps/test/demo.spec.js | 4 +-- src/steps/test/index.spec.js | 2 +- src/sticky/test/demo.spec.js | 4 +-- src/sticky/test/index.spec.js | 2 +- src/submit-bar/test/demo.spec.js | 4 +-- src/submit-bar/test/index.spec.js | 2 +- src/swipe-cell/test/demo.spec.js | 4 +-- src/swipe-cell/test/index.spec.js | 2 +- src/swipe/test/demo.spec.js | 10 +++--- src/swipe/test/index.spec.js | 2 +- src/switch-cell/test/demo.spec.js | 4 +-- src/switch-cell/test/index.spec.js | 2 +- src/switch/test/demo.spec.js | 4 +-- src/switch/test/index.spec.js | 2 +- src/tab/test/demo.spec.js | 4 +-- src/tab/test/index.spec.js | 2 +- src/tabbar/test/demo.spec.js | 4 +-- src/tabbar/test/index.spec.js | 2 +- src/tag/test/demo.spec.js | 4 +-- src/tag/test/index.spec.js | 2 +- src/toast/test/demo.spec.js | 4 +-- src/toast/test/index.spec.js | 2 +- src/tree-select/test/demo.spec.js | 4 +-- src/tree-select/test/index.spec.js | 2 +- src/uploader/test/demo.spec.js | 4 +-- src/uploader/test/index.spec.js | 2 +- src/utils/test/index.spec.js | 2 +- test/demo-test.ts | 36 ------------------- test/demo.ts | 36 +++++++++++++++++++ test/{utils => }/dom.ts | 6 ++-- test/{utils => }/event.ts | 0 test/{utils => }/index.ts | 15 ++++++-- test/{jest.transform.js => transformer.js} | 0 test/{utils => }/transition.ts | 0 125 files changed, 231 insertions(+), 220 deletions(-) delete mode 100644 test/demo-test.ts create mode 100644 test/demo.ts rename test/{utils => }/dom.ts (90%) rename test/{utils => }/event.ts (100%) rename test/{utils => }/index.ts (52%) rename test/{jest.transform.js => transformer.js} (100%) rename test/{utils => }/transition.ts (100%) diff --git a/jest.config.js b/jest.config.js index 4c3354605..1b2a2b04d 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,9 +2,9 @@ module.exports = { moduleFileExtensions: ['js', 'jsx', 'vue', 'ts', 'tsx'], transform: { '\\.(vue)$': 'vue-jest', - '\\.(js|jsx|ts|tsx)$': '/test/jest.transform.js', + '\\.(js|jsx|ts|tsx)$': '/test/transformer.js', }, - snapshotSerializers: ['/node_modules/jest-serializer-vue'], + snapshotSerializers: ['jest-serializer-vue'], collectCoverageFrom: [ 'src/**/*.{js,jsx,ts,tsx,vue}', '!**/style/**', diff --git a/src/action-sheet/test/demo.spec.js b/src/action-sheet/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/action-sheet/test/demo.spec.js +++ b/src/action-sheet/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/action-sheet/test/index.spec.js b/src/action-sheet/test/index.spec.js index 1a1803386..8fe5bb2af 100644 --- a/src/action-sheet/test/index.spec.js +++ b/src/action-sheet/test/index.spec.js @@ -1,4 +1,4 @@ -import { mount, later } from '../../../test/utils'; +import { mount, later } from '../../../test'; import ActionSheet from '..'; test('callback events', () => { diff --git a/src/address-edit/test/demo.spec.js b/src/address-edit/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/address-edit/test/demo.spec.js +++ b/src/address-edit/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/address-edit/test/index.spec.js b/src/address-edit/test/index.spec.js index c03e2cf97..80325de03 100644 --- a/src/address-edit/test/index.spec.js +++ b/src/address-edit/test/index.spec.js @@ -1,6 +1,6 @@ import AddressEdit from '..'; import areaList from '../../area/demo/area.simple'; -import { mount, later } from '../../../test/utils'; +import { mount, later } from '../../../test'; const addressInfo = { name: '测试', diff --git a/src/address-list/test/demo.spec.js b/src/address-list/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/address-list/test/demo.spec.js +++ b/src/address-list/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/address-list/test/index.spec.js b/src/address-list/test/index.spec.js index 6e5a163ab..c4ed57d4b 100644 --- a/src/address-list/test/index.spec.js +++ b/src/address-list/test/index.spec.js @@ -1,4 +1,4 @@ -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; import AddressList from '..'; const list = [ diff --git a/src/area/test/demo.spec.js b/src/area/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/area/test/demo.spec.js +++ b/src/area/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/area/test/index.spec.js b/src/area/test/index.spec.js index 7df588f3a..90baed817 100644 --- a/src/area/test/index.spec.js +++ b/src/area/test/index.spec.js @@ -1,6 +1,6 @@ import Area from '..'; import areaList from '../demo/area.simple'; -import { mount, later, triggerDrag } from '../../../test/utils'; +import { mount, later, triggerDrag } from '../../../test'; const firstOption = [ { code: '110000', name: '北京市' }, diff --git a/src/button/test/demo.spec.js b/src/button/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/button/test/demo.spec.js +++ b/src/button/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/button/test/index.spec.js b/src/button/test/index.spec.js index 65ed46b18..0039635b9 100644 --- a/src/button/test/index.spec.js +++ b/src/button/test/index.spec.js @@ -1,4 +1,4 @@ -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; import Button from '..'; test('loading size', () => { diff --git a/src/card/test/demo.spec.js b/src/card/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/card/test/demo.spec.js +++ b/src/card/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/card/test/index.spec.js b/src/card/test/index.spec.js index c0c7cc3b8..bbcea88cb 100644 --- a/src/card/test/index.spec.js +++ b/src/card/test/index.spec.js @@ -1,5 +1,5 @@ import Card from '..'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('click event', () => { const onClick = jest.fn(); diff --git a/src/cell/test/demo.spec.js b/src/cell/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/cell/test/demo.spec.js +++ b/src/cell/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/cell/test/index.spec.js b/src/cell/test/index.spec.js index b049d184c..88152ceb8 100644 --- a/src/cell/test/index.spec.js +++ b/src/cell/test/index.spec.js @@ -1,6 +1,6 @@ import Cell from '..'; import CellGroup from '../../cell-group'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('click event', () => { const click = jest.fn(); diff --git a/src/checkbox/test/demo.spec.js b/src/checkbox/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/checkbox/test/demo.spec.js +++ b/src/checkbox/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/checkbox/test/index.spec.js b/src/checkbox/test/index.spec.js index 0b81c4d3d..6150064b9 100644 --- a/src/checkbox/test/index.spec.js +++ b/src/checkbox/test/index.spec.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import Checkbox from '..'; import CheckboxGroup from '../../checkbox-group'; -import { mount, later } from '../../../test/utils'; +import { mount, later } from '../../../test'; Vue.use(Checkbox); Vue.use(CheckboxGroup); diff --git a/src/circle/test/demo.spec.js b/src/circle/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/circle/test/demo.spec.js +++ b/src/circle/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/circle/test/index.spec.js b/src/circle/test/index.spec.js index ca918a97d..2d37e250f 100644 --- a/src/circle/test/index.spec.js +++ b/src/circle/test/index.spec.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import Circle from '..'; -import { mount, later } from '../../../test/utils'; +import { mount, later } from '../../../test'; test('speed is 0', async () => { const wrapper = mount(Circle, { diff --git a/src/col/test/demo.spec.js b/src/col/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/col/test/demo.spec.js +++ b/src/col/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/col/test/index.spec.js b/src/col/test/index.spec.js index bc0b8a57e..aa6bce612 100644 --- a/src/col/test/index.spec.js +++ b/src/col/test/index.spec.js @@ -1,6 +1,6 @@ import Col from '..'; import Row from '../../row'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('Col click event', () => { const wrapper = mount(Col); diff --git a/src/collapse/test/demo.spec.js b/src/collapse/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/collapse/test/demo.spec.js +++ b/src/collapse/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/collapse/test/index.spec.js b/src/collapse/test/index.spec.js index 72bead829..0e092a9b3 100644 --- a/src/collapse/test/index.spec.js +++ b/src/collapse/test/index.spec.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import Collapse from '..'; import CollapseItem from '../../collapse-item'; -import { later, mount } from '../../../test/utils'; +import { later, mount } from '../../../test'; Vue.use(Collapse); Vue.use(CollapseItem); diff --git a/src/contact-card/test/demo.spec.js b/src/contact-card/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/contact-card/test/demo.spec.js +++ b/src/contact-card/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/contact-card/test/index.spec.js b/src/contact-card/test/index.spec.js index 81802cd43..91bd01001 100644 --- a/src/contact-card/test/index.spec.js +++ b/src/contact-card/test/index.spec.js @@ -1,7 +1,7 @@ import ContactCard from '..'; import ContactList from '../../contact-list'; import ContactEdit from '../../contact-edit'; -import { mount, later } from '../../../test/utils'; +import { mount, later } from '../../../test'; const contactInfo = { name: 'test', diff --git a/src/count-down/test/index.spec.js b/src/count-down/test/index.spec.js index 28c3be1a3..0f014f086 100644 --- a/src/count-down/test/index.spec.js +++ b/src/count-down/test/index.spec.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import CountDown from '..'; -import { mount, later } from '../../../test/utils'; +import { mount, later } from '../../../test'; Vue.use(CountDown); diff --git a/src/coupon-list/test/demo.spec.js b/src/coupon-list/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/coupon-list/test/demo.spec.js +++ b/src/coupon-list/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/coupon-list/test/index.spec.js b/src/coupon-list/test/index.spec.js index 4b19b3253..c27cf80da 100644 --- a/src/coupon-list/test/index.spec.js +++ b/src/coupon-list/test/index.spec.js @@ -1,7 +1,7 @@ import Coupon from '../../coupon'; import CouponList from '..'; import CouponCell from '../../coupon-cell'; -import { later, mount } from '../../../test/utils'; +import { later, mount } from '../../../test'; const coupon = { id: 1, diff --git a/src/datetime-picker/test/date-picker.spec.js b/src/datetime-picker/test/date-picker.spec.js index 633508e9e..b0a94dc4b 100644 --- a/src/datetime-picker/test/date-picker.spec.js +++ b/src/datetime-picker/test/date-picker.spec.js @@ -1,5 +1,5 @@ import DatePicker from '../DatePicker'; -import { mount, later, triggerDrag } from '../../../test/utils'; +import { mount, later, triggerDrag } from '../../../test'; function filter(type, options) { const mod = type === 'year' ? 10 : 5; diff --git a/src/datetime-picker/test/datetime-picker.spec.js b/src/datetime-picker/test/datetime-picker.spec.js index c12ed7666..f8083d6a9 100644 --- a/src/datetime-picker/test/datetime-picker.spec.js +++ b/src/datetime-picker/test/datetime-picker.spec.js @@ -1,5 +1,5 @@ import DatetimePicker from '..'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('confirm & cancel event', () => { const onConfirm = jest.fn(); diff --git a/src/datetime-picker/test/demo.spec.js b/src/datetime-picker/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/datetime-picker/test/demo.spec.js +++ b/src/datetime-picker/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/datetime-picker/test/time-picker.spec.js b/src/datetime-picker/test/time-picker.spec.js index 95c090077..596f8099e 100644 --- a/src/datetime-picker/test/time-picker.spec.js +++ b/src/datetime-picker/test/time-picker.spec.js @@ -1,5 +1,5 @@ import TimePicker from '../TimePicker'; -import { mount, later, triggerDrag } from '../../../test/utils'; +import { mount, later, triggerDrag } from '../../../test'; function filter(type, options) { const mod = type === 'minute' ? 10 : 5; diff --git a/src/dialog/test/demo.spec.js b/src/dialog/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/dialog/test/demo.spec.js +++ b/src/dialog/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/dialog/test/index.spec.js b/src/dialog/test/index.spec.js index 91b5dfb18..552192a29 100644 --- a/src/dialog/test/index.spec.js +++ b/src/dialog/test/index.spec.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import Dialog from '..'; import DialogComponent from '../Dialog'; -import { mount, later, trigger } from '../../../test/utils'; +import { mount, later, trigger } from '../../../test'; test('Dialog function call', async () => { Dialog.close(); diff --git a/src/divider/test/demo.spec.js b/src/divider/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/divider/test/demo.spec.js +++ b/src/divider/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/dropdown-menu/test/demo.spec.js b/src/dropdown-menu/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/dropdown-menu/test/demo.spec.js +++ b/src/dropdown-menu/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/dropdown-menu/test/index.spec.js b/src/dropdown-menu/test/index.spec.js index 61bdfdf98..9f6a60368 100644 --- a/src/dropdown-menu/test/index.spec.js +++ b/src/dropdown-menu/test/index.spec.js @@ -1,4 +1,4 @@ -import { mount, later } from '../../../test/utils'; +import { mount, later } from '../../../test'; import Vue from 'vue'; import DropdownMenu from '..'; import DropdownItem from '../../dropdown-item'; diff --git a/src/field/test/demo.spec.js b/src/field/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/field/test/demo.spec.js +++ b/src/field/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/field/test/index.spec.js b/src/field/test/index.spec.js index 77f4107ab..75d91f6eb 100644 --- a/src/field/test/index.spec.js +++ b/src/field/test/index.spec.js @@ -1,5 +1,5 @@ import Field from '..'; -import { mount, later } from '../../../test/utils'; +import { mount, later } from '../../../test'; test('input event', () => { const wrapper = mount(Field); diff --git a/src/goods-action/test/demo.spec.js b/src/goods-action/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/goods-action/test/demo.spec.js +++ b/src/goods-action/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/goods-action/test/index.spec.js b/src/goods-action/test/index.spec.js index 20ff21ec5..7780cf2db 100644 --- a/src/goods-action/test/index.spec.js +++ b/src/goods-action/test/index.spec.js @@ -1,6 +1,6 @@ import Button from '../../goods-action-button'; import Icon from '../../goods-action-icon'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('Button click event', () => { const wrapper = mount(Button); diff --git a/src/grid/test/demo.spec.js b/src/grid/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/grid/test/demo.spec.js +++ b/src/grid/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/grid/test/index.spec.js b/src/grid/test/index.spec.js index 00375db15..1fc484ff3 100644 --- a/src/grid/test/index.spec.js +++ b/src/grid/test/index.spec.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import Grid from '..'; import GridItem from '../../grid-item'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; Vue.use(Grid); Vue.use(GridItem); diff --git a/src/icon/test/index.spec.js b/src/icon/test/index.spec.js index 8d764a0b9..6d52493c2 100644 --- a/src/icon/test/index.spec.js +++ b/src/icon/test/index.spec.js @@ -1,5 +1,5 @@ import Icon from '..'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('render icon with builtin icon name', () => { const wrapper = mount(Icon, { diff --git a/src/image-preview/test/index.spec.js b/src/image-preview/test/index.spec.js index 48518429c..727970b0c 100644 --- a/src/image-preview/test/index.spec.js +++ b/src/image-preview/test/index.spec.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import ImagePreview from '..'; import ImagePreviewVue from '../ImagePreview'; -import { mount, trigger, triggerDrag, later } from '../../../test/utils'; +import { mount, trigger, triggerDrag, later } from '../../../test'; function triggerZoom(el, x, y) { trigger(el, 'touchstart', 0, 0, { x, y }); diff --git a/src/image/test/demo.spec.js b/src/image/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/image/test/demo.spec.js +++ b/src/image/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/image/test/index.spec.js b/src/image/test/index.spec.js index 1a54b2f06..a4beca8e9 100644 --- a/src/image/test/index.spec.js +++ b/src/image/test/index.spec.js @@ -1,5 +1,5 @@ -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; import Image from '..'; test('click event', () => { diff --git a/src/index-bar/test/demo.spec.js b/src/index-bar/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/index-bar/test/demo.spec.js +++ b/src/index-bar/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/index-bar/test/index.spec.js b/src/index-bar/test/index.spec.js index dde3fddf9..e7036862a 100644 --- a/src/index-bar/test/index.spec.js +++ b/src/index-bar/test/index.spec.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import IndexBar from '..'; import IndexAnchor from '../../index-anchor'; -import { mount, trigger, triggerDrag } from '../../../test/utils'; +import { mount, trigger, triggerDrag } from '../../../test'; Vue.use(IndexBar); Vue.use(IndexAnchor); diff --git a/src/info/test/index.spec.js b/src/info/test/index.spec.js index e7d35db2c..e18f83032 100644 --- a/src/info/test/index.spec.js +++ b/src/info/test/index.spec.js @@ -1,5 +1,5 @@ import Info from '..'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('should not render when info is empty string', () => { const wrapper = mount(Info, { diff --git a/src/list/test/demo.spec.js b/src/list/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/list/test/demo.spec.js +++ b/src/list/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/list/test/index.spec.js b/src/list/test/index.spec.js index 8a709bfec..14a9e584e 100644 --- a/src/list/test/index.spec.js +++ b/src/list/test/index.spec.js @@ -1,5 +1,5 @@ import List from '..'; -import { mount, later, mockGetBoundingClientRect } from '../../../test/utils'; +import { mount, later, mockGetBoundingClientRect } from '../../../test'; test('load event', async () => { const wrapper = mount(List); diff --git a/src/loading/test/demo.spec.js b/src/loading/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/loading/test/demo.spec.js +++ b/src/loading/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/loading/test/index.spec.js b/src/loading/test/index.spec.js index 8f9d385e7..aee3f2e9f 100644 --- a/src/loading/test/index.spec.js +++ b/src/loading/test/index.spec.js @@ -1,4 +1,4 @@ -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; import Loading from '..'; test('size prop', () => { diff --git a/src/nav-bar/test/demo.spec.js b/src/nav-bar/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/nav-bar/test/demo.spec.js +++ b/src/nav-bar/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/nav-bar/test/index.spec.js b/src/nav-bar/test/index.spec.js index 12ce9cbe2..79238f704 100644 --- a/src/nav-bar/test/index.spec.js +++ b/src/nav-bar/test/index.spec.js @@ -1,5 +1,5 @@ import NavBar from '..'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('render left & right slot', () => { const wrapper = mount(NavBar, { diff --git a/src/notice-bar/test/demo.spec.js b/src/notice-bar/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/notice-bar/test/demo.spec.js +++ b/src/notice-bar/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/notice-bar/test/index.spec.js b/src/notice-bar/test/index.spec.js index 8c5a680f1..83d835faa 100644 --- a/src/notice-bar/test/index.spec.js +++ b/src/notice-bar/test/index.spec.js @@ -1,5 +1,5 @@ import NoticeBar from '..'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('click event', () => { const wrapper = mount(NoticeBar); diff --git a/src/notify/test/demo.spec.js b/src/notify/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/notify/test/demo.spec.js +++ b/src/notify/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/notify/test/index.spec.js b/src/notify/test/index.spec.js index 424f86d62..61a2b61a3 100644 --- a/src/notify/test/index.spec.js +++ b/src/notify/test/index.spec.js @@ -1,5 +1,5 @@ import Notify from '..'; -import { later } from '../../../test/utils'; +import { later } from '../../../test'; test('create a notify', async () => { // should not cause error when call clear before show notify diff --git a/src/number-keyboard/test/demo.spec.js b/src/number-keyboard/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/number-keyboard/test/demo.spec.js +++ b/src/number-keyboard/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/number-keyboard/test/index.spec.js b/src/number-keyboard/test/index.spec.js index ca78a5f11..0ae82b946 100644 --- a/src/number-keyboard/test/index.spec.js +++ b/src/number-keyboard/test/index.spec.js @@ -1,5 +1,5 @@ import NumberKeyboard from '..'; -import { mount, trigger } from '../../../test/utils'; +import { mount, trigger } from '../../../test'; function clickKey(key) { trigger(key, 'touchstart'); diff --git a/src/overlay/test/demo.spec.js b/src/overlay/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/overlay/test/demo.spec.js +++ b/src/overlay/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/overlay/test/index.spec.js b/src/overlay/test/index.spec.js index 0d4094a66..2aca57e78 100644 --- a/src/overlay/test/index.spec.js +++ b/src/overlay/test/index.spec.js @@ -1,4 +1,4 @@ -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; import Overlay from '..'; test('z-index prop', () => { diff --git a/src/pagination/test/demo.spec.js b/src/pagination/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/pagination/test/demo.spec.js +++ b/src/pagination/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/panel/test/demo.spec.js b/src/panel/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/panel/test/demo.spec.js +++ b/src/panel/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/password-input/test/demo.spec.js b/src/password-input/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/password-input/test/demo.spec.js +++ b/src/password-input/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/password-input/test/index.spec.js b/src/password-input/test/index.spec.js index 759caebac..d9a4825dc 100644 --- a/src/password-input/test/index.spec.js +++ b/src/password-input/test/index.spec.js @@ -1,5 +1,5 @@ import PasswordInput from '..'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('focus event', () => { const focus = jest.fn(); diff --git a/src/picker/test/demo.spec.js b/src/picker/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/picker/test/demo.spec.js +++ b/src/picker/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/picker/test/index.spec.js b/src/picker/test/index.spec.js index f64af7145..86036ba37 100644 --- a/src/picker/test/index.spec.js +++ b/src/picker/test/index.spec.js @@ -1,6 +1,6 @@ import Picker from '..'; import PickerColumn from '../PickerColumn'; -import { mount, triggerDrag, later } from '../../../test/utils'; +import { mount, triggerDrag, later } from '../../../test'; const simpleColumn = ['1990', '1991', '1992', '1993', '1994', '1995']; const columns = [ diff --git a/src/popup/test/demo.spec.js b/src/popup/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/popup/test/demo.spec.js +++ b/src/popup/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/popup/test/index.spec.js b/src/popup/test/index.spec.js index a5879e9e8..14db2aad9 100644 --- a/src/popup/test/index.spec.js +++ b/src/popup/test/index.spec.js @@ -1,5 +1,5 @@ import Popup from '..'; -import { mount, triggerDrag, later } from '../../../test/utils'; +import { mount, triggerDrag, later } from '../../../test'; let wrapper; afterEach(() => { diff --git a/src/progress/test/demo.spec.js b/src/progress/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/progress/test/demo.spec.js +++ b/src/progress/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/progress/test/index.spec.js b/src/progress/test/index.spec.js index 6ea8431b5..c2b5b6c86 100644 --- a/src/progress/test/index.spec.js +++ b/src/progress/test/index.spec.js @@ -1,5 +1,5 @@ import Progress from '..'; -import { mount, later } from '../../../test/utils'; +import { mount, later } from '../../../test'; test('calc width', async () => { const wrapper = mount(Progress, { diff --git a/src/pull-refresh/test/demo.spec.js b/src/pull-refresh/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/pull-refresh/test/demo.spec.js +++ b/src/pull-refresh/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/pull-refresh/test/index.spec.js b/src/pull-refresh/test/index.spec.js index 7c37a9994..0356e9863 100644 --- a/src/pull-refresh/test/index.spec.js +++ b/src/pull-refresh/test/index.spec.js @@ -1,5 +1,5 @@ import PullRefresh from '..'; -import { mount, later, trigger, triggerDrag } from '../../../test/utils'; +import { mount, later, trigger, triggerDrag } from '../../../test'; test('change head content when pulling down', async () => { const wrapper = mount(PullRefresh, { diff --git a/src/radio/test/demo.spec.js b/src/radio/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/radio/test/demo.spec.js +++ b/src/radio/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/radio/test/index.spec.js b/src/radio/test/index.spec.js index ce837fabe..adc6147fd 100644 --- a/src/radio/test/index.spec.js +++ b/src/radio/test/index.spec.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import Radio from '..'; import RadioGroup from '../../radio-group'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; Vue.use(Radio); Vue.use(RadioGroup); diff --git a/src/rate/test/demo.spec.js b/src/rate/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/rate/test/demo.spec.js +++ b/src/rate/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/rate/test/index.spec.js b/src/rate/test/index.spec.js index 9b20ca337..8203dcf52 100644 --- a/src/rate/test/index.spec.js +++ b/src/rate/test/index.spec.js @@ -1,5 +1,5 @@ import Rate from '..'; -import { mount, triggerDrag } from '../../../test/utils'; +import { mount, triggerDrag } from '../../../test'; function mockGetBoundingClientRect(items) { items.filter((icon, index) => { diff --git a/src/search/test/demo.spec.js b/src/search/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/search/test/demo.spec.js +++ b/src/search/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/search/test/index.spec.js b/src/search/test/index.spec.js index 884cabe4c..fa5bb4eb4 100644 --- a/src/search/test/index.spec.js +++ b/src/search/test/index.spec.js @@ -1,5 +1,5 @@ import Search from '..'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('input event', () => { const onInput = jest.fn(); diff --git a/src/sidebar/test/demo.spec.js b/src/sidebar/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/sidebar/test/demo.spec.js +++ b/src/sidebar/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/sidebar/test/index.spec.js b/src/sidebar/test/index.spec.js index 64dfb44f9..b65d50a16 100644 --- a/src/sidebar/test/index.spec.js +++ b/src/sidebar/test/index.spec.js @@ -1,4 +1,4 @@ -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; import Vue from 'vue'; import Sidebar from '..'; import SidebarItem from '../../sidebar-item'; diff --git a/src/skeleton/test/demo.spec.js b/src/skeleton/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/skeleton/test/demo.spec.js +++ b/src/skeleton/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/skeleton/test/index.spec.js b/src/skeleton/test/index.spec.js index dd3790a1f..81d3ccb12 100644 --- a/src/skeleton/test/index.spec.js +++ b/src/skeleton/test/index.spec.js @@ -1,4 +1,4 @@ -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; import Skeleton from '..'; test('row-width array', () => { diff --git a/src/sku/test/demo.spec.js b/src/sku/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/sku/test/demo.spec.js +++ b/src/sku/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/slider/test/demo.spec.js b/src/slider/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/slider/test/demo.spec.js +++ b/src/slider/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/slider/test/index.spec.js b/src/slider/test/index.spec.js index 47c021328..b83d9563f 100644 --- a/src/slider/test/index.spec.js +++ b/src/slider/test/index.spec.js @@ -4,7 +4,7 @@ import { trigger, triggerDrag, mockGetBoundingClientRect -} from '../../../test/utils'; +} from '../../../test'; function mockRect(vertical) { return mockGetBoundingClientRect({ diff --git a/src/stepper/test/demo.spec.js b/src/stepper/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/stepper/test/demo.spec.js +++ b/src/stepper/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/stepper/test/index.spec.js b/src/stepper/test/index.spec.js index 4205a0370..a5a2deff2 100644 --- a/src/stepper/test/index.spec.js +++ b/src/stepper/test/index.spec.js @@ -1,5 +1,5 @@ import Stepper from '..'; -import { mount, later } from '../../../test/utils'; +import { mount, later } from '../../../test'; test('disabled stepper', () => { const wrapper = mount(Stepper, { diff --git a/src/steps/test/demo.spec.js b/src/steps/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/steps/test/demo.spec.js +++ b/src/steps/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/steps/test/index.spec.js b/src/steps/test/index.spec.js index 748a6ed56..ba568f6cc 100644 --- a/src/steps/test/index.spec.js +++ b/src/steps/test/index.spec.js @@ -1,4 +1,4 @@ -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; import Steps from '..'; import Step from '../../step'; diff --git a/src/sticky/test/demo.spec.js b/src/sticky/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/sticky/test/demo.spec.js +++ b/src/sticky/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/sticky/test/index.spec.js b/src/sticky/test/index.spec.js index a59689042..870a7f758 100644 --- a/src/sticky/test/index.spec.js +++ b/src/sticky/test/index.spec.js @@ -1,4 +1,4 @@ -import { mount, mockScrollTop } from '../../../test/utils'; +import { mount, mockScrollTop } from '../../../test'; import Vue from 'vue'; import Sticky from '..'; diff --git a/src/submit-bar/test/demo.spec.js b/src/submit-bar/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/submit-bar/test/demo.spec.js +++ b/src/submit-bar/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/submit-bar/test/index.spec.js b/src/submit-bar/test/index.spec.js index 410416268..12832b105 100644 --- a/src/submit-bar/test/index.spec.js +++ b/src/submit-bar/test/index.spec.js @@ -1,5 +1,5 @@ import SubmitBar from '..'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('submit event', () => { const submit = jest.fn(); diff --git a/src/swipe-cell/test/demo.spec.js b/src/swipe-cell/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/swipe-cell/test/demo.spec.js +++ b/src/swipe-cell/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/swipe-cell/test/index.spec.js b/src/swipe-cell/test/index.spec.js index c95c4dd65..f1af38b43 100644 --- a/src/swipe-cell/test/index.spec.js +++ b/src/swipe-cell/test/index.spec.js @@ -4,7 +4,7 @@ import { triggerDrag, later, mockGetBoundingClientRect -} from '../../../test/utils'; +} from '../../../test'; const THRESHOLD = 0.15; const defaultProps = { diff --git a/src/swipe/test/demo.spec.js b/src/swipe/test/demo.spec.js index b9b0acf0f..2f2861f24 100644 --- a/src/swipe/test/demo.spec.js +++ b/src/swipe/test/demo.spec.js @@ -1,17 +1,17 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; -import { mockGetBoundingClientRect } from '../../../test/utils'; +import { snapshotDemo } from '../../../test/demo'; +import { mockGetBoundingClientRect } from '../../../test'; let restore; -demoTest(Demo, { - hookBeforeTest: () => { +snapshotDemo(Demo, { + beforeTest: () => { restore = mockGetBoundingClientRect({ width: 100, height: 100 }); }, - hookAfterTest: () => { + afterTest: () => { restore(); } }); diff --git a/src/swipe/test/index.spec.js b/src/swipe/test/index.spec.js index e69133e89..68b2d28cb 100644 --- a/src/swipe/test/index.spec.js +++ b/src/swipe/test/index.spec.js @@ -1,6 +1,6 @@ import Swipe from '..'; import SwipeItem from '../../swipe-item'; -import { mount, triggerDrag, later } from '../../../test/utils'; +import { mount, triggerDrag, later } from '../../../test'; const Component = { template: ` diff --git a/src/switch-cell/test/demo.spec.js b/src/switch-cell/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/switch-cell/test/demo.spec.js +++ b/src/switch-cell/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/switch-cell/test/index.spec.js b/src/switch-cell/test/index.spec.js index 9a066e0c0..97a4c39c8 100644 --- a/src/switch-cell/test/index.spec.js +++ b/src/switch-cell/test/index.spec.js @@ -1,5 +1,5 @@ import SwitchCell from '..'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('change event', () => { const onChange = jest.fn(); diff --git a/src/switch/test/demo.spec.js b/src/switch/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/switch/test/demo.spec.js +++ b/src/switch/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/switch/test/index.spec.js b/src/switch/test/index.spec.js index ab816297b..d54d20c9c 100644 --- a/src/switch/test/index.spec.js +++ b/src/switch/test/index.spec.js @@ -1,5 +1,5 @@ import Switch from '..'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('emit event', () => { const input = jest.fn(); diff --git a/src/tab/test/demo.spec.js b/src/tab/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/tab/test/demo.spec.js +++ b/src/tab/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/tab/test/index.spec.js b/src/tab/test/index.spec.js index 659740884..9bac4bede 100644 --- a/src/tab/test/index.spec.js +++ b/src/tab/test/index.spec.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import Tab from '..'; import Tabs from '../../tabs'; -import { mount, later, triggerDrag } from '../../../test/utils'; +import { mount, later, triggerDrag } from '../../../test'; Vue.use(Tab); Vue.use(Tabs); diff --git a/src/tabbar/test/demo.spec.js b/src/tabbar/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/tabbar/test/demo.spec.js +++ b/src/tabbar/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/tabbar/test/index.spec.js b/src/tabbar/test/index.spec.js index 921031a4e..b2ca61d0c 100644 --- a/src/tabbar/test/index.spec.js +++ b/src/tabbar/test/index.spec.js @@ -1,5 +1,5 @@ import VueRouter from 'vue-router'; -import { mount, later } from '../../../test/utils'; +import { mount, later } from '../../../test'; import Vue from 'vue'; import Tabbar from '..'; import TabbarItem from '../../tabbar-item'; diff --git a/src/tag/test/demo.spec.js b/src/tag/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/tag/test/demo.spec.js +++ b/src/tag/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/tag/test/index.spec.js b/src/tag/test/index.spec.js index 2da20703c..2fff16cbd 100644 --- a/src/tag/test/index.spec.js +++ b/src/tag/test/index.spec.js @@ -1,5 +1,5 @@ import Tag from '..'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; test('click event', () => { const click = jest.fn(); diff --git a/src/toast/test/demo.spec.js b/src/toast/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/toast/test/demo.spec.js +++ b/src/toast/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/toast/test/index.spec.js b/src/toast/test/index.spec.js index 62164d354..ae05aa072 100644 --- a/src/toast/test/index.spec.js +++ b/src/toast/test/index.spec.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import Toast from '..'; import ToastVue from '../Toast'; -import { later } from '../../../test/utils'; +import { later } from '../../../test'; test('create a forbidClick toast', async () => { const toast = Toast({ diff --git a/src/tree-select/test/demo.spec.js b/src/tree-select/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/tree-select/test/demo.spec.js +++ b/src/tree-select/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/tree-select/test/index.spec.js b/src/tree-select/test/index.spec.js index aa5fd9b35..47b25fc7d 100644 --- a/src/tree-select/test/index.spec.js +++ b/src/tree-select/test/index.spec.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import TreeSelect from '..'; -import { mount } from '../../../test/utils'; +import { mount } from '../../../test'; Vue.use(TreeSelect); diff --git a/src/uploader/test/demo.spec.js b/src/uploader/test/demo.spec.js index d647cfabc..5c70922b5 100644 --- a/src/uploader/test/demo.spec.js +++ b/src/uploader/test/demo.spec.js @@ -1,4 +1,4 @@ import Demo from '../demo'; -import demoTest from '../../../test/demo-test'; +import { snapshotDemo } from '../../../test/demo'; -demoTest(Demo); +snapshotDemo(Demo); diff --git a/src/uploader/test/index.spec.js b/src/uploader/test/index.spec.js index 54db702d9..1af2068b1 100644 --- a/src/uploader/test/index.spec.js +++ b/src/uploader/test/index.spec.js @@ -1,5 +1,5 @@ import Uploader from '..'; -import { mount, later, triggerDrag } from '../../../test/utils'; +import { mount, later, triggerDrag } from '../../../test'; window.File = function() { this.size = 10000; diff --git a/src/utils/test/index.spec.js b/src/utils/test/index.spec.js index 0eb331a0a..28d603b26 100644 --- a/src/utils/test/index.spec.js +++ b/src/utils/test/index.spec.js @@ -2,7 +2,7 @@ import { deepClone } from '../deep-clone'; import { deepAssign } from '../deep-assign'; import { isDef, get } from '..'; import { raf, cancelRaf } from '../dom/raf'; -import { later } from '../../../test/utils'; +import { later } from '../../../test'; import { isEmail } from '../validate/email'; import { isMobile } from '../validate/mobile'; import { isNumber } from '../validate/number'; diff --git a/test/demo-test.ts b/test/demo-test.ts deleted file mode 100644 index 7ee41d531..000000000 --- a/test/demo-test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import Vue from 'vue'; -import '../docs/site/mobile/demo-common'; -import Locale from '../src/locale'; -import { mount, later } from './utils'; - -const empty = { - render(h) { - return h('div', [this.$slots.default]); - }, - inheritAttrs: false -}; - -Vue.component('demo-block', empty); -Vue.component('demo-section', empty); - -export default function (Demo: any, option: any = {}) { - test('renders demo correctly', async () => { - if (option.hookBeforeTest) { - option.hookBeforeTest(); - } - - if (Demo.i18n) { - Locale.add(Demo.i18n); - } - - const wrapper = mount(Demo); - - await later(); - - expect(wrapper).toMatchSnapshot(); - - if (option.hookAfterTest) { - option.hookAfterTest(); - } - }); -} diff --git a/test/demo.ts b/test/demo.ts new file mode 100644 index 000000000..0ef71b2e6 --- /dev/null +++ b/test/demo.ts @@ -0,0 +1,36 @@ +import Vue, { CreateElement } from 'vue'; +import '../docs/site/mobile/demo-common'; +import Locale from '../src/locale'; +import { mount, later } from '.'; + +const Empty = { + render(h: CreateElement): ReturnType { + return h('div', [(this as any).$slots.default]); + }, + inheritAttrs: false +}; + +Vue.component('demo-block', Empty); +Vue.component('demo-section', Empty); + +export function snapshotDemo(Demo: any, option: any = {}) { + test('renders demo correctly', async () => { + if (option.beforeTest) { + option.beforeTest(); + } + + if (Demo.i18n) { + Locale.add(Demo.i18n); + } + + const wrapper = mount(Demo); + + await later(); + + expect(wrapper).toMatchSnapshot(); + + if (option.afterTest) { + option.afterTest(); + } + }); +} diff --git a/test/utils/dom.ts b/test/dom.ts similarity index 90% rename from test/utils/dom.ts rename to test/dom.ts index a4b89b2db..62fbec4a8 100644 --- a/test/utils/dom.ts +++ b/test/dom.ts @@ -32,12 +32,14 @@ function mockHTMLElementOffset() { mockHTMLElementOffset(); -export function mockGetBoundingClientRect(rect: ClientRect | DOMRect): Function { +export function mockGetBoundingClientRect( + rect: ClientRect | DOMRect +): Function { const originMethod = Element.prototype.getBoundingClientRect; Element.prototype.getBoundingClientRect = jest.fn(() => rect); - return function () { + return function() { Element.prototype.getBoundingClientRect = originMethod; }; } diff --git a/test/utils/event.ts b/test/event.ts similarity index 100% rename from test/utils/event.ts rename to test/event.ts diff --git a/test/utils/index.ts b/test/index.ts similarity index 52% rename from test/utils/index.ts rename to test/index.ts index decedfcc6..b585e78be 100644 --- a/test/utils/index.ts +++ b/test/index.ts @@ -1,17 +1,26 @@ import Vue from 'vue'; import './transition'; -import { mount } from '@vue/test-utils'; +import { mount, TransitionStub } from '@vue/test-utils'; import { trigger, triggerDrag } from './event'; import { mockScrollTop, mockGetBoundingClientRect } from './dom'; // prevent vue warning log Vue.config.silent = true; +// stub transition +Vue.component('transition', TransitionStub as any); + // promisify setTimeout -function later(delay: number = 0): Promise { +export function later(delay: number = 0): Promise { return new Promise(resolve => { setTimeout(resolve, delay); }); } -export { mount, later, trigger, triggerDrag, mockScrollTop, mockGetBoundingClientRect }; +export { + mount, + trigger, + triggerDrag, + mockScrollTop, + mockGetBoundingClientRect +}; diff --git a/test/jest.transform.js b/test/transformer.js similarity index 100% rename from test/jest.transform.js rename to test/transformer.js diff --git a/test/utils/transition.ts b/test/transition.ts similarity index 100% rename from test/utils/transition.ts rename to test/transition.ts