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';
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'],

View File

@ -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 : (
<Transition {...transitionProps}>
<div v-show={!closing} class={alertCls} data-show={!closing}>
<div {...$attrs} v-show={!closing} class={alertCls} data-show={!closing}>
{showIcon ? iconNode : null}
<span class={`${prefixCls}-message`}>{message}</span>
<span class={`${prefixCls}-description`}>{description}</span>

View File

@ -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 (
<Anchor ref="anchor">
<Link href="#API" title="API" />
<Link href={`#${hash}`} title={hash} />
</Anchor>
);
},
@ -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);