Skip to content

Commit 643e0dd

Browse files
committed
[EuiAbsoluteTab] Test forgiving parsing
1 parent 84cf07c commit 643e0dd

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

packages/eui/src/components/date_picker/super_date_picker/date_popover/absolute_tab.test.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,31 @@ describe('EuiAbsoluteTab', () => {
123123
expect(input).toHaveValue('Jan 31st 01');
124124
});
125125

126+
it('can be forgiving with `dateFormat`', () => {
127+
const { getByTestSubject } = render(
128+
<EuiAbsoluteTab
129+
{...props}
130+
dateFormat="MMM D, YYYY HH:mm:ss"
131+
locale="en"
132+
/>
133+
);
134+
const input = getByTestSubject(
135+
'superDatePickerAbsoluteDateInput'
136+
) as HTMLInputElement;
137+
138+
changeInput(input, 'Jan 31, 1993');
139+
expect(input).not.toBeInvalid();
140+
expect(input).toHaveValue('Jan 31, 1993 00:00:00');
141+
142+
changeInput(input, 'Jan 31');
143+
expect(input).not.toBeInvalid();
144+
expect(input.value).toContain('Jan 31, ');
145+
146+
changeInput(input, 'Jan');
147+
expect(input).not.toBeInvalid();
148+
expect(input.value).toContain('Jan 1, ');
149+
});
150+
126151
describe('parses date string in locale', () => {
127152
test.each<{
128153
locale: LocaleSpecifier;

0 commit comments

Comments
 (0)