mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 20:18:03 +08:00
a840b910e7
* feat: input-date 支持手动输入 * update snapshots
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import React = require('react');
|
|
import {render, fireEvent} from '@testing-library/react';
|
|
import '../../../src/themes/default';
|
|
import moment from 'moment';
|
|
import {render as amisRender} from '../../../src/index';
|
|
import {createMockMediaMatcher, makeEnv} from '../../helper';
|
|
|
|
let originalMatchMedia: any;
|
|
|
|
beforeAll(() => {
|
|
originalMatchMedia = window.matchMedia;
|
|
window.matchMedia = createMockMediaMatcher(true);
|
|
});
|
|
|
|
afterAll(() => {
|
|
window.matchMedia = originalMatchMedia;
|
|
});
|
|
|
|
test('Renderer:mobile Input Date', async () => {
|
|
const {container, findByPlaceholderText, getByText} = render(
|
|
amisRender(
|
|
{
|
|
type: 'form',
|
|
api: '/api/mock2/form/saveForm',
|
|
body: [
|
|
{
|
|
type: 'input-date',
|
|
name: 'date',
|
|
label: '日期'
|
|
}
|
|
]
|
|
},
|
|
{},
|
|
makeEnv({})
|
|
)
|
|
);
|
|
|
|
const inputDate = await findByPlaceholderText('请选择日期');
|
|
fireEvent.click(inputDate);
|
|
|
|
const confirmButton = document.querySelector(
|
|
'.cxd-PickerColumns-confirm'
|
|
) as HTMLButtonElement;
|
|
|
|
fireEvent.click(confirmButton);
|
|
|
|
// const value = document.querySelector(
|
|
// '.cxd-DatePicker-value'
|
|
// ) as HTMLSpanElement;
|
|
|
|
// TODO: 这里原组件的日错了,等修复
|
|
// expect(value.innerHTML).toEqual(moment().format('YYYY-MM-DD'));
|
|
});
|