mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-05 05:18:34 +08:00
ed69ac05aa
* 补充部分单测 * 补充部分单元测试 * 补充部分组件的单元测试
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import React = require('react');
|
|
import PageRenderer from '../../../src/renderers/Form';
|
|
import * as renderer from 'react-test-renderer';
|
|
import {render, fireEvent, cleanup, getByText} from '@testing-library/react';
|
|
import '../../../src/themes/default';
|
|
import {render as amisRender} from '../../../src/index';
|
|
import {makeEnv} from '../../helper';
|
|
import moment from 'moment';
|
|
|
|
test('Renderer:inputYear click', async () => {
|
|
const {container, findByText} = render(
|
|
amisRender(
|
|
{
|
|
type: 'form',
|
|
api: '/api/xxx',
|
|
body: [
|
|
{
|
|
type: 'input-year',
|
|
name: 'year',
|
|
label: '年'
|
|
}
|
|
],
|
|
title: 'The form',
|
|
actions: []
|
|
},
|
|
{},
|
|
makeEnv({})
|
|
)
|
|
);
|
|
|
|
const inputDate = await findByText('请选择年');
|
|
|
|
fireEvent.click(inputDate);
|
|
|
|
const thisYearText = moment().format('YYYY');
|
|
|
|
const thisYear = await findByText(thisYearText);
|
|
|
|
fireEvent.click(thisYear);
|
|
|
|
const value = document.querySelector(
|
|
'.cxd-DatePicker-value'
|
|
) as HTMLSpanElement;
|
|
|
|
expect(value.innerHTML).toEqual(thisYearText);
|
|
});
|