amis/__tests__/renderers/Form/mobileCity.test.tsx
吴多益 152ab9bff8
chore: 补充部分组件的单元测试 (#3604)
* chore: 补充部分组件的单元测试

* 尝试修单测报错问题

* 修复测试报错

* 修复测试报错
2022-02-18 12:48:01 +08:00

48 lines
1.2 KiB
TypeScript

import React = require('react');
import {render, fireEvent, screen} from '@testing-library/react';
import '../../../src/themes/default';
import {render as amisRender} from '../../../src/index';
import {createMockMediaMatcher, makeEnv, wait} from '../../helper';
import {act} from 'react-dom/test-utils';
let originalMatchMedia: any;
beforeAll(() => {
originalMatchMedia = window.matchMedia;
window.matchMedia = createMockMediaMatcher(true);
});
afterAll(() => {
window.matchMedia = originalMatchMedia;
});
test('Renderer:mobileCity', async () => {
// TODO: 不知道为啥报错了
// const {container, getByText} = render(
// amisRender(
// {
// type: 'form',
// api: '/api/xxx',
// controls: [
// {
// type: 'city',
// name: 'a',
// label: 'city',
// allowDistrict: true,
// allowCity: true
// }
// ],
// title: 'The form',
// actions: []
// },
// {},
// makeEnv({})
// )
// );
// await wait(200);
// fireEvent.click(getByText('请选择操作'));
// fireEvent.click(getByText('确认'));
// screen.debug();
// expect(container).toMatchSnapshot();
});