mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-03 06:11:48 +00:00
Moved common test set-up code to helper function
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import { DateIntervalDropdownItems } from '../../../src/utils/dates/DateIntervalDropdownItems';
|
||||
import { DATE_INTERVALS, DateInterval, rangeOrIntervalToString } from '../../../src/utils/dates/types';
|
||||
import { DropdownBtn } from '../../../src/utils/DropdownBtn';
|
||||
import { renderWithEvents } from '../../__mocks__/setUpTest';
|
||||
|
||||
describe('<DateIntervalDropdownItems />', () => {
|
||||
const onChange = jest.fn();
|
||||
const setUp = async () => {
|
||||
const user = userEvent.setup();
|
||||
const renderResult = render(
|
||||
const { user, ...renderResult } = renderWithEvents(
|
||||
<DropdownBtn text="text">
|
||||
<DateIntervalDropdownItems allText="All" active="last180Days" onChange={onChange} />
|
||||
</DropdownBtn>,
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import { DateInterval, rangeOrIntervalToString } from '../../../src/utils/dates/types';
|
||||
import { DateIntervalSelector } from '../../../src/utils/dates/DateIntervalSelector';
|
||||
import { renderWithEvents } from '../../__mocks__/setUpTest';
|
||||
|
||||
describe('<DateIntervalSelector />', () => {
|
||||
const activeInterval: DateInterval = 'last7Days';
|
||||
const onChange = jest.fn();
|
||||
const setUp = () => ({
|
||||
user: userEvent.setup(),
|
||||
...render(<DateIntervalSelector allText="All text" active={activeInterval} onChange={onChange} />),
|
||||
});
|
||||
const setUp = () => renderWithEvents(
|
||||
<DateIntervalSelector allText="All text" active={activeInterval} onChange={onChange} />,
|
||||
);
|
||||
|
||||
it('passes props down to nested DateIntervalDropdownItems', async () => {
|
||||
const { user } = setUp();
|
||||
|
||||
Reference in New Issue
Block a user