-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use non timezone-aware date APIs in date time picker #8021 (CP:…
… 24.4) (#8027)
- Loading branch information
1 parent
be0dfd3
commit 073c99a
Showing
5 changed files
with
187 additions
and
58 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
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
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,37 @@ | ||
import { expect } from '@esm-bundle/chai'; | ||
import { fixtureSync } from '@vaadin/testing-helpers'; | ||
import '../src/vaadin-date-time-picker.js'; | ||
|
||
describe('timezone independent', () => { | ||
let dateTimePicker; | ||
let datePicker; | ||
let timePicker; | ||
|
||
beforeEach(() => { | ||
dateTimePicker = fixtureSync('<vaadin-date-time-picker></vaadin-date-time-picker>'); | ||
datePicker = dateTimePicker.querySelector('[slot="date-picker"]'); | ||
timePicker = dateTimePicker.querySelector('[slot="time-picker"]'); | ||
}); | ||
|
||
it('should not skip missing hour from DST switch', () => { | ||
// There's no good way to mock the system timezone, so use multiple test | ||
// cases to cover different timezones, in one of which this test hopefully | ||
// runs. The setup should verify that the component does not use the system | ||
// timezone to manipulate date instances, which would lead to skipping an | ||
// hour when entering the date and time of DST start, as this is an hour | ||
// that does not exist in timezones that use DST. | ||
const testCases = [ | ||
'2024-03-10T02:00', // US Eastern DST start | ||
'2024-03-31T02:00', // Central european DST start | ||
'2024-03-31T03:00', // Eastern european DST start | ||
]; | ||
|
||
testCases.forEach((value) => { | ||
const [date, time] = value.split('T'); | ||
datePicker.value = date; | ||
timePicker.value = time; | ||
|
||
expect(dateTimePicker.value).to.equal(value); | ||
}); | ||
}); | ||
}); |