From bf508421cf23bb21a417dce05925d195e88fe4cb Mon Sep 17 00:00:00 2001
From: tangjinzhou <415800467@qq.com>
Date: Sat, 28 Aug 2021 21:57:12 +0800
Subject: [PATCH] test: update
---
components/tooltip/Tooltip.tsx | 2 +-
components/tooltip/__tests__/tooltip.test.js | 7 +------
components/tree/Tree.tsx | 2 +-
components/vc-mentions/src/mentionsProps.ts | 2 +-
components/vc-tooltip/src/Tooltip.tsx | 8 +++++---
tests/shared/focusTest.js | 2 +-
6 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/components/tooltip/Tooltip.tsx b/components/tooltip/Tooltip.tsx
index 8c3079e46..f69063578 100644
--- a/components/tooltip/Tooltip.tsx
+++ b/components/tooltip/Tooltip.tsx
@@ -230,7 +230,7 @@ export default defineComponent({
const vcTooltipProps = {
...attrs,
- ...props,
+ ...(props as TooltipProps),
prefixCls: prefixCls.value,
getTooltipContainer: getPopupContainer || getTargetContainer.value,
builtinPlacements: tooltipPlacements.value,
diff --git a/components/tooltip/__tests__/tooltip.test.js b/components/tooltip/__tests__/tooltip.test.js
index f50f52b8f..90fd1ad27 100644
--- a/components/tooltip/__tests__/tooltip.test.js
+++ b/components/tooltip/__tests__/tooltip.test.js
@@ -16,11 +16,6 @@ describe('Tooltip', () => {
mouseEnterDelay: 0,
mouseLeaveDelay: 0,
onVisibleChange,
- // TODO test/util 的bug 没有使用 v-model 同样会改变
- 'onUpdate:visible': () => {
- props.visible = this.visible;
- this.$forceUpdate();
- },
};
if (this.visible !== undefined) {
props.visible = this.visible;
@@ -80,7 +75,7 @@ describe('Tooltip', () => {
});
await asyncExpect(() => {
expect(onVisibleChange).toHaveBeenLastCalledWith(true);
- expect(wrapper.vm.$refs.tooltip.visible).toBe(true);
+ expect(wrapper.vm.$refs.tooltip.visible).toBe(false);
});
await asyncExpect(() => {
// always trigger onVisibleChange
diff --git a/components/tree/Tree.tsx b/components/tree/Tree.tsx
index 1615acdd7..5a70ab8d6 100644
--- a/components/tree/Tree.tsx
+++ b/components/tree/Tree.tsx
@@ -200,7 +200,7 @@ export default defineComponent({
fieldNames = props.replaceFields,
motion = props.openAnimation,
itemHeight = 28,
- } = props;
+ } = props as TreeProps;
const newProps = {
...attrs,
...props,
diff --git a/components/vc-mentions/src/mentionsProps.ts b/components/vc-mentions/src/mentionsProps.ts
index 0f4acc0fd..fb65093cb 100644
--- a/components/vc-mentions/src/mentionsProps.ts
+++ b/components/vc-mentions/src/mentionsProps.ts
@@ -47,7 +47,7 @@ export const defaultProps = {
split: ' ',
rows: 1,
validateSearch: defaultValidateSearch,
- filterOption: defaultFilterOption,
+ filterOption: (() => defaultFilterOption) as any,
};
export default initDefaultProps(vcMentionsProps, defaultProps);
diff --git a/components/vc-tooltip/src/Tooltip.tsx b/components/vc-tooltip/src/Tooltip.tsx
index 3ec9d8c07..ad657cfd6 100644
--- a/components/vc-tooltip/src/Tooltip.tsx
+++ b/components/vc-tooltip/src/Tooltip.tsx
@@ -30,6 +30,8 @@ export default defineComponent({
builtinPlacements: PropTypes.object,
overlayInnerStyle: PropTypes.style,
popupVisible: PropTypes.looseBool,
+ onVisibleChange: PropTypes.func,
+ onPopupAlign: PropTypes.func,
},
slots: ['arrowContent', 'overlay'],
setup(props, { slots, attrs, expose }) {
@@ -116,12 +118,12 @@ export default defineComponent({
mouseEnterDelay,
...extraProps,
...attrs,
- onPopupVisibleChange: (attrs.onVisibleChange as any) || noop,
- onPopupAlign: attrs.onPopupAlign || noop,
+ onPopupVisibleChange: props.onVisibleChange || noop,
+ onPopupAlign: props.onPopupAlign || noop,
ref: triggerDOM,
popup: getPopupElement(),
};
- return {slots.default?.()};
+ return ;
};
},
});
diff --git a/tests/shared/focusTest.js b/tests/shared/focusTest.js
index 5e32d0585..780d62bfd 100644
--- a/tests/shared/focusTest.js
+++ b/tests/shared/focusTest.js
@@ -29,7 +29,7 @@ export default function focusTest(Component) {
expect(handleFocus).toBeCalled();
});
- fit('blur() and onBlur', async () => {
+ it('blur() and onBlur', async () => {
const handleBlur = jest.fn();
const handleFocus = jest.fn();
const wrapper = mount(