Skip to content

Commit 6be6299

Browse files
committed
test: update modal mentions snap
1 parent 0a7065c commit 6be6299

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

components/_util/transition.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { defineComponent, Fragment, Transition as T, TransitionGroup as TG } from 'vue';
1+
import { defineComponent, Fragment, nextTick, Transition as T, TransitionGroup as TG } from 'vue';
2+
import { findDOMNode } from './props-util';
23

34
export const getTransitionProps = (transitionName: string, opt: object = {}) => {
45
if (process.env.NODE_ENV === 'test') {
5-
return {};
6+
return opt;
67
}
78
const transitionProps = transitionName
89
? {
@@ -44,9 +45,22 @@ let Transition = T;
4445
let TransitionGroup = TG;
4546

4647
if (process.env.NODE_ENV === 'test') {
47-
Transition = (_, { slots }) => {
48+
Transition = (props, { slots }) => {
49+
let child = slots.default?.()[0];
50+
if (child && child.dirs && child.dirs[0]) {
51+
const value = child.dirs[0].value;
52+
const oldValue = child.dirs[0].oldValue;
53+
if (!value && value !== oldValue) {
54+
nextTick(() => {
55+
if (props.onAfterLeave) {
56+
props.onAfterLeave(findDOMNode(this));
57+
}
58+
});
59+
}
60+
}
4861
return slots.default?.();
4962
};
63+
Transition.inheritAttrs = false;
5064
TransitionGroup = defineComponent({
5165
inheritAttrs: false,
5266
props: ['tag', 'class'],

components/mentions/__tests__/__snapshots__/demo.test.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ exports[`renders ./antdv-demo/docs/mentions/demo/form.md correctly 1`] = `
3333
</div>
3434
</div>
3535
<div class="ant-row ant-form-item">
36+
<!---->
3637
<div class="ant-col ant-col-12 ant-col-offset-5 ant-form-item-control-wrapper">
3738
<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">
3839
<!----><span>Reset</span>

components/mentions/__tests__/index.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ describe('Mentions', () => {
7777
});
7878

7979
it('notExist', async () => {
80+
jest.useFakeTimers();
8081
const wrapper = mount({
8182
render() {
8283
return (

components/modal/ActionButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default defineComponent({
4141
onClick() {
4242
const { actionFn, closeModal } = this;
4343
if (actionFn) {
44-
let ret;
44+
let ret: any;
4545
if (actionFn.length) {
4646
ret = actionFn(closeModal);
4747
} else {
@@ -53,12 +53,12 @@ export default defineComponent({
5353
if (ret && ret.then) {
5454
this.setState({ loading: true });
5555
ret.then(
56-
(...args) => {
56+
(...args: any[]) => {
5757
// It's unnecessary to set loading=false, for the Modal will be unmounted after close.
5858
// this.setState({ loading: false });
5959
closeModal(...args);
6060
},
61-
e => {
61+
(e: Event) => {
6262
// Emit error when catch promise reject
6363
// eslint-disable-next-line no-console
6464
console.error(e);

components/modal/Modal.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,6 @@ export const destroyFns = [];
150150
export default defineComponent({
151151
name: 'AModal',
152152
inheritAttrs: false,
153-
model: {
154-
prop: 'visible',
155-
event: 'change',
156-
},
157153
emits: ['update:visible', 'cancel', 'change', 'ok'],
158154
props: initDefaultProps(modalProps, {
159155
width: 520,

components/modal/confirm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { destroyFns, ModalFuncProps } from './Modal';
44

55
import Omit from 'omit.js';
66

7-
export default function confirm(config: ModalFuncProps) {
7+
export default function confirm(config: ModalFuncProps & { parentContext?: any }) {
88
const div = document.createElement('div');
99
document.body.appendChild(div);
10-
let currentConfig = { ...Omit(config, ['parentContext']), close, visible: true };
10+
let currentConfig = { ...Omit(config, ['parentContext']), close, visible: true } as any;
1111

1212
let confirmDialogInstance = null;
1313
let confirmDialogProps = {};

0 commit comments

Comments
 (0)