mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-20 21:46:20 +00:00
Added test covering custom formatting in DateInput
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { parseISO } from 'date-fns';
|
||||
import { DateInput, DateInputProps } from '../../src/utils/DateInput';
|
||||
import { renderWithEvents } from '../__helpers__/setUpTest';
|
||||
|
||||
@@ -30,4 +31,14 @@ describe('<DateInput />', () => {
|
||||
await user.click(screen.getByPlaceholderText('foo'));
|
||||
await waitFor(() => expect(container.querySelector('.react-datepicker')).toBeInTheDocument());
|
||||
});
|
||||
|
||||
it.each([
|
||||
[undefined, '2022-01-01'],
|
||||
['yyyy-MM-dd', '2022-01-01'],
|
||||
['yyyy-MM-dd HH:mm', '2022-01-01 15:18'],
|
||||
['HH:mm:ss', '15:18:36'],
|
||||
])('shows date in expected format', (dateFormat, expectedValue) => {
|
||||
setUp({ placeholderText: 'foo', selected: parseISO('2022-01-01T15:18:36'), dateFormat });
|
||||
expect(screen.getByPlaceholderText('foo')).toHaveValue(expectedValue);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user