From f8750f235069915a4972f4a91e1e94de63f25692 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Thu, 22 Oct 2020 23:27:18 +0800 Subject: [PATCH] test: update test --- components/_util/transition.tsx | 4 +++- components/alert/index.tsx | 5 +++-- components/anchor/__tests__/Anchor.test.js | 8 ++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/components/_util/transition.tsx b/components/_util/transition.tsx index 32e02497e..bfa501935 100644 --- a/components/_util/transition.tsx +++ b/components/_util/transition.tsx @@ -1,6 +1,9 @@ import { defineComponent, Fragment, Transition as T, TransitionGroup as TG } from 'vue'; export const getTransitionProps = (transitionName: string, opt: object = {}) => { + if (process.env.NODE_ENV === 'test') { + return {}; + } const transitionProps = transitionName ? { appear: true, @@ -44,7 +47,6 @@ if (process.env.NODE_ENV === 'test') { Transition = (_, { slots }) => { return slots.default?.(); }; - Transition.inheritAttrs = false; TransitionGroup = defineComponent({ inheritAttrs: false, props: ['tag', 'class'], diff --git a/components/alert/index.tsx b/components/alert/index.tsx index 919b86648..b23dfe721 100644 --- a/components/alert/index.tsx +++ b/components/alert/index.tsx @@ -58,6 +58,7 @@ export const AlertProps = { const Alert = defineComponent({ name: 'AAlert', + inheritAttrs: false, props: AlertProps, mixins: [BaseMixin], emits: ['close'], @@ -96,7 +97,7 @@ const Alert = defineComponent({ }, render() { - const { prefixCls: customizePrefixCls, banner, closing, closed } = this; + const { prefixCls: customizePrefixCls, banner, closing, closed, $attrs } = this; const getPrefixCls = this.configProvider.getPrefixCls; const prefixCls = getPrefixCls('alert', customizePrefixCls); @@ -148,7 +149,7 @@ const Alert = defineComponent({ }); return closed ? null : ( -
+
{showIcon ? iconNode : null} {message} {description} diff --git a/components/anchor/__tests__/Anchor.test.js b/components/anchor/__tests__/Anchor.test.js index 56a0efcc4..ecfc52cd6 100644 --- a/components/anchor/__tests__/Anchor.test.js +++ b/components/anchor/__tests__/Anchor.test.js @@ -5,14 +5,18 @@ import Anchor from '..'; const { Link } = Anchor; +let idCounter = 0; +const getHashUrl = () => `Anchor-API-${idCounter++}`; + describe('Anchor Render', () => { it('Anchor render perfectly', done => { + const hash = getHashUrl(); const wrapper = mount( { render() { return ( - + ); }, @@ -20,7 +24,7 @@ describe('Anchor Render', () => { { sync: false }, ); Vue.nextTick(() => { - wrapper.find('a[href="#API"]').trigger('click'); + wrapper.find(`a[href="#${hash}`).trigger('click'); wrapper.vm.$refs.anchor.handleScroll(); setTimeout(() => { expect(wrapper.vm.$refs.anchor.$data.activeLink).not.toBe(null);