mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
26 lines
1 KiB
TypeScript
26 lines
1 KiB
TypeScript
import { screen, waitFor } from '@testing-library/react';
|
|
import { DateIntervalSelector } from '../../../src/utils/dates/DateIntervalSelector';
|
|
import type { DateInterval } from '../../../src/utils/helpers/dateIntervals';
|
|
import { rangeOrIntervalToString } from '../../../src/utils/helpers/dateIntervals';
|
|
import { renderWithEvents } from '../../__helpers__/setUpTest';
|
|
|
|
describe('<DateIntervalSelector />', () => {
|
|
const activeInterval: DateInterval = 'last7Days';
|
|
const onChange = jest.fn();
|
|
const setUp = () => renderWithEvents(
|
|
<DateIntervalSelector allText="All text" active={activeInterval} onChange={onChange} />,
|
|
);
|
|
|
|
it('passes props down to nested DateIntervalDropdownItems', async () => {
|
|
const { user } = setUp();
|
|
const btn = screen.getByRole('button');
|
|
|
|
await user.click(btn);
|
|
await waitFor(() => expect(screen.getByRole('menu')).toBeInTheDocument());
|
|
|
|
const items = screen.getAllByRole('menuitem');
|
|
|
|
expect(btn).toHaveTextContent(rangeOrIntervalToString(activeInterval) ?? '');
|
|
expect(items).toHaveLength(8);
|
|
});
|
|
});
|