mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 12:08:13 +08:00
ed69ac05aa
* 补充部分单测 * 补充部分单元测试 * 补充部分组件的单元测试
71 lines
1.5 KiB
TypeScript
71 lines
1.5 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, wait} from '../helper';
|
|
import rows from '../mockData/rows';
|
|
|
|
test('Renderer:crud', async () => {
|
|
const {container, findByText} = render(
|
|
amisRender(
|
|
{
|
|
type: 'page',
|
|
body: {
|
|
type: 'crud',
|
|
api: '/api/mock2/sample',
|
|
syncLocation: false,
|
|
columns: [
|
|
{
|
|
name: 'id',
|
|
label: 'ID'
|
|
},
|
|
{
|
|
name: 'engine',
|
|
label: 'Rendering engine'
|
|
},
|
|
{
|
|
name: 'browser',
|
|
label: 'Browser'
|
|
},
|
|
{
|
|
name: 'platform',
|
|
label: 'Platform(s)'
|
|
},
|
|
{
|
|
name: 'version',
|
|
label: 'Engine version'
|
|
},
|
|
{
|
|
name: 'grade',
|
|
label: 'CSS grade'
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{},
|
|
makeEnv({
|
|
fetcher: async (config: any) => {
|
|
return {
|
|
status: 200,
|
|
headers: {},
|
|
data: {
|
|
status: 0,
|
|
msg: '',
|
|
data: {
|
|
count: 1,
|
|
rows
|
|
}
|
|
}
|
|
};
|
|
}
|
|
})
|
|
)
|
|
);
|
|
|
|
await findByText('Internet Explorer 4.0');
|
|
|
|
await wait(1000);
|
|
|
|
expect(container).toMatchSnapshot();
|
|
});
|