vendor: amis 6.13.0 base (fork root)
This commit is contained in:
64
packages/amis/__tests__/event-action/toast.test.tsx
Normal file
64
packages/amis/__tests__/event-action/toast.test.tsx
Normal file
@@ -0,0 +1,64 @@
|
||||
import {fireEvent, render, waitFor} from '@testing-library/react';
|
||||
import '../../src';
|
||||
import {render as amisRender} from '../../src';
|
||||
import {makeEnv} from '../helper';
|
||||
|
||||
test('EventAction:toast', async () => {
|
||||
const notify = jest.fn();
|
||||
const {getByText, container}: any = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'page',
|
||||
data: {
|
||||
msg: '我是全局警告消息,可以配置不同类型和弹出位置'
|
||||
},
|
||||
body: [
|
||||
{
|
||||
type: 'button',
|
||||
label: 'toast',
|
||||
level: 'warning',
|
||||
className: 'mr-2 mb-2',
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: [
|
||||
{
|
||||
actionType: 'toast',
|
||||
args: {
|
||||
msgType: 'warning',
|
||||
msg: '${msg}~',
|
||||
position: 'top-right',
|
||||
closeButton: true,
|
||||
showIcon: true,
|
||||
timeout: 5000
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{},
|
||||
makeEnv({
|
||||
notify
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
fireEvent.click(getByText('toast'));
|
||||
await waitFor(() => {
|
||||
expect(notify).toHaveBeenCalled();
|
||||
});
|
||||
expect(notify.mock.calls[0][0]).toEqual('warning');
|
||||
expect(notify.mock.calls[0][1]).toEqual(
|
||||
'我是全局警告消息,可以配置不同类型和弹出位置~'
|
||||
);
|
||||
expect(notify.mock.calls[0][2]).toEqual({
|
||||
msgType: 'warning',
|
||||
msg: '我是全局警告消息,可以配置不同类型和弹出位置~',
|
||||
position: 'top-right',
|
||||
closeButton: true,
|
||||
showIcon: true,
|
||||
timeout: 5000
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user