Skip to content

Commit d889dff

Browse files
committed
Add test for date type
1 parent 09c8933 commit d889dff

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/test_query_result.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class PersonType < GraphQL::Schema::Object
6060
field :company, String, null: true
6161
field :homepageURL, String, null: true, method: :homepage_url, camelize: false
6262
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
63+
field :created_on, GraphQL::Types::ISO8601Date, null: false
6364
field :hobbies, [String], null: true
6465
field :plan, PlanType, null: false
6566
end
@@ -103,6 +104,7 @@ def me
103104
last_name: "Peek",
104105
company: "GitHub",
105106
created_at: Time.at(0),
107+
created_on: Date.new(1970, 1, 1),
106108
updated_at: Time.at(1),
107109
hobbies: ["soccer", "coding"],
108110
homepage_url: nil,
@@ -123,6 +125,7 @@ def issue_or_pull_request
123125
last_name: "Peek",
124126
company: "GitHub",
125127
created_at: Time.at(0),
128+
created_on: Date.new(1970, 1, 1),
126129
updated_at: Time.at(1),
127130
hobbies: ["soccer", "coding"],
128131
plan: "LARGE"
@@ -605,6 +608,23 @@ def test_datetime_scalar_casting
605608
assert_equal Time.at(1), person.updated_at
606609
end
607610

611+
def test_date_scalar_casting
612+
Temp.const_set :Query, @client.parse(<<-'GRAPHQL')
613+
{
614+
me {
615+
name
616+
createdOn
617+
}
618+
}
619+
GRAPHQL
620+
621+
response = @client.query(Temp::Query)
622+
623+
person = response.data.me
624+
assert_equal "Josh", person.name
625+
assert_equal Date.new(1970, 1, 1), person.created_on
626+
end
627+
608628
include FooHelper
609629

610630
def test_source_location

0 commit comments

Comments
 (0)