From da48cbda188dddeaef404e9a7ca3462d2e7a96ee Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Fri, 16 Apr 2021 18:38:31 +0300 Subject: [PATCH 1/3] Add tests for #826 --- tests/iso-date/Date.test.ts | 4 +- tests/iso-date/DateTime.test.ts | 2 +- tests/iso-date/Time.test.ts | 2 +- .../iso-date/__snapshots__/Date.test.ts.snap | 14 +- .../__snapshots__/DateTime.test.ts.snap | 130 +++++++++--------- .../iso-date/__snapshots__/Time.test.ts.snap | 110 +++++++-------- 6 files changed, 134 insertions(+), 128 deletions(-) diff --git a/tests/iso-date/Date.test.ts b/tests/iso-date/Date.test.ts index 27173188a..863a67828 100644 --- a/tests/iso-date/Date.test.ts +++ b/tests/iso-date/Date.test.ts @@ -12,7 +12,7 @@ import { Kind } from 'graphql'; // flowlint-next-line untyped-import:off import { stringify } from 'jest-matcher-utils'; -const invalidDates = ['invalid date', '2015-02-29']; +const invalidDates = ['invalid date', '2015-02-29', '2021-07-32']; const validDates = [ ['2016-12-17', new Date(Date.UTC(2016, 11, 17))], @@ -97,7 +97,7 @@ describe('GraphQLDate', () => { }); }); - describe('literial parsing', () => { + describe('literal parsing', () => { validDates.forEach(([value, expected]) => { const literal = { kind: Kind.STRING, diff --git a/tests/iso-date/DateTime.test.ts b/tests/iso-date/DateTime.test.ts index cb9a70c5b..898df892a 100644 --- a/tests/iso-date/DateTime.test.ts +++ b/tests/iso-date/DateTime.test.ts @@ -144,7 +144,7 @@ describe('GraphQLDateTime', () => { }); }); - describe('literial parsing', () => { + describe('literal parsing', () => { validDates.forEach(([value, expected]) => { const literal = { kind: Kind.STRING, diff --git a/tests/iso-date/Time.test.ts b/tests/iso-date/Time.test.ts index 34990ebb2..e9c4872b5 100644 --- a/tests/iso-date/Time.test.ts +++ b/tests/iso-date/Time.test.ts @@ -119,7 +119,7 @@ describe('GraphQLTime', () => { }); }); - describe('literial parsing', () => { + describe('literal parsing', () => { validDates.forEach(([value, expected]) => { const literal = { kind: Kind.STRING, diff --git a/tests/iso-date/__snapshots__/Date.test.ts.snap b/tests/iso-date/__snapshots__/Date.test.ts.snap index 2fad16afc..ab823d7a2 100644 --- a/tests/iso-date/__snapshots__/Date.test.ts.snap +++ b/tests/iso-date/__snapshots__/Date.test.ts.snap @@ -2,16 +2,20 @@ exports[`GraphQLDate has a description 1`] = `"A date string, such as 2007-12-03, compliant with the \`full-date\` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar."`; -exports[`GraphQLDate literial parsing errors when parsing invalid literal {"kind": "Document"} 1`] = `"Date cannot represent non string type false"`; +exports[`GraphQLDate literal parsing errors when parsing invalid literal {"kind": "Document"} 1`] = `"Date cannot represent non string type false"`; -exports[`GraphQLDate literial parsing errors when parsing invalid literal {"kind": "FloatValue", "value": "5"} 1`] = `"Date cannot represent non string type 5"`; +exports[`GraphQLDate literal parsing errors when parsing invalid literal {"kind": "FloatValue", "value": "5"} 1`] = `"Date cannot represent non string type 5"`; -exports[`GraphQLDate literial parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2015-02-29"} 1`] = `"Date cannot represent an invalid date-string 2015-02-29."`; +exports[`GraphQLDate literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2015-02-29"} 1`] = `"Date cannot represent an invalid date-string 2015-02-29."`; -exports[`GraphQLDate literial parsing errors when parsing invalid literal {"kind": "StringValue", "value": "invalid date"} 1`] = `"Date cannot represent an invalid date-string invalid date."`; +exports[`GraphQLDate literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2021-07-32"} 1`] = `"Date cannot represent an invalid date-string 2021-07-32."`; + +exports[`GraphQLDate literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "invalid date"} 1`] = `"Date cannot represent an invalid date-string invalid date."`; exports[`GraphQLDate serialization throws an error when serializing an invalid date-string "2015-02-29" 1`] = `"Date cannot represent an invalid date-string 2015-02-29."`; +exports[`GraphQLDate serialization throws an error when serializing an invalid date-string "2021-07-32" 1`] = `"Date cannot represent an invalid date-string 2021-07-32."`; + exports[`GraphQLDate serialization throws an error when serializing an invalid date-string "invalid date" 1`] = `"Date cannot represent an invalid date-string invalid date."`; exports[`GraphQLDate serialization throws error when serializing [] 1`] = `"Date cannot represent a non string, or non Date type []"`; @@ -28,6 +32,8 @@ exports[`GraphQLDate serialization throws error when serializing undefined 1`] = exports[`GraphQLDate value parsing throws an error parsing an invalid datetime-string "2015-02-29" 1`] = `"Date cannot represent an invalid date-string 2015-02-29."`; +exports[`GraphQLDate value parsing throws an error parsing an invalid datetime-string "2021-07-32" 1`] = `"Date cannot represent an invalid date-string 2021-07-32."`; + exports[`GraphQLDate value parsing throws an error parsing an invalid datetime-string "invalid date" 1`] = `"Date cannot represent an invalid date-string invalid date."`; exports[`GraphQLDate value parsing throws an error when parsing [] 1`] = `"Date cannot represent non string type []"`; diff --git a/tests/iso-date/__snapshots__/DateTime.test.ts.snap b/tests/iso-date/__snapshots__/DateTime.test.ts.snap index 7f849e14f..a75c80670 100644 --- a/tests/iso-date/__snapshots__/DateTime.test.ts.snap +++ b/tests/iso-date/__snapshots__/DateTime.test.ts.snap @@ -1,65 +1,65 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`GraphQLDateTime has a description 1`] = `"A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the \`date-time\` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar."`; - -exports[`GraphQLDateTime literial parsing errors when parsing invalid literal {"kind": "Document"} 1`] = `"DateTime cannot represent non string or Date type false"`; - -exports[`GraphQLDateTime literial parsing errors when parsing invalid literal {"kind": "FloatValue", "value": "5"} 1`] = `"DateTime cannot represent non string or Date type 5"`; - -exports[`GraphQLDateTime literial parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2015-02-24T00:00:00.000+0100"} 1`] = `"DateTime cannot represent an invalid date-time-string 2015-02-24T00:00:00.000+0100."`; - -exports[`GraphQLDateTime literial parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2016-02-01T00:00:00.Z"} 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00:00:00.Z."`; - -exports[`GraphQLDateTime literial parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2016-02-01T00:00Z"} 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00:00Z."`; - -exports[`GraphQLDateTime literial parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2016-02-01T000059Z"} 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T000059Z."`; - -exports[`GraphQLDateTime literial parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2016-02-01T00Z"} 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00Z."`; - -exports[`GraphQLDateTime literial parsing errors when parsing invalid literal {"kind": "StringValue", "value": "Invalid date"} 1`] = `"DateTime cannot represent an invalid date-time-string Invalid date."`; - -exports[`GraphQLDateTime serialization throws an error when serializing an invalid date-string "2015-02-24T00:00:00.000+0100" 1`] = `"DateTime cannot represent an invalid date-time-string 2015-02-24T00:00:00.000+0100."`; - -exports[`GraphQLDateTime serialization throws an error when serializing an invalid date-string "2016-02-01T00:00:00.Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00:00:00.Z."`; - -exports[`GraphQLDateTime serialization throws an error when serializing an invalid date-string "2016-02-01T00:00Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00:00Z."`; - -exports[`GraphQLDateTime serialization throws an error when serializing an invalid date-string "2016-02-01T000059Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T000059Z."`; - -exports[`GraphQLDateTime serialization throws an error when serializing an invalid date-string "2016-02-01T00Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00Z."`; - -exports[`GraphQLDateTime serialization throws an error when serializing an invalid date-string "Invalid date" 1`] = `"DateTime cannot represent an invalid date-time-string Invalid date."`; - -exports[`GraphQLDateTime serialization throws error when serializing [] 1`] = `"DateTime cannot be serialized from a non string, non numeric or non Date type []"`; - -exports[`GraphQLDateTime serialization throws error when serializing {} 1`] = `"DateTime cannot be serialized from a non string, non numeric or non Date type {}"`; - -exports[`GraphQLDateTime serialization throws error when serializing invalid date 1`] = `"DateTime cannot represent an invalid Date instance"`; - -exports[`GraphQLDateTime serialization throws error when serializing null 1`] = `"DateTime cannot be serialized from a non string, non numeric or non Date type null"`; - -exports[`GraphQLDateTime serialization throws error when serializing true 1`] = `"DateTime cannot be serialized from a non string, non numeric or non Date type true"`; - -exports[`GraphQLDateTime serialization throws error when serializing undefined 1`] = `"DateTime cannot be serialized from a non string, non numeric or non Date type undefined"`; - -exports[`GraphQLDateTime value parsing throws an error parsing an invalid date-string "2015-02-24T00:00:00.000+0100" 1`] = `"DateTime cannot represent an invalid date-time-string 2015-02-24T00:00:00.000+0100."`; - -exports[`GraphQLDateTime value parsing throws an error parsing an invalid date-string "2016-02-01T00:00:00.Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00:00:00.Z."`; - -exports[`GraphQLDateTime value parsing throws an error parsing an invalid date-string "2016-02-01T00:00Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00:00Z."`; - -exports[`GraphQLDateTime value parsing throws an error parsing an invalid date-string "2016-02-01T000059Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T000059Z."`; - -exports[`GraphQLDateTime value parsing throws an error parsing an invalid date-string "2016-02-01T00Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00Z."`; - -exports[`GraphQLDateTime value parsing throws an error parsing an invalid date-string "Invalid date" 1`] = `"DateTime cannot represent an invalid date-time-string Invalid date."`; - -exports[`GraphQLDateTime value parsing throws an error when parsing [] 1`] = `"DateTime cannot represent non string or Date type []"`; - -exports[`GraphQLDateTime value parsing throws an error when parsing {} 1`] = `"DateTime cannot represent non string or Date type {}"`; - -exports[`GraphQLDateTime value parsing throws an error when parsing 4566 1`] = `"DateTime cannot represent non string or Date type 4566"`; - -exports[`GraphQLDateTime value parsing throws an error when parsing null 1`] = `"DateTime cannot represent non string or Date type null"`; - -exports[`GraphQLDateTime value parsing throws an error when parsing true 1`] = `"DateTime cannot represent non string or Date type true"`; +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`GraphQLDateTime has a description 1`] = `"A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the \`date-time\` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar."`; + +exports[`GraphQLDateTime literal parsing errors when parsing invalid literal {"kind": "Document"} 1`] = `"DateTime cannot represent non string or Date type false"`; + +exports[`GraphQLDateTime literal parsing errors when parsing invalid literal {"kind": "FloatValue", "value": "5"} 1`] = `"DateTime cannot represent non string or Date type 5"`; + +exports[`GraphQLDateTime literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2015-02-24T00:00:00.000+0100"} 1`] = `"DateTime cannot represent an invalid date-time-string 2015-02-24T00:00:00.000+0100."`; + +exports[`GraphQLDateTime literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2016-02-01T00:00:00.Z"} 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00:00:00.Z."`; + +exports[`GraphQLDateTime literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2016-02-01T00:00Z"} 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00:00Z."`; + +exports[`GraphQLDateTime literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2016-02-01T000059Z"} 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T000059Z."`; + +exports[`GraphQLDateTime literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2016-02-01T00Z"} 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00Z."`; + +exports[`GraphQLDateTime literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "Invalid date"} 1`] = `"DateTime cannot represent an invalid date-time-string Invalid date."`; + +exports[`GraphQLDateTime serialization throws an error when serializing an invalid date-string "2015-02-24T00:00:00.000+0100" 1`] = `"DateTime cannot represent an invalid date-time-string 2015-02-24T00:00:00.000+0100."`; + +exports[`GraphQLDateTime serialization throws an error when serializing an invalid date-string "2016-02-01T00:00:00.Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00:00:00.Z."`; + +exports[`GraphQLDateTime serialization throws an error when serializing an invalid date-string "2016-02-01T00:00Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00:00Z."`; + +exports[`GraphQLDateTime serialization throws an error when serializing an invalid date-string "2016-02-01T000059Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T000059Z."`; + +exports[`GraphQLDateTime serialization throws an error when serializing an invalid date-string "2016-02-01T00Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00Z."`; + +exports[`GraphQLDateTime serialization throws an error when serializing an invalid date-string "Invalid date" 1`] = `"DateTime cannot represent an invalid date-time-string Invalid date."`; + +exports[`GraphQLDateTime serialization throws error when serializing [] 1`] = `"DateTime cannot be serialized from a non string, non numeric or non Date type []"`; + +exports[`GraphQLDateTime serialization throws error when serializing {} 1`] = `"DateTime cannot be serialized from a non string, non numeric or non Date type {}"`; + +exports[`GraphQLDateTime serialization throws error when serializing invalid date 1`] = `"DateTime cannot represent an invalid Date instance"`; + +exports[`GraphQLDateTime serialization throws error when serializing null 1`] = `"DateTime cannot be serialized from a non string, non numeric or non Date type null"`; + +exports[`GraphQLDateTime serialization throws error when serializing true 1`] = `"DateTime cannot be serialized from a non string, non numeric or non Date type true"`; + +exports[`GraphQLDateTime serialization throws error when serializing undefined 1`] = `"DateTime cannot be serialized from a non string, non numeric or non Date type undefined"`; + +exports[`GraphQLDateTime value parsing throws an error parsing an invalid date-string "2015-02-24T00:00:00.000+0100" 1`] = `"DateTime cannot represent an invalid date-time-string 2015-02-24T00:00:00.000+0100."`; + +exports[`GraphQLDateTime value parsing throws an error parsing an invalid date-string "2016-02-01T00:00:00.Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00:00:00.Z."`; + +exports[`GraphQLDateTime value parsing throws an error parsing an invalid date-string "2016-02-01T00:00Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00:00Z."`; + +exports[`GraphQLDateTime value parsing throws an error parsing an invalid date-string "2016-02-01T000059Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T000059Z."`; + +exports[`GraphQLDateTime value parsing throws an error parsing an invalid date-string "2016-02-01T00Z" 1`] = `"DateTime cannot represent an invalid date-time-string 2016-02-01T00Z."`; + +exports[`GraphQLDateTime value parsing throws an error parsing an invalid date-string "Invalid date" 1`] = `"DateTime cannot represent an invalid date-time-string Invalid date."`; + +exports[`GraphQLDateTime value parsing throws an error when parsing [] 1`] = `"DateTime cannot represent non string or Date type []"`; + +exports[`GraphQLDateTime value parsing throws an error when parsing {} 1`] = `"DateTime cannot represent non string or Date type {}"`; + +exports[`GraphQLDateTime value parsing throws an error when parsing 4566 1`] = `"DateTime cannot represent non string or Date type 4566"`; + +exports[`GraphQLDateTime value parsing throws an error when parsing null 1`] = `"DateTime cannot represent non string or Date type null"`; + +exports[`GraphQLDateTime value parsing throws an error when parsing true 1`] = `"DateTime cannot represent non string or Date type true"`; diff --git a/tests/iso-date/__snapshots__/Time.test.ts.snap b/tests/iso-date/__snapshots__/Time.test.ts.snap index 83f205cfe..9c80cc57a 100644 --- a/tests/iso-date/__snapshots__/Time.test.ts.snap +++ b/tests/iso-date/__snapshots__/Time.test.ts.snap @@ -1,55 +1,55 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`GraphQLTime has a description 1`] = `"A time string at UTC, such as 10:15:30Z, compliant with the \`full-time\` format outlined in section 5.6 of the RFC 3339profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar."`; - -exports[`GraphQLTime literial parsing errors when parsing invalid literal {"kind": "StringValue", "value": "00:00:00.45+01"} 1`] = `"Time cannot represent an invalid time-string 00:00:00.45+01."`; - -exports[`GraphQLTime literial parsing errors when parsing invalid literal {"kind": "StringValue", "value": "00:00:00.45+0130"} 1`] = `"Time cannot represent an invalid time-string 00:00:00.45+0130."`; - -exports[`GraphQLTime literial parsing errors when parsing invalid literal {"kind": "StringValue", "value": "10:30:02.Z"} 1`] = `"Time cannot represent an invalid time-string 10:30:02.Z."`; - -exports[`GraphQLTime literial parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2016-01-01T00:00:00.223Z"} 1`] = `"Time cannot represent an invalid time-string 2016-01-01T00:00:00.223Z."`; - -exports[`GraphQLTime literial parsing errors when parsing invalid literal {"kind": "StringValue", "value": "Invalid date"} 1`] = `"Time cannot represent an invalid time-string Invalid date."`; - -exports[`GraphQLTime serialization throws an error when serializing an invalid date-string "00:00:00.45+01" 1`] = `"Time cannot represent an invalid time-string 00:00:00.45+01."`; - -exports[`GraphQLTime serialization throws an error when serializing an invalid date-string "00:00:00.45+0130" 1`] = `"Time cannot represent an invalid time-string 00:00:00.45+0130."`; - -exports[`GraphQLTime serialization throws an error when serializing an invalid date-string "10:30:02.Z" 1`] = `"Time cannot represent an invalid time-string 10:30:02.Z."`; - -exports[`GraphQLTime serialization throws an error when serializing an invalid date-string "2016-01-01T00:00:00.223Z" 1`] = `"Time cannot represent an invalid time-string 2016-01-01T00:00:00.223Z."`; - -exports[`GraphQLTime serialization throws an error when serializing an invalid date-string "Invalid date" 1`] = `"Time cannot represent an invalid time-string Invalid date."`; - -exports[`GraphQLTime serialization throws error when serializing [] 1`] = `"Time cannot be serialized from a non string, or non Date type []"`; - -exports[`GraphQLTime serialization throws error when serializing {} 1`] = `"Time cannot be serialized from a non string, or non Date type {}"`; - -exports[`GraphQLTime serialization throws error when serializing invalid date 1`] = `"Time cannot represent an invalid Date instance"`; - -exports[`GraphQLTime serialization throws error when serializing null 1`] = `"Time cannot be serialized from a non string, or non Date type null"`; - -exports[`GraphQLTime serialization throws error when serializing true 1`] = `"Time cannot be serialized from a non string, or non Date type true"`; - -exports[`GraphQLTime serialization throws error when serializing undefined 1`] = `"Time cannot be serialized from a non string, or non Date type undefined"`; - -exports[`GraphQLTime value parsing throws an error parsing an invalid time-string "00:00:00.45+01" 1`] = `"Time cannot represent an invalid time-string 00:00:00.45+01."`; - -exports[`GraphQLTime value parsing throws an error parsing an invalid time-string "00:00:00.45+0130" 1`] = `"Time cannot represent an invalid time-string 00:00:00.45+0130."`; - -exports[`GraphQLTime value parsing throws an error parsing an invalid time-string "10:30:02.Z" 1`] = `"Time cannot represent an invalid time-string 10:30:02.Z."`; - -exports[`GraphQLTime value parsing throws an error parsing an invalid time-string "2016-01-01T00:00:00.223Z" 1`] = `"Time cannot represent an invalid time-string 2016-01-01T00:00:00.223Z."`; - -exports[`GraphQLTime value parsing throws an error parsing an invalid time-string "Invalid date" 1`] = `"Time cannot represent an invalid time-string Invalid date."`; - -exports[`GraphQLTime value parsing throws an error when parsing [] 1`] = `"Time cannot represent non string type []"`; - -exports[`GraphQLTime value parsing throws an error when parsing {} 1`] = `"Time cannot represent non string type {}"`; - -exports[`GraphQLTime value parsing throws an error when parsing 4566 1`] = `"Time cannot represent non string type 4566"`; - -exports[`GraphQLTime value parsing throws an error when parsing null 1`] = `"Time cannot represent non string type null"`; - -exports[`GraphQLTime value parsing throws an error when parsing true 1`] = `"Time cannot represent non string type true"`; +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`GraphQLTime has a description 1`] = `"A time string at UTC, such as 10:15:30Z, compliant with the \`full-time\` format outlined in section 5.6 of the RFC 3339profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar."`; + +exports[`GraphQLTime literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "00:00:00.45+01"} 1`] = `"Time cannot represent an invalid time-string 00:00:00.45+01."`; + +exports[`GraphQLTime literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "00:00:00.45+0130"} 1`] = `"Time cannot represent an invalid time-string 00:00:00.45+0130."`; + +exports[`GraphQLTime literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "10:30:02.Z"} 1`] = `"Time cannot represent an invalid time-string 10:30:02.Z."`; + +exports[`GraphQLTime literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "2016-01-01T00:00:00.223Z"} 1`] = `"Time cannot represent an invalid time-string 2016-01-01T00:00:00.223Z."`; + +exports[`GraphQLTime literal parsing errors when parsing invalid literal {"kind": "StringValue", "value": "Invalid date"} 1`] = `"Time cannot represent an invalid time-string Invalid date."`; + +exports[`GraphQLTime serialization throws an error when serializing an invalid date-string "00:00:00.45+01" 1`] = `"Time cannot represent an invalid time-string 00:00:00.45+01."`; + +exports[`GraphQLTime serialization throws an error when serializing an invalid date-string "00:00:00.45+0130" 1`] = `"Time cannot represent an invalid time-string 00:00:00.45+0130."`; + +exports[`GraphQLTime serialization throws an error when serializing an invalid date-string "10:30:02.Z" 1`] = `"Time cannot represent an invalid time-string 10:30:02.Z."`; + +exports[`GraphQLTime serialization throws an error when serializing an invalid date-string "2016-01-01T00:00:00.223Z" 1`] = `"Time cannot represent an invalid time-string 2016-01-01T00:00:00.223Z."`; + +exports[`GraphQLTime serialization throws an error when serializing an invalid date-string "Invalid date" 1`] = `"Time cannot represent an invalid time-string Invalid date."`; + +exports[`GraphQLTime serialization throws error when serializing [] 1`] = `"Time cannot be serialized from a non string, or non Date type []"`; + +exports[`GraphQLTime serialization throws error when serializing {} 1`] = `"Time cannot be serialized from a non string, or non Date type {}"`; + +exports[`GraphQLTime serialization throws error when serializing invalid date 1`] = `"Time cannot represent an invalid Date instance"`; + +exports[`GraphQLTime serialization throws error when serializing null 1`] = `"Time cannot be serialized from a non string, or non Date type null"`; + +exports[`GraphQLTime serialization throws error when serializing true 1`] = `"Time cannot be serialized from a non string, or non Date type true"`; + +exports[`GraphQLTime serialization throws error when serializing undefined 1`] = `"Time cannot be serialized from a non string, or non Date type undefined"`; + +exports[`GraphQLTime value parsing throws an error parsing an invalid time-string "00:00:00.45+01" 1`] = `"Time cannot represent an invalid time-string 00:00:00.45+01."`; + +exports[`GraphQLTime value parsing throws an error parsing an invalid time-string "00:00:00.45+0130" 1`] = `"Time cannot represent an invalid time-string 00:00:00.45+0130."`; + +exports[`GraphQLTime value parsing throws an error parsing an invalid time-string "10:30:02.Z" 1`] = `"Time cannot represent an invalid time-string 10:30:02.Z."`; + +exports[`GraphQLTime value parsing throws an error parsing an invalid time-string "2016-01-01T00:00:00.223Z" 1`] = `"Time cannot represent an invalid time-string 2016-01-01T00:00:00.223Z."`; + +exports[`GraphQLTime value parsing throws an error parsing an invalid time-string "Invalid date" 1`] = `"Time cannot represent an invalid time-string Invalid date."`; + +exports[`GraphQLTime value parsing throws an error when parsing [] 1`] = `"Time cannot represent non string type []"`; + +exports[`GraphQLTime value parsing throws an error when parsing {} 1`] = `"Time cannot represent non string type {}"`; + +exports[`GraphQLTime value parsing throws an error when parsing 4566 1`] = `"Time cannot represent non string type 4566"`; + +exports[`GraphQLTime value parsing throws an error when parsing null 1`] = `"Time cannot represent non string type null"`; + +exports[`GraphQLTime value parsing throws an error when parsing true 1`] = `"Time cannot represent non string type true"`; From 5c0286aaa4fb4d6ed1d8fee5b3403386580fec77 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Sat, 24 Apr 2021 14:22:24 +0300 Subject: [PATCH 2/3] Support lower case date time strings #469 --- src/scalars/iso-date/validator.ts | 4 ++-- tests/iso-date/DateTime.test.ts | 1 + tests/iso-date/Time.test.ts | 1 + tsconfig.all.json | 22 ++++++---------------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/scalars/iso-date/validator.ts b/src/scalars/iso-date/validator.ts index 7a91d3ad7..bb4b66c74 100644 --- a/src/scalars/iso-date/validator.ts +++ b/src/scalars/iso-date/validator.ts @@ -44,6 +44,7 @@ const leapYear = (year: number): boolean => { // - Leap seconds cannot be known in advance. // export const validateTime = (time: string): boolean => { + time = time?.toUpperCase(); const TIME_REGEX = /^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(\.\d{1,})?(([Z])|([+|-]([01][0-9]|2[0-3]):[0-5][0-9]))$/; return TIME_REGEX.test(time); }; @@ -117,14 +118,13 @@ export const validateDate = (datestring: string): boolean => { // Where *s is a fraction of seconds with at least 1 digit. // export const validateDateTime = (dateTimeString: string): boolean => { - /* + dateTimeString = dateTimeString?.toUpperCase(); const RFC_3339_REGEX = /^(\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60))(\.\d{1,})?(([Z])|([+|-]([01][0-9]|2[0-3]):[0-5][0-9]))$/; // Validate the structure of the date-string if (!RFC_3339_REGEX.test(dateTimeString)) { return false; } - */ // Check if it is a correct date using the javascript Date parse() method. const time = Date.parse(dateTimeString); if (time !== time) { diff --git a/tests/iso-date/DateTime.test.ts b/tests/iso-date/DateTime.test.ts index 898df892a..fd966fbff 100644 --- a/tests/iso-date/DateTime.test.ts +++ b/tests/iso-date/DateTime.test.ts @@ -42,6 +42,7 @@ const validDates = [ '2017-01-07T11:25:00.450+01:00', new Date(Date.UTC(2017, 0, 7, 10, 25, 0, 450)), ], + ['2016-02-01t00:00:00.000z', new Date(Date.UTC(2016, 1, 1, 0, 0, 0, 0))], ]; describe('GraphQLDateTime', () => { diff --git a/tests/iso-date/Time.test.ts b/tests/iso-date/Time.test.ts index e9c4872b5..8aa76af66 100644 --- a/tests/iso-date/Time.test.ts +++ b/tests/iso-date/Time.test.ts @@ -34,6 +34,7 @@ const validDates = [ ['16:10:20.1359945Z', new Date(Date.UTC(2017, 0, 1, 16, 10, 20, 135))], ['00:00:00+01:30', new Date(Date.UTC(2016, 11, 31, 22, 30))], ['00:00:30.3-01:30', new Date(Date.UTC(2017, 0, 1, 1, 30, 30, 300))], + ['00:00:00z', new Date(Date.UTC(2017, 0, 1))], ]; describe('GraphQLTime', () => { diff --git a/tsconfig.all.json b/tsconfig.all.json index 067b074b6..d136fd174 100644 --- a/tsconfig.all.json +++ b/tsconfig.all.json @@ -3,11 +3,8 @@ "allowSyntheticDefaultImports": true, "experimentalDecorators": true, "module": "esnext", - "target": "esnext", - "lib": [ - "esnext", - "dom" - ], + "target": "es2018", + "lib": ["esnext", "dom"], "suppressImplicitAnyIndexErrors": true, "moduleResolution": "node", "emitDecoratorMetadata": true, @@ -22,18 +19,11 @@ "noUnusedParameters": true, "resolveJsonModule": true, "importHelpers": true, - "typeRoots": [ - "./types", - "./node_modules/@types" - ], + "typeRoots": ["./types", "./node_modules/@types"], "baseUrl": ".", "paths": { - "*": [ - "./types/*" - ] + "*": ["./types/*"] } }, - "exclude": [ - "node_modules" - ] -} \ No newline at end of file + "exclude": ["node_modules"] +} From dfbd139d3b7bcb1de9ce6dbb14066c693317771d Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Sat, 24 Apr 2021 14:23:58 +0300 Subject: [PATCH 3/3] Update Node on CI --- .github/workflows/main.yml | 4 ++-- .github/workflows/website.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a605cd279..6c0af0916 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node_version: [10, 12, 14] + node_version: [12, 16] steps: - name: Checkout Master uses: actions/checkout@v2 @@ -38,7 +38,7 @@ jobs: - name: Use Node uses: actions/setup-node@v2 with: - node-version: '14.x' + node-version: '16.x' - name: Install Dependencies using Yarn run: yarn install - name: Build diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 9bab806de..9a5cfc638 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -30,7 +30,7 @@ jobs: - name: Use Node uses: actions/setup-node@v2 with: - node-version: '14.x' + node-version: '16.x' - name: Install Dependencies using Yarn run: yarn install --ignore-engines working-directory: website