test: update test

pull/3053/head
tangjinzhou 2020-10-22 23:27:18 +08:00
parent a8dda5c586
commit f8750f2350
3 changed files with 12 additions and 5 deletions

View File

@ -1,6 +1,9 @@
import { defineComponent, Fragment, Transition as T, TransitionGroup as TG } from 'vue'; import { defineComponent, Fragment, Transition as T, TransitionGroup as TG } from 'vue';
export const getTransitionProps = (transitionName: string, opt: object = {}) => { export const getTransitionProps = (transitionName: string, opt: object = {}) => {
if (process.env.NODE_ENV === 'test') {
return {};
}
const transitionProps = transitionName const transitionProps = transitionName
? { ? {
appear: true, appear: true,
@ -44,7 +47,6 @@ if (process.env.NODE_ENV === 'test') {
Transition = (_, { slots }) => { Transition = (_, { slots }) => {
return slots.default?.(); return slots.default?.();
}; };
Transition.inheritAttrs = false;
TransitionGroup = defineComponent({ TransitionGroup = defineComponent({
inheritAttrs: false, inheritAttrs: false,
props: ['tag', 'class'], props: ['tag', 'class'],

View File

@ -58,6 +58,7 @@ export const AlertProps = {
const Alert = defineComponent({ const Alert = defineComponent({
name: 'AAlert', name: 'AAlert',
inheritAttrs: false,
props: AlertProps, props: AlertProps,
mixins: [BaseMixin], mixins: [BaseMixin],
emits: ['close'], emits: ['close'],
@ -96,7 +97,7 @@ const Alert = defineComponent({
}, },
render() { render() {
const { prefixCls: customizePrefixCls, banner, closing, closed } = this; const { prefixCls: customizePrefixCls, banner, closing, closed, $attrs } = this;
const getPrefixCls = this.configProvider.getPrefixCls; const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('alert', customizePrefixCls); const prefixCls = getPrefixCls('alert', customizePrefixCls);
@ -148,7 +149,7 @@ const Alert = defineComponent({
}); });
return closed ? null : ( return closed ? null : (
<Transition {...transitionProps}> <Transition {...transitionProps}>
<div v-show={!closing} class={alertCls} data-show={!closing}> <div {...$attrs} v-show={!closing} class={alertCls} data-show={!closing}>
{showIcon ? iconNode : null} {showIcon ? iconNode : null}
<span class={`${prefixCls}-message`}>{message}</span> <span class={`${prefixCls}-message`}>{message}</span>
<span class={`${prefixCls}-description`}>{description}</span> <span class={`${prefixCls}-description`}>{description}</span>

View File

@ -5,14 +5,18 @@ import Anchor from '..';
const { Link } = Anchor; const { Link } = Anchor;
let idCounter = 0;
const getHashUrl = () => `Anchor-API-${idCounter++}`;
describe('Anchor Render', () => { describe('Anchor Render', () => {
it('Anchor render perfectly', done => { it('Anchor render perfectly', done => {
const hash = getHashUrl();
const wrapper = mount( const wrapper = mount(
{ {
render() { render() {
return ( return (
<Anchor ref="anchor"> <Anchor ref="anchor">
<Link href="#API" title="API" /> <Link href={`#${hash}`} title={hash} />
</Anchor> </Anchor>
); );
}, },
@ -20,7 +24,7 @@ describe('Anchor Render', () => {
{ sync: false }, { sync: false },
); );
Vue.nextTick(() => { Vue.nextTick(() => {
wrapper.find('a[href="#API"]').trigger('click'); wrapper.find(`a[href="#${hash}`).trigger('click');
wrapper.vm.$refs.anchor.handleScroll(); wrapper.vm.$refs.anchor.handleScroll();
setTimeout(() => { setTimeout(() => {
expect(wrapper.vm.$refs.anchor.$data.activeLink).not.toBe(null); expect(wrapper.vm.$refs.anchor.$data.activeLink).not.toBe(null);