-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -12,6 +12,7 @@ import { | |||||||||||||||||
GraphQLID, | ||||||||||||||||||
GraphQLInt, | ||||||||||||||||||
GraphQLFloat, | ||||||||||||||||||
GraphQLList, | ||||||||||||||||||
GraphQLString, | ||||||||||||||||||
GraphQLEnumType, | ||||||||||||||||||
GraphQLInputObjectType, | ||||||||||||||||||
|
@@ -283,4 +284,39 @@ describe('coerceValue', () => { | |||||||||||||||||
]); | ||||||||||||||||||
}); | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
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 commentThe 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
graphql-js/src/utilities/__tests__/coerceValue-test.js Lines 75 to 78 in 7bc632a
So instead of |
||||||||||||||||||
expectValue(coerceValue([[1], [2, 3]], TestList)).to.deep.equal([ | ||||||||||||||||||
[1], | ||||||||||||||||||
[2, 3], | ||||||||||||||||||
]); | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
it('correctly coerces a null value', () => { | ||||||||||||||||||
expectValue(coerceValue(null, TestList)).to.deep.equal(null); | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
it('correctly coerces a non-list value', () => { | ||||||||||||||||||
expectValue(coerceValue(42, TestList)).to.deep.equal([[42]]); | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
it('correctly coerces nested non-list values', () => { | ||||||||||||||||||
expectValue(coerceValue([1, 2, 3], TestList)).to.deep.equal([ | ||||||||||||||||||
[1], | ||||||||||||||||||
[2], | ||||||||||||||||||
[3], | ||||||||||||||||||
]); | ||||||||||||||||||
}); | ||||||||||||||||||
|
||||||||||||||||||
it('correctly coerces nested null values', () => { | ||||||||||||||||||
expectValue(coerceValue([42, [null], null], TestList)).to.deep.equal([ | ||||||||||||||||||
[42], | ||||||||||||||||||
[null], | ||||||||||||||||||
null, | ||||||||||||||||||
]); | ||||||||||||||||||
}); | ||||||||||||||||||
}); | ||||||||||||||||||
}); |
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
forfor GraphQLList
and just implement all test from this table: http://facebook.github.io/graphql/June2018/#sec-Type-System.List