Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix act errors in CustomFrame test #21427

Merged
merged 1 commit into from
Sep 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { render, screen } from 'spec/helpers/testing-library';
import userEvent from '@testing-library/user-event';
import { CustomFrame } from '.';

jest.useFakeTimers();

const emptyValue = '';
const nowValue = 'now : now';
const todayValue = 'today : today';
Expand Down Expand Up @@ -137,16 +139,20 @@ test('triggers onChange when the value changes', () => {
expect(onChange).toHaveBeenCalled();
});

test('triggers onChange when the mode changes', () => {
test('triggers onChange when the mode changes', async () => {
const onChange = jest.fn();
render(
<Provider store={store}>
<CustomFrame onChange={onChange} value={todayNowValue} />
</Provider>,
);
userEvent.click(screen.getByTitle('Midnight'));
expect(await screen.findByTitle('Relative Date/Time')).toBeInTheDocument();
userEvent.click(screen.getByTitle('Relative Date/Time'));
userEvent.click(screen.getAllByTitle('Now')[1]);
expect(
await screen.findByText('Configure custom time range'),
).toBeInTheDocument();
userEvent.click(screen.getAllByTitle('Specific Date/Time')[1]);
expect(onChange).toHaveBeenCalledTimes(2);
});
Expand All @@ -159,8 +165,10 @@ test('triggers onChange when the grain changes', async () => {
</Provider>,
);
userEvent.click(screen.getByText('Days Before'));
expect(await screen.findByText('Weeks Before')).toBeInTheDocument();
userEvent.click(screen.getByText('Weeks Before'));
userEvent.click(screen.getByText('Days After'));
expect(await screen.findByText('Weeks After')).toBeInTheDocument();
userEvent.click(screen.getByText('Weeks After'));
expect(onChange).toHaveBeenCalledTimes(2);
});
Expand Down