2022-05-16 10:41:43 +08:00
|
|
|
|
import {fireEvent, render, waitFor} from '@testing-library/react';
|
2022-06-02 10:00:09 +08:00
|
|
|
|
import '../../src';
|
|
|
|
|
import {render as amisRender} from '../../src';
|
2022-05-16 10:41:43 +08:00
|
|
|
|
import {makeEnv, wait} from '../helper';
|
|
|
|
|
|
2023-07-20 11:11:39 +08:00
|
|
|
|
test('EventAction:drawer args', async () => {
|
|
|
|
|
const notify = jest.fn();
|
2024-02-02 13:55:23 +08:00
|
|
|
|
let container: HTMLElement;
|
|
|
|
|
const renderResult: any = render(
|
2023-07-20 11:11:39 +08:00
|
|
|
|
amisRender(
|
|
|
|
|
{
|
|
|
|
|
type: 'page',
|
|
|
|
|
body: [
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '打开抽屉',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'drawer',
|
|
|
|
|
args: {
|
|
|
|
|
drawer: {
|
|
|
|
|
type: 'drawer',
|
|
|
|
|
id: 'drawer_001',
|
|
|
|
|
title: '模态抽屉',
|
|
|
|
|
body: [
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '打开子抽屉',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'drawer',
|
|
|
|
|
args: {
|
|
|
|
|
drawer: {
|
|
|
|
|
type: 'drawer',
|
|
|
|
|
title: '模态子抽屉',
|
|
|
|
|
body: [
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '关闭父抽屉',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'closeDrawer',
|
|
|
|
|
componentId: 'drawer_001'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '关闭当前抽屉',
|
|
|
|
|
className: 'ml-2',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'closeDrawer'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '触发确认',
|
|
|
|
|
className: 'ml-2',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'confirm',
|
|
|
|
|
componentId: 'drawer_001'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '触发取消',
|
|
|
|
|
className: 'ml-2',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'cancel',
|
|
|
|
|
componentId: 'drawer_001'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
onEvent: {
|
|
|
|
|
confirm: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'toast',
|
|
|
|
|
args: {
|
|
|
|
|
msg: 'confirm'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
cancel: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'toast',
|
|
|
|
|
args: {
|
|
|
|
|
msg: 'cancel'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{},
|
|
|
|
|
makeEnv({
|
|
|
|
|
getModalContainer: () => container,
|
|
|
|
|
notify
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
);
|
2024-02-02 13:55:23 +08:00
|
|
|
|
const getByText = renderResult.getByText;
|
|
|
|
|
container = renderResult.container;
|
2023-07-20 11:11:39 +08:00
|
|
|
|
|
|
|
|
|
// events
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
|
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('确认')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('确认'));
|
|
|
|
|
await wait(300);
|
|
|
|
|
expect(notify).toHaveBeenCalled();
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
|
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('取消')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('取消'));
|
|
|
|
|
await wait(300);
|
|
|
|
|
expect(notify).toHaveBeenCalled();
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
|
|
|
|
|
|
// actions
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('关闭当前抽屉')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('关闭当前抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
|
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('打开子抽屉')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('打开子抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('关闭父抽屉')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('关闭父抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
|
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('触发确认')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('触发确认'));
|
|
|
|
|
await wait(300);
|
|
|
|
|
expect(notify).toHaveBeenCalled();
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
|
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('触发取消')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('触发取消'));
|
|
|
|
|
await wait(300);
|
|
|
|
|
expect(notify).toHaveBeenCalled();
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
|
}, 7000);
|
|
|
|
|
|
2022-05-16 10:41:43 +08:00
|
|
|
|
test('EventAction:drawer', async () => {
|
|
|
|
|
const notify = jest.fn();
|
2024-02-02 13:55:23 +08:00
|
|
|
|
let container: HTMLElement;
|
|
|
|
|
const renderResult: any = render(
|
2022-05-16 10:41:43 +08:00
|
|
|
|
amisRender(
|
|
|
|
|
{
|
|
|
|
|
type: 'page',
|
|
|
|
|
body: [
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '打开抽屉',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'drawer',
|
2023-06-28 16:26:39 +08:00
|
|
|
|
drawer: {
|
|
|
|
|
type: 'drawer',
|
|
|
|
|
id: 'drawer_001',
|
|
|
|
|
title: '模态抽屉',
|
|
|
|
|
body: [
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '打开子抽屉',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'drawer',
|
|
|
|
|
drawer: {
|
|
|
|
|
type: 'drawer',
|
|
|
|
|
title: '模态子抽屉',
|
|
|
|
|
body: [
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '关闭父抽屉',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'closeDrawer',
|
|
|
|
|
componentId: 'drawer_001'
|
2022-05-16 10:41:43 +08:00
|
|
|
|
}
|
2023-06-28 16:26:39 +08:00
|
|
|
|
]
|
2022-05-16 10:41:43 +08:00
|
|
|
|
}
|
2023-06-28 16:26:39 +08:00
|
|
|
|
}
|
2022-05-16 10:41:43 +08:00
|
|
|
|
}
|
2023-06-28 16:26:39 +08:00
|
|
|
|
]
|
2022-05-16 10:41:43 +08:00
|
|
|
|
}
|
2023-06-28 16:26:39 +08:00
|
|
|
|
}
|
|
|
|
|
]
|
2022-05-16 10:41:43 +08:00
|
|
|
|
}
|
2023-06-28 16:26:39 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '关闭当前抽屉',
|
|
|
|
|
className: 'ml-2',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'closeDrawer'
|
|
|
|
|
}
|
|
|
|
|
]
|
2022-05-16 10:41:43 +08:00
|
|
|
|
}
|
2023-06-28 16:26:39 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '触发确认',
|
|
|
|
|
className: 'ml-2',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'confirm',
|
|
|
|
|
componentId: 'drawer_001'
|
|
|
|
|
}
|
|
|
|
|
]
|
2022-05-16 10:41:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-28 16:26:39 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '触发取消',
|
|
|
|
|
className: 'ml-2',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'cancel',
|
|
|
|
|
componentId: 'drawer_001'
|
2022-10-18 16:26:13 +08:00
|
|
|
|
}
|
2023-06-28 16:26:39 +08:00
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
onEvent: {
|
|
|
|
|
confirm: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'toast',
|
|
|
|
|
args: {
|
|
|
|
|
msg: 'confirm'
|
2022-05-16 10:41:43 +08:00
|
|
|
|
}
|
2023-06-28 16:26:39 +08:00
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
cancel: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'toast',
|
|
|
|
|
args: {
|
|
|
|
|
msg: 'cancel'
|
2022-05-16 10:41:43 +08:00
|
|
|
|
}
|
2023-06-28 16:26:39 +08:00
|
|
|
|
}
|
|
|
|
|
]
|
2022-05-16 10:41:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{},
|
|
|
|
|
makeEnv({
|
|
|
|
|
getModalContainer: () => container,
|
|
|
|
|
notify
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2024-02-02 13:55:23 +08:00
|
|
|
|
const getByText = renderResult.getByText;
|
|
|
|
|
container = renderResult.container;
|
|
|
|
|
|
2022-05-16 10:41:43 +08:00
|
|
|
|
// events
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
|
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('确认')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('确认'));
|
|
|
|
|
await wait(300);
|
|
|
|
|
expect(notify).toHaveBeenCalled();
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
|
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('取消')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('取消'));
|
|
|
|
|
await wait(300);
|
|
|
|
|
expect(notify).toHaveBeenCalled();
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
|
|
|
|
|
|
// actions
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('关闭当前抽屉')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('关闭当前抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
|
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('打开子抽屉')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('打开子抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('关闭父抽屉')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('关闭父抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
|
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('触发确认')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('触发确认'));
|
|
|
|
|
await wait(300);
|
|
|
|
|
expect(notify).toHaveBeenCalled();
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
|
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(getByText('触发取消')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
fireEvent.click(getByText('触发取消'));
|
|
|
|
|
await wait(300);
|
|
|
|
|
expect(notify).toHaveBeenCalled();
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
expect(container).toMatchSnapshot();
|
2022-05-27 18:30:59 +08:00
|
|
|
|
}, 7000);
|
2023-07-20 11:11:39 +08:00
|
|
|
|
|
|
|
|
|
test('EventAction:drawer data', async () => {
|
2024-02-02 13:55:23 +08:00
|
|
|
|
let container: HTMLElement;
|
|
|
|
|
const renderResult: any = render(
|
2023-07-20 11:11:39 +08:00
|
|
|
|
amisRender(
|
|
|
|
|
{
|
|
|
|
|
type: 'page',
|
|
|
|
|
data: {
|
|
|
|
|
name: 'amis'
|
|
|
|
|
},
|
|
|
|
|
body: [
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '打开抽屉',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'drawer',
|
|
|
|
|
args: {
|
|
|
|
|
drawer: {
|
|
|
|
|
type: 'drawer',
|
|
|
|
|
id: 'drawer_001',
|
|
|
|
|
title: '模态弹窗${event.data.name}',
|
|
|
|
|
body: [
|
|
|
|
|
{
|
|
|
|
|
type: 'tpl',
|
|
|
|
|
tpl: '你好,我是${name}、${name1}、${name2}'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
data: {
|
|
|
|
|
name1: '${name}',
|
|
|
|
|
name2: '${event.data.name}'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{},
|
|
|
|
|
makeEnv({
|
|
|
|
|
getModalContainer: () => container
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
);
|
2024-02-02 13:55:23 +08:00
|
|
|
|
const getByText = renderResult.getByText;
|
|
|
|
|
container = renderResult.container;
|
2023-07-20 11:11:39 +08:00
|
|
|
|
|
|
|
|
|
// events
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).toBeInTheDocument();
|
|
|
|
|
expect(getByText('模态弹窗')).toBeInTheDocument();
|
|
|
|
|
expect(getByText('你好,我是、amis、amis')).toBeInTheDocument(); // 因为事件动作给args提前做了映射
|
|
|
|
|
});
|
|
|
|
|
}, 7000);
|
|
|
|
|
|
|
|
|
|
test('EventAction:drawer data2', async () => {
|
2024-02-02 13:55:23 +08:00
|
|
|
|
let container: HTMLElement;
|
|
|
|
|
const renderResult: any = render(
|
2023-07-20 11:11:39 +08:00
|
|
|
|
amisRender(
|
|
|
|
|
{
|
|
|
|
|
type: 'page',
|
|
|
|
|
data: {
|
|
|
|
|
name: 'amis'
|
|
|
|
|
},
|
|
|
|
|
body: [
|
|
|
|
|
{
|
|
|
|
|
type: 'button',
|
|
|
|
|
label: '打开抽屉',
|
|
|
|
|
onEvent: {
|
|
|
|
|
click: {
|
|
|
|
|
actions: [
|
|
|
|
|
{
|
|
|
|
|
actionType: 'drawer',
|
|
|
|
|
drawer: {
|
|
|
|
|
type: 'drawer',
|
|
|
|
|
id: 'drawer_001',
|
|
|
|
|
title: '模态弹窗${event.data.name}',
|
|
|
|
|
body: [
|
|
|
|
|
{
|
|
|
|
|
type: 'tpl',
|
|
|
|
|
tpl: '你好,我是${name}、${name1}、${name2}'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
data: {
|
|
|
|
|
name1: '${name}',
|
|
|
|
|
name2: '${event.data.name}'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{},
|
|
|
|
|
makeEnv({
|
|
|
|
|
getModalContainer: () => container
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2024-02-02 13:55:23 +08:00
|
|
|
|
const getByText = renderResult.getByText;
|
|
|
|
|
container = renderResult.container;
|
|
|
|
|
|
2023-07-20 11:11:39 +08:00
|
|
|
|
// events
|
|
|
|
|
fireEvent.click(getByText('打开抽屉'));
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
expect(container.querySelector('[role="dialog"]')).toBeInTheDocument();
|
|
|
|
|
expect(getByText('模态弹窗')).toBeInTheDocument();
|
|
|
|
|
expect(getByText('你好,我是、amis、amis')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
}, 7000);
|