amis2/__tests__/renderers/Date.test.tsx

34 lines
820 B
TypeScript
Raw Normal View History

2019-07-04 16:24:13 +08:00
import React = require('react');
import {render} from '@testing-library/react';
2019-07-04 16:24:13 +08:00
import '../../src/themes/default';
2021-02-03 23:39:37 +08:00
import {render as amisRender} from '../../src/index';
import {makeEnv} from '../helper';
import moment from 'moment';
2019-07-04 16:24:13 +08:00
test('Renderer:date', async () => {
2021-02-03 23:39:37 +08:00
const {container} = render(
amisRender(
{
2019-07-04 16:24:13 +08:00
type: 'date',
name: 'date',
label: 'date',
value: '1559836800',
format: 'YYYY-MM-DD',
placeholder: '请选择时间',
minDate: '1559664000',
maxDate: '1561737600',
className: 'show'
2021-02-03 23:39:37 +08:00
},
{},
makeEnv({})
)
);
2019-07-04 16:24:13 +08:00
2021-02-03 23:39:37 +08:00
const input = container.querySelector('.a-DateField');
expect(input?.innerHTML).toEqual(
moment('1559836800', 'X').format('YYYY-MM-DD')
);
2019-07-04 16:24:13 +08:00
2021-02-03 23:39:37 +08:00
expect(container).toMatchSnapshot();
});