test: update modal mentions snap

pull/3053/head
tangjinzhou 2020-10-25 23:06:03 +08:00
parent 0a7065ce89
commit 6be6299717
6 changed files with 24 additions and 12 deletions

View File

@ -1,8 +1,9 @@
import { defineComponent, Fragment, Transition as T, TransitionGroup as TG } from 'vue';
import { defineComponent, Fragment, nextTick, Transition as T, TransitionGroup as TG } from 'vue';
import { findDOMNode } from './props-util';
export const getTransitionProps = (transitionName: string, opt: object = {}) => {
if (process.env.NODE_ENV === 'test') {
return {};
return opt;
}
const transitionProps = transitionName
? {
@ -44,9 +45,22 @@ let Transition = T;
let TransitionGroup = TG;
if (process.env.NODE_ENV === 'test') {
Transition = (_, { slots }) => {
Transition = (props, { slots }) => {
let child = slots.default?.()[0];
if (child && child.dirs && child.dirs[0]) {
const value = child.dirs[0].value;
const oldValue = child.dirs[0].oldValue;
if (!value && value !== oldValue) {
nextTick(() => {
if (props.onAfterLeave) {
props.onAfterLeave(findDOMNode(this));
}
});
}
}
return slots.default?.();
};
Transition.inheritAttrs = false;
TransitionGroup = defineComponent({
inheritAttrs: false,
props: ['tag', 'class'],

View File

@ -33,6 +33,7 @@ exports[`renders ./antdv-demo/docs/mentions/demo/form.md correctly 1`] = `
</div>
</div>
<div class="ant-row ant-form-item">
<!---->
<div class="ant-col ant-col-12 ant-col-offset-5 ant-form-item-control-wrapper">
<div class="ant-form-item-control"><span class="ant-form-item-children"><button class="ant-btn ant-btn-primary" type="button"><!----><span>Submit</span></button><button style="margin-left: 8px;" class="ant-btn" type="button">
<!----><span>Reset</span>

View File

@ -77,6 +77,7 @@ describe('Mentions', () => {
});
it('notExist', async () => {
jest.useFakeTimers();
const wrapper = mount({
render() {
return (

View File

@ -41,7 +41,7 @@ export default defineComponent({
onClick() {
const { actionFn, closeModal } = this;
if (actionFn) {
let ret;
let ret: any;
if (actionFn.length) {
ret = actionFn(closeModal);
} else {
@ -53,12 +53,12 @@ export default defineComponent({
if (ret && ret.then) {
this.setState({ loading: true });
ret.then(
(...args) => {
(...args: any[]) => {
// It's unnecessary to set loading=false, for the Modal will be unmounted after close.
// this.setState({ loading: false });
closeModal(...args);
},
e => {
(e: Event) => {
// Emit error when catch promise reject
// eslint-disable-next-line no-console
console.error(e);

View File

@ -150,10 +150,6 @@ export const destroyFns = [];
export default defineComponent({
name: 'AModal',
inheritAttrs: false,
model: {
prop: 'visible',
event: 'change',
},
emits: ['update:visible', 'cancel', 'change', 'ok'],
props: initDefaultProps(modalProps, {
width: 520,

View File

@ -4,10 +4,10 @@ import { destroyFns, ModalFuncProps } from './Modal';
import Omit from 'omit.js';
export default function confirm(config: ModalFuncProps) {
export default function confirm(config: ModalFuncProps & { parentContext?: any }) {
const div = document.createElement('div');
document.body.appendChild(div);
let currentConfig = { ...Omit(config, ['parentContext']), close, visible: true };
let currentConfig = { ...Omit(config, ['parentContext']), close, visible: true } as any;
let confirmDialogInstance = null;
let confirmDialogProps = {};