Skip to content

Commit 220c827

Browse files
authored
Merge pull request #344 from lutovich/1.6-temporal-its-valid-time
Fix temporal ITs to only generate DST-safe time
2 parents 3c80dc9 + 2712db5 commit 220c827

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

test/v1/temporal-types.test.js

+16-9
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,7 @@ const MIN_TIME_ZONE_OFFSET = -MAX_TIME_ZONE_OFFSET;
3232
const SECONDS_PER_MINUTE = 60;
3333
const MIN_ZONE_ID = 'Etc/GMT+12';
3434
const MAX_ZONE_ID = 'Etc/GMT-14';
35-
const ZONE_IDS = ['Europe/Zaporozhye', 'America/Argentina/Mendoza', 'Etc/GMT-12', 'Asia/Jayapura', 'Pacific/Auckland', 'America/Argentina/Rio_Gallegos',
36-
'America/Tegucigalpa', 'Europe/Skopje', 'Africa/Lome', 'America/Eirunepe', 'Pacific/Port_Moresby', 'America/Merida', 'Asia/Qyzylorda', 'Hongkong',
37-
'America/Paramaribo', 'Pacific/Wallis', 'Antarctica/Mawson', 'America/Metlakatla', 'Indian/Reunion', 'Asia/Chungking', 'Canada/Central', 'Etc/GMT-6',
38-
'UCT', 'America/Belem', 'Europe/Belgrade', 'Singapore', 'Israel', 'Europe/London', 'America/Yellowknife', 'Europe/Uzhgorod', 'Etc/GMT+7',
39-
'America/Indiana/Winamac', 'Asia/Kuala_Lumpur', 'America/Cuiaba', 'Europe/Sofia', 'Asia/Kuching', 'Australia/Lord_Howe', 'America/Porto_Acre',
40-
'America/Indiana/Indianapolis', 'Africa/Windhoek', 'Atlantic/Cape_Verde', 'Asia/Kuwait', 'America/Barbados', 'Egypt', 'GB-Eire', 'Antarctica/South_Pole',
41-
'America/Kentucky/Louisville', 'Asia/Yangon', 'CET', 'Etc/GMT+11', 'Asia/Dubai', 'Europe/Stockholm'];
35+
const ZONE_IDS = ['Europe/Zaporozhye', 'Europe/London', 'UTC', 'Africa/Cairo'];
4236

4337
describe('temporal-types', () => {
4438

@@ -434,18 +428,22 @@ describe('temporal-types', () => {
434428

435429
function randomDateTimeWithZoneOffset() {
436430
return new neo4j.DateTimeWithZoneOffset(
437-
randomLocalDateTime(),
431+
randomDstSafeLocalDateTime(),
438432
randomZoneOffsetSeconds()
439433
);
440434
}
441435

442436
function randomDateTimeWithZoneId() {
443437
return new neo4j.DateTimeWithZoneId(
444-
randomLocalDateTime(),
438+
randomDstSafeLocalDateTime(),
445439
randomZoneId()
446440
);
447441
}
448442

443+
function randomDstSafeLocalDateTime() {
444+
return new neo4j.LocalDateTime(randomDate(), randomDstSafeLocalTime());
445+
}
446+
449447
function randomLocalDateTime() {
450448
return new neo4j.LocalDateTime(randomDate(), randomLocalTime());
451449
}
@@ -474,6 +472,15 @@ describe('temporal-types', () => {
474472
);
475473
}
476474

475+
function randomDstSafeLocalTime() {
476+
return new neo4j.LocalTime(
477+
randomInt(4, 23), // do not generate hours in range where DST adjustment happens
478+
randomInt(0, 59),
479+
randomInt(0, 59),
480+
randomInt(0, MAX_NANO_OF_SECOND)
481+
);
482+
}
483+
477484
function randomZoneOffsetSeconds() {
478485
const randomOffsetWithSeconds = neo4j.int(randomInt(MIN_TIME_ZONE_OFFSET, MAX_TIME_ZONE_OFFSET));
479486
return randomOffsetWithSeconds.div(SECONDS_PER_MINUTE).multiply(SECONDS_PER_MINUTE); // truncate seconds

0 commit comments

Comments
 (0)