-
Notifications
You must be signed in to change notification settings - Fork 85
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
) * fix: use non timezone-aware date instances in date time picker * add test case * reduce code duplication Co-authored-by: Sascha Ißbrücker <[email protected]>
- Loading branch information
1 parent
d25327c
commit cec1366
Showing
5 changed files
with
177 additions
and
56 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 '@vaadin/chai-plugins'; | ||
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); | ||
}); | ||
}); | ||
}); |