amis/__tests__/renderers/DropDownButton.test.tsx

51 lines
1.3 KiB
TypeScript
Raw Normal View History

2019-07-04 16:22:24 +08:00
import React = require('react');
import {render, fireEvent} from '@testing-library/react';
2019-07-04 16:22:24 +08:00
import '../../src/themes/default';
import {render as amisRender} from '../../src/index';
import {makeEnv} from '../helper';
2019-07-04 16:22:24 +08:00
test('Renderer:dropdown-button', async () => {
const {container} = render(
amisRender(
{
2019-07-04 16:22:24 +08:00
type: 'dropdown-button',
level: 'primary',
buttons: [
{
type: 'button',
label: '按钮',
actionType: 'dialog',
dialog: {
title: '系统提示',
body: '对你点击了'
2019-07-04 16:22:24 +08:00
}
},
{
type: 'button',
label: '按钮',
actionType: 'dialog',
dialog: {
title: '系统提示',
body: '对你点击了'
}
},
{
type: 'button',
label: '按钮',
visible: false
}
2019-07-04 16:22:24 +08:00
],
className: 'show'
},
{},
makeEnv({})
)
);
2019-07-04 16:22:24 +08:00
const dropdowmButton = document.querySelector('button.cxd-Button');
fireEvent.click(dropdowmButton as HTMLDivElement);
expect(container).toMatchSnapshot();
fireEvent.click(dropdowmButton as HTMLDivElement);
expect(container).toMatchSnapshot();
});