amis/__tests__/renderers/Form/chainedSelect.test.tsx
吴多益 ed69ac05aa
chore: 补充部分组件的单测,行覆盖率到 56% (#3567)
* 补充部分单测

* 补充部分单元测试

* 补充部分组件的单元测试
2022-02-11 19:36:45 +08:00

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();
});