mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-05 05:18:34 +08:00
ed69ac05aa
* 补充部分单测 * 补充部分单元测试 * 补充部分组件的单元测试
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import React = require('react');
|
|
import {render} from '@testing-library/react';
|
|
import '../../../src/themes/default';
|
|
import {render as amisRender} from '../../../src/index';
|
|
import {makeEnv} from '../../helper';
|
|
|
|
test('Renderer:chained-select', async () => {
|
|
const {container, findByText} = render(
|
|
amisRender(
|
|
{
|
|
type: 'form',
|
|
debug: true,
|
|
api: '/api/mock2/form/saveForm',
|
|
body: [
|
|
{
|
|
name: 'select3',
|
|
type: 'chained-select',
|
|
label: '级联下拉',
|
|
source:
|
|
'/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4',
|
|
value: 'a,b'
|
|
}
|
|
]
|
|
},
|
|
{},
|
|
makeEnv({
|
|
fetcher: async (config: any) => {
|
|
return {
|
|
status: 200,
|
|
headers: {},
|
|
data: {
|
|
status: 0,
|
|
msg: '',
|
|
data: [
|
|
{label: 'A 0', value: 'a'},
|
|
{label: 'B 0', value: 'b'},
|
|
{label: 'C 0', value: 'c'},
|
|
{label: 'D 0', value: 'd'}
|
|
]
|
|
}
|
|
};
|
|
}
|
|
})
|
|
)
|
|
);
|
|
|
|
await findByText('A 0');
|
|
|
|
expect(container).toMatchSnapshot();
|
|
});
|