-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Lukas Tyla <[email protected]>
- Loading branch information
Showing
5 changed files
with
124 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/x-date-pickers-pro/src/DateRangeCalendar/timezone.DateRangeCalendar.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as React from 'react'; | ||
import { expect } from 'chai'; | ||
import { screen, fireEvent } from '@mui/internal-test-utils'; | ||
import { describeAdapters } from 'test/utils/pickers'; | ||
import { DateRangeCalendar } from './DateRangeCalendar'; | ||
|
||
describe('<DateRangeCalendar /> - Timezone', () => { | ||
describeAdapters('Timezone prop', DateRangeCalendar, ({ adapter, render }) => { | ||
if (!adapter.isTimezoneCompatible) { | ||
return; | ||
} | ||
|
||
it('should correctly render month days when timezone changes', () => { | ||
function DateCalendarWithControlledTimezone() { | ||
const [timezone, setTimezone] = React.useState('Europe/Paris'); | ||
return ( | ||
<React.Fragment> | ||
<DateRangeCalendar timezone={timezone} calendars={1} /> | ||
<button onClick={() => setTimezone('America/New_York')}>Switch timezone</button> | ||
</React.Fragment> | ||
); | ||
} | ||
render(<DateCalendarWithControlledTimezone />); | ||
|
||
expect( | ||
screen.getAllByRole('gridcell', { | ||
name: (_, element) => element.nodeName === 'BUTTON', | ||
}).length, | ||
).to.equal(30); | ||
|
||
fireEvent.click(screen.getByRole('button', { name: 'Switch timezone' })); | ||
|
||
// the amount of rendered days should remain the same after changing timezone | ||
expect( | ||
screen.getAllByRole('gridcell', { | ||
name: (_, element) => element.nodeName === 'BUTTON', | ||
}).length, | ||
).to.equal(30); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters