mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 11:58:10 +08:00
0742036e57
* feat:组件广播事件机制 * feat:组件广播事件机制 * feat:组件广播事件机制 * feat:组件广播事件机制 * feat:组件广播事件机制
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import React = require('react');
|
|
import {render, cleanup, fireEvent} from '@testing-library/react';
|
|
import '../../../src/themes/default';
|
|
import {render as amisRender} from '../../../src/index';
|
|
import {wait, makeEnv} from '../../helper';
|
|
import {clearStoresCache} from '../../../src/factory';
|
|
|
|
afterEach(() => {
|
|
cleanup();
|
|
clearStoresCache();
|
|
});
|
|
|
|
test('Renderer:button', async () => {
|
|
const {getByText, container}: any = render(
|
|
amisRender(
|
|
{
|
|
type: 'form',
|
|
title: 'The form',
|
|
controls: [
|
|
{
|
|
type: 'button',
|
|
name: 'test',
|
|
label: 'Text',
|
|
icon: 'fa fa-plus'
|
|
},
|
|
{
|
|
type: 'button',
|
|
label: 'OpenDialog',
|
|
actionType: 'dialog',
|
|
dialog: {
|
|
confirmMode: false,
|
|
title: '提示',
|
|
body: '对,你刚点击了!'
|
|
}
|
|
},
|
|
{
|
|
type: 'submit',
|
|
level: 'primary',
|
|
label: 'Submit'
|
|
},
|
|
{
|
|
type: 'reset',
|
|
label: 'Reset',
|
|
level: 'danger',
|
|
size: 'sm',
|
|
className: 'r-2x'
|
|
}
|
|
],
|
|
submitText: null,
|
|
actions: []
|
|
},
|
|
{},
|
|
makeEnv({
|
|
getModalContainer: () => container
|
|
})
|
|
)
|
|
);
|
|
expect(container).toMatchSnapshot();
|
|
fireEvent.click(getByText(/OpenDialog/));
|
|
await wait(100);
|
|
expect(container).toMatchSnapshot();
|
|
});
|