Skip to content

Commit

Permalink
Try fixing unstable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy committed Sep 5, 2024
1 parent 1bb883a commit 6ee336e
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createPickerRenderer, adapterToUse } from 'test/utils/pickers';
const isJSDOM = /jsdom/.test(window.navigator.userAgent);

describe('<DateCalendar />', () => {
const { render } = createPickerRenderer();
const { render, clock } = createPickerRenderer({ clockConfig: new Date(2019, 0, 2) });

it('switches between views uncontrolled', async () => {
const handleViewChange = spy();
Expand Down Expand Up @@ -128,17 +128,13 @@ describe('<DateCalendar />', () => {
});

describe('with fake timers', () => {
const { render: renderWithFakeTimers, clock } = createPickerRenderer({
clock: 'fake',
clockConfig: new Date('2019-01-02'),
});
clock.withFakeTimers();

// test: https://github.com/mui/mui-x/issues/12373
it('should not reset day to `startOfDay` if value already exists when finding the closest enabled date', () => {
const onChange = spy();
const defaultDate = adapterToUse.date('2019-01-02T11:12:13.550Z');
renderWithFakeTimers(
<DateCalendar onChange={onChange} disablePast defaultValue={defaultDate} />,
);
render(<DateCalendar onChange={onChange} disablePast defaultValue={defaultDate} />);

fireEvent.click(
screen.getByRole('button', { name: 'calendar view is open, switch to year view' }),
Expand Down

0 comments on commit 6ee336e

Please sign in to comment.