amis2/__tests__/renderers/Form/mobileInputDate.test.tsx
吴多益 a840b910e7
feat: input-date 支持手动输入 (#3677)
* feat: input-date 支持手动输入

* update snapshots
2022-03-03 14:31:35 +08:00

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