-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add testcases for nested list coercion #1528
Conversation
@@ -283,4 +284,39 @@ describe('coerceValue', () => { | |||
]); | |||
}); | |||
}); | |||
|
|||
describe('for nested GraphQLList', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jjergus Thanks for PR 👍
I think it better to have describe
for for GraphQLList
and just implement all test from this table: http://facebook.github.io/graphql/June2018/#sec-Type-System.List
describe('for nested GraphQLList', () => { | ||
const TestList = GraphQLList(GraphQLList(GraphQLInt)); | ||
|
||
it('correctly coerces a nested list value', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to use existing naming convention, e.g.
graphql-js/src/utilities/__tests__/coerceValue-test.js
Lines 131 to 134 in 7bc632a
it('returns value for integer', () => { | |
const result = coerceValue(1, GraphQLFloat); | |
expectValue(result).to.equal(1); | |
}); |
graphql-js/src/utilities/__tests__/coerceValue-test.js
Lines 75 to 78 in 7bc632a
it('returns null for null value', () => { | |
const result = coerceValue(null, GraphQLInt); | |
expectValue(result).to.equal(null); | |
}); |
So instead of correctly coerces a nested list value
it could be return value for nested list
.
Same goes for other testcases
Thanks for the review! I added more test cases and made the descriptions consistent with the rest of the file. I'm still keeping the nested list test cases separate from the non-nested ones, since it seems to be easier to read that way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a good set of tests. Thanks!
Add some test cases to cover coercion of list values, especially nested lists where some non-list values are involved. These exercise the following special case from the spec:
Most of these examples are copied directly from the spec. However, one of them actually coerces to a value different from what the example in the spec says, which I believe to be a mistake in the spec: graphql/graphql-spec#515
@IvanGoncharov what do you think?