From 789647c60438025a2d092379ed5ca7d3b2f66e02 Mon Sep 17 00:00:00 2001 From: tanjinzhou <415800467@qq.com> Date: Wed, 28 Oct 2020 15:31:45 +0800 Subject: [PATCH] test: update test & ts --- antdv-demo | 2 +- components/_util/BaseMixin.js | 3 +- components/_util/BaseMixin2.js | 3 +- components/_util/Portal.js | 4 +- components/anchor/Anchor.tsx | 6 +- components/anchor/AnchorLink.tsx | 4 +- components/avatar/Avatar.tsx | 8 +- components/back-top/index.tsx | 4 +- components/cascader/index.tsx | 7 -- components/checkbox/Checkbox.tsx | 4 +- components/date-picker/RangePicker.tsx | 4 +- components/date-picker/WeekPicker.tsx | 6 +- .../__snapshots__/RangePicker.test.js.snap | 2 +- components/date-picker/createPicker.tsx | 4 +- components/date-picker/wrapPicker.tsx | 4 +- components/form/FormItem.tsx | 4 +- components/input/Input.tsx | 6 +- components/input/ResizableTextArea.tsx | 4 +- components/input/TextArea.tsx | 6 +- components/layout/Sider.tsx | 4 +- .../__snapshots__/index.test.js.snap | 88 +++++++++---------- components/mentions/index.tsx | 4 +- .../__snapshots__/index.test.js.snap | 8 +- components/spin/Spin.tsx | 4 +- components/table/filterDropdown.tsx | 12 +-- components/transfer/list.tsx | 4 +- components/transfer/renderListBody.tsx | 4 +- components/upload/UploadList.tsx | 4 +- components/vc-select/OptionList.tsx | 2 +- components/vc-select/Select.tsx | 2 +- components/vc-select/generate.tsx | 6 +- tests/setup.js | 6 +- 32 files changed, 116 insertions(+), 117 deletions(-) diff --git a/antdv-demo b/antdv-demo index 9bb9cb5ae..4f6ebd031 160000 --- a/antdv-demo +++ b/antdv-demo @@ -1 +1 @@ -Subproject commit 9bb9cb5ae42a776adb2d3bf3242a473a9851b344 +Subproject commit 4f6ebd03190812369678c4dd383fdb4e98d6f6c1 diff --git a/components/_util/BaseMixin.js b/components/_util/BaseMixin.js index 1bf7c9c3c..eeec056e3 100644 --- a/components/_util/BaseMixin.js +++ b/components/_util/BaseMixin.js @@ -1,3 +1,4 @@ +import { nextTick } from 'vue'; import { getOptionProps } from './props-util'; export default { @@ -19,7 +20,7 @@ export default { if (this._.isMounted) { this.$forceUpdate(); } - this.$nextTick(() => { + nextTick(() => { callback && callback(); }); }, diff --git a/components/_util/BaseMixin2.js b/components/_util/BaseMixin2.js index 4d8007a3c..00446ed20 100644 --- a/components/_util/BaseMixin2.js +++ b/components/_util/BaseMixin2.js @@ -1,3 +1,4 @@ +import { nextTick } from 'vue'; import { getOptionProps } from './props-util'; export default { @@ -19,7 +20,7 @@ export default { if (this._.isMounted) { this.$forceUpdate(); } - this.$nextTick(() => { + nextTick(() => { callback && callback(); }); }, diff --git a/components/_util/Portal.js b/components/_util/Portal.js index 0fc276677..e0ca32114 100644 --- a/components/_util/Portal.js +++ b/components/_util/Portal.js @@ -1,5 +1,5 @@ import PropTypes from './vue-types'; -import { defineComponent, Teleport } from 'vue'; +import { defineComponent, nextTick, Teleport } from 'vue'; export default defineComponent({ name: 'Portal', @@ -18,7 +18,7 @@ export default defineComponent({ updated() { const { didUpdate } = this.$props; if (didUpdate) { - this.$nextTick(() => { + nextTick(() => { didUpdate(this.$props); }); } diff --git a/components/anchor/Anchor.tsx b/components/anchor/Anchor.tsx index a76522d4f..b718296e5 100644 --- a/components/anchor/Anchor.tsx +++ b/components/anchor/Anchor.tsx @@ -1,4 +1,4 @@ -import { defineComponent, inject, provide } from 'vue'; +import { defineComponent, inject, nextTick, provide } from 'vue'; import PropTypes from '../_util/vue-types'; import classNames from '../_util/classNames'; import addEventListener from '../vc-util/Dom/addEventListener'; @@ -117,7 +117,7 @@ export default defineComponent({ }; }, mounted() { - this.$nextTick(() => { + nextTick(() => { const { getContainer } = this; this.scrollContainer = getContainer(); this.scrollEvent = addEventListener(this.scrollContainer, 'scroll', this.handleScroll); @@ -125,7 +125,7 @@ export default defineComponent({ }); }, updated() { - this.$nextTick(() => { + nextTick(() => { if (this.scrollEvent) { const { getContainer } = this; const currentContainer = getContainer(); diff --git a/components/anchor/AnchorLink.tsx b/components/anchor/AnchorLink.tsx index 4a2578bfe..4997dbe49 100644 --- a/components/anchor/AnchorLink.tsx +++ b/components/anchor/AnchorLink.tsx @@ -1,4 +1,4 @@ -import { ComponentPublicInstance, defineComponent, inject } from 'vue'; +import { ComponentPublicInstance, defineComponent, inject, nextTick } from 'vue'; import PropTypes from '../_util/vue-types'; import { getComponent } from '../_util/props-util'; import classNames from '../_util/classNames'; @@ -32,7 +32,7 @@ export default defineComponent({ }, watch: { href(val, oldVal) { - this.$nextTick(() => { + nextTick(() => { this.antAnchor.unregisterLink(oldVal); this.antAnchor.registerLink(val); }); diff --git a/components/avatar/Avatar.tsx b/components/avatar/Avatar.tsx index 9eeabd45d..212bd57cf 100644 --- a/components/avatar/Avatar.tsx +++ b/components/avatar/Avatar.tsx @@ -1,5 +1,5 @@ import { tuple, VueNode } from '../_util/type'; -import { CSSProperties, defineComponent, inject, PropType } from 'vue'; +import { CSSProperties, defineComponent, inject, nextTick, PropType } from 'vue'; import { defaultConfigProvider } from '../config-provider'; import { getComponent } from '../_util/props-util'; import PropTypes from '../_util/vue-types'; @@ -40,7 +40,7 @@ export default defineComponent({ }, watch: { src() { - this.$nextTick(() => { + nextTick(() => { this.isImgExist = true; this.scale = 1; // force uodate for position @@ -49,13 +49,13 @@ export default defineComponent({ }, }, mounted() { - this.$nextTick(() => { + nextTick(() => { this.setScale(); this.isMounted = true; }); }, updated() { - this.$nextTick(() => { + nextTick(() => { this.setScale(); }); }, diff --git a/components/back-top/index.tsx b/components/back-top/index.tsx index 01596aef1..e3f91e4a7 100644 --- a/components/back-top/index.tsx +++ b/components/back-top/index.tsx @@ -1,4 +1,4 @@ -import { App, defineComponent, inject } from 'vue'; +import { App, defineComponent, inject, nextTick } from 'vue'; import classNames from '../_util/classNames'; import PropTypes from '../_util/vue-types'; import backTopTypes from './backTopTypes'; @@ -36,7 +36,7 @@ const BackTop = defineComponent({ }; }, mounted() { - this.$nextTick(() => { + nextTick(() => { const getTarget = this.target || getDefaultTarget; this.scrollEvent = addEventListener(getTarget(), 'scroll', this.handleScroll); this.handleScroll(); diff --git a/components/cascader/index.tsx b/components/cascader/index.tsx index 4d401fd74..6a49e14ca 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -231,13 +231,6 @@ const Cascader = defineComponent({ flattenOptions: showSearch ? flattenTree(options, this.$props) : undefined, }; }, - // mounted() { - // this.$nextTick(() => { - // if (this.autofocus && !this.showSearch && !this.disabled) { - // this.$refs.picker.focus(); - // } - // }); - // }, watch: { value(val) { this.setState({ sValue: val || [] }); diff --git a/components/checkbox/Checkbox.tsx b/components/checkbox/Checkbox.tsx index b90cc3df2..6b2767509 100644 --- a/components/checkbox/Checkbox.tsx +++ b/components/checkbox/Checkbox.tsx @@ -1,4 +1,4 @@ -import { defineComponent, inject } from 'vue'; +import { defineComponent, inject, nextTick } from 'vue'; import PropTypes from '../_util/vue-types'; import classNames from '../_util/classNames'; import VcCheckbox from '../vc-checkbox'; @@ -36,7 +36,7 @@ export default defineComponent({ watch: { value(value, prevValue) { - this.$nextTick(() => { + nextTick(() => { const { checkboxGroupContext: checkboxGroup = {} } = this; if (checkboxGroup.registerValue && checkboxGroup.cancelValue) { checkboxGroup.cancelValue(prevValue); diff --git a/components/date-picker/RangePicker.tsx b/components/date-picker/RangePicker.tsx index f36a6a795..1bff2f4c9 100644 --- a/components/date-picker/RangePicker.tsx +++ b/components/date-picker/RangePicker.tsx @@ -1,4 +1,4 @@ -import { CSSProperties, defineComponent, inject } from 'vue'; +import { CSSProperties, defineComponent, inject, nextTick } from 'vue'; import moment from 'moment'; import RangeCalendar from '../vc-calendar/src/RangeCalendar'; import VcDatePicker from '../vc-calendar/src/Picker'; @@ -136,7 +136,7 @@ export default defineComponent({ this.setState(state); }, sOpen(val, oldVal) { - this.$nextTick(() => { + nextTick(() => { if (!hasProp(this, 'open') && oldVal && !val) { this.focus(); } diff --git a/components/date-picker/WeekPicker.tsx b/components/date-picker/WeekPicker.tsx index 94088d9d4..2306d38aa 100644 --- a/components/date-picker/WeekPicker.tsx +++ b/components/date-picker/WeekPicker.tsx @@ -1,4 +1,4 @@ -import { defineComponent, inject } from 'vue'; +import { defineComponent, inject, nextTick } from 'vue'; import moment from 'moment'; import Calendar from '../vc-calendar'; import VcDatePicker from '../vc-calendar/src/Picker'; @@ -63,7 +63,7 @@ export default defineComponent({ this.prevState = { ...this.$data, ...state }; }, _open(val, oldVal) { - this.$nextTick(() => { + nextTick(() => { if (!hasProp(this, 'open') && oldVal && !val) { this.focus(); } @@ -74,7 +74,7 @@ export default defineComponent({ this.prevState = { ...this.$data }; }, updated() { - this.$nextTick(() => { + nextTick(() => { if (!hasProp(this, 'open') && this.prevState._open && !this._open) { this.focus(); } diff --git a/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap b/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap index da21fdb35..ffee840c4 100644 --- a/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap +++ b/components/date-picker/__tests__/__snapshots__/RangePicker.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`RangePicker show month panel according to value 1`] = ` -
( this.setState(state); }, sOpen(val, oldVal) { - this.$nextTick(() => { + nextTick(() => { if (!hasProp(this, 'open') && oldVal && !val) { this.focus(); } diff --git a/components/date-picker/wrapPicker.tsx b/components/date-picker/wrapPicker.tsx index 460a671dc..dc9204c0d 100644 --- a/components/date-picker/wrapPicker.tsx +++ b/components/date-picker/wrapPicker.tsx @@ -1,4 +1,4 @@ -import { provide, inject, defineComponent, DefineComponent } from 'vue'; +import { provide, inject, defineComponent, DefineComponent, nextTick } from 'vue'; import TimePickerPanel from '../vc-time-picker/Panel'; import classNames from '../_util/classNames'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; @@ -74,7 +74,7 @@ export default function wrapPicker
( checkValidate('DatePicker', defaultValue, 'defaultValue', valueFormat); checkValidate('DatePicker', value, 'value', valueFormat); if (autofocus && !disabled) { - this.$nextTick(() => { + nextTick(() => { this.focus(); }); } diff --git a/components/form/FormItem.tsx b/components/form/FormItem.tsx index e734f58e2..a5368d08a 100644 --- a/components/form/FormItem.tsx +++ b/components/form/FormItem.tsx @@ -1,4 +1,4 @@ -import { inject, provide, PropType, defineComponent, computed } from 'vue'; +import { inject, provide, PropType, defineComponent, computed, nextTick } from 'vue'; import cloneDeep from 'lodash-es/cloneDeep'; import PropTypes from '../_util/vue-types'; import classNames from '../_util/classNames'; @@ -295,7 +295,7 @@ export default defineComponent({ prop.o[prop.k] = this.initialValue; } // reset validateDisabled after onFieldChange triggered - this.$nextTick(() => { + nextTick(() => { this.validateDisabled = false; }); }, diff --git a/components/input/Input.tsx b/components/input/Input.tsx index 869f2adf6..042bbd0e2 100644 --- a/components/input/Input.tsx +++ b/components/input/Input.tsx @@ -1,4 +1,4 @@ -import { defineComponent, inject, VNode, withDirectives } from 'vue'; +import { defineComponent, inject, nextTick, VNode, withDirectives } from 'vue'; import antInputDirective from '../_util/antInputDirective'; import classNames from '../_util/classNames'; import omit from 'omit.js'; @@ -76,7 +76,7 @@ export default defineComponent({ }, }, mounted() { - this.$nextTick(() => { + nextTick(() => { if (process.env.NODE_ENV === 'test') { if (this.autofocus) { this.focus(); @@ -129,7 +129,7 @@ export default defineComponent({ } else { this.$forceUpdate(); } - this.$nextTick(() => { + nextTick(() => { callback && callback(); }); }, diff --git a/components/input/ResizableTextArea.tsx b/components/input/ResizableTextArea.tsx index e6a0d347d..734254397 100644 --- a/components/input/ResizableTextArea.tsx +++ b/components/input/ResizableTextArea.tsx @@ -1,4 +1,4 @@ -import { PropType, VNode } from 'vue'; +import { nextTick, PropType, VNode } from 'vue'; import ResizeObserver from '../vc-resize-observer'; import omit from 'omit.js'; import classNames from '../_util/classNames'; @@ -55,7 +55,7 @@ const ResizableTextArea = defineComponent({ }, watch: { value() { - this.$nextTick(() => { + nextTick(() => { this.resizeTextarea(); }); }, diff --git a/components/input/TextArea.tsx b/components/input/TextArea.tsx index 87de5a8f5..e407927d7 100644 --- a/components/input/TextArea.tsx +++ b/components/input/TextArea.tsx @@ -1,4 +1,4 @@ -import { defineComponent, inject } from 'vue'; +import { defineComponent, inject, nextTick } from 'vue'; import ClearableLabeledInput from './ClearableLabeledInput'; import ResizableTextArea from './ResizableTextArea'; import inputProps from './inputProps'; @@ -40,7 +40,7 @@ export default defineComponent({ }, }, mounted() { - this.$nextTick(() => { + nextTick(() => { if (process.env.NODE_ENV === 'test') { if (this.autofocus) { this.focus(); @@ -55,7 +55,7 @@ export default defineComponent({ } else { this.$forceUpdate(); } - this.$nextTick(() => { + nextTick(() => { callback && callback(); }); }, diff --git a/components/layout/Sider.tsx b/components/layout/Sider.tsx index ca7651c36..a8f94a577 100644 --- a/components/layout/Sider.tsx +++ b/components/layout/Sider.tsx @@ -1,5 +1,5 @@ import classNames from '../_util/classNames'; -import { inject, provide, PropType, defineComponent } from 'vue'; +import { inject, provide, PropType, defineComponent, nextTick } from 'vue'; import PropTypes from '../_util/vue-types'; import { tuple } from '../_util/type'; import { getOptionProps, hasProp, getComponent, getSlot } from '../_util/props-util'; @@ -114,7 +114,7 @@ export default defineComponent({ }, mounted() { - this.$nextTick(() => { + nextTick(() => { if (this.mql) { this.mql.addListener(this.responsiveHandler); this.responsiveHandler(this.mql); diff --git a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap index 187eb7c4c..1107dbca8 100644 --- a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap +++ b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap @@ -10434,7 +10434,7 @@ exports[`Locale Provider should display the text as hu 1`] = `