@@ -62,31 +62,45 @@ describe('coerceValue', () => {
6262 expectValue ( result ) . to . equal ( null ) ;
6363 } ) ;
6464
65- it ( 'returns a single error for empty value' , ( ) => {
65+ it ( 'returns a single error for empty string as value' , ( ) => {
6666 const result = coerceValue ( '' , GraphQLInt ) ;
6767 expectErrors ( result ) . to . deep . equal ( [
68- 'Expected type Int; Int cannot represent non 32-bit signed integer value: (empty string)' ,
68+ 'Expected type Int; Int cannot represent non- integer value: (empty string)' ,
6969 ] ) ;
7070 } ) ;
7171
72- it ( 'returns error for float input as int' , ( ) => {
72+ it ( 'returns a single error for 2^32 input as int' , ( ) => {
73+ const result = coerceValue ( Math . pow ( 2 , 32 ) , GraphQLInt ) ;
74+ expectErrors ( result ) . to . deep . equal ( [
75+ 'Expected type Int; Int cannot represent non 32-bit signed integer value: 4294967296' ,
76+ ] ) ;
77+ } ) ;
78+
79+ it ( 'returns a single error for float input as int' , ( ) => {
7380 const result = coerceValue ( '1.5' , GraphQLInt ) ;
7481 expectErrors ( result ) . to . deep . equal ( [
7582 'Expected type Int; Int cannot represent non-integer value: 1.5' ,
7683 ] ) ;
7784 } ) ;
7885
86+ it ( 'returns a single error for Infinity input as int' , ( ) => {
87+ const result = coerceValue ( Infinity , GraphQLInt ) ;
88+ expectErrors ( result ) . to . deep . equal ( [
89+ 'Expected type Int; Int cannot represent non-integer value: Infinity' ,
90+ ] ) ;
91+ } ) ;
92+
7993 it ( 'returns a single error for char input' , ( ) => {
8094 const result = coerceValue ( 'a' , GraphQLInt ) ;
8195 expectErrors ( result ) . to . deep . equal ( [
82- 'Expected type Int; Int cannot represent non 32-bit signed integer value: a' ,
96+ 'Expected type Int; Int cannot represent non- integer value: a' ,
8397 ] ) ;
8498 } ) ;
8599
86100 it ( 'returns a single error for char input' , ( ) => {
87101 const result = coerceValue ( 'meow' , GraphQLInt ) ;
88102 expectErrors ( result ) . to . deep . equal ( [
89- 'Expected type Int; Int cannot represent non 32-bit signed integer value: meow' ,
103+ 'Expected type Int; Int cannot represent non- integer value: meow' ,
90104 ] ) ;
91105 } ) ;
92106 } ) ;
@@ -112,13 +126,20 @@ describe('coerceValue', () => {
112126 expectValue ( result ) . to . equal ( null ) ;
113127 } ) ;
114128
115- it ( 'returns a single error for empty value ' , ( ) => {
129+ it ( 'returns a single error for empty string input ' , ( ) => {
116130 const result = coerceValue ( '' , GraphQLFloat ) ;
117131 expectErrors ( result ) . to . deep . equal ( [
118132 'Expected type Float; Float cannot represent non numeric value: (empty string)' ,
119133 ] ) ;
120134 } ) ;
121135
136+ it ( 'returns a single error for Infinity input' , ( ) => {
137+ const result = coerceValue ( Infinity , GraphQLFloat ) ;
138+ expectErrors ( result ) . to . deep . equal ( [
139+ 'Expected type Float; Float cannot represent non numeric value: Infinity' ,
140+ ] ) ;
141+ } ) ;
142+
122143 it ( 'returns a single error for char input' , ( ) => {
123144 const result = coerceValue ( 'a' , GraphQLFloat ) ;
124145 expectErrors ( result ) . to . deep . equal ( [
@@ -191,15 +212,15 @@ describe('coerceValue', () => {
191212 it ( 'returns no error for an invalid field' , ( ) => {
192213 const result = coerceValue ( { foo : 'abc' } , TestInputObject ) ;
193214 expectErrors ( result ) . to . deep . equal ( [
194- 'Expected type Int at value.foo; Int cannot represent non 32-bit signed integer value: abc' ,
215+ 'Expected type Int at value.foo; Int cannot represent non- integer value: abc' ,
195216 ] ) ;
196217 } ) ;
197218
198219 it ( 'returns multiple errors for multiple invalid fields' , ( ) => {
199220 const result = coerceValue ( { foo : 'abc' , bar : 'def' } , TestInputObject ) ;
200221 expectErrors ( result ) . to . deep . equal ( [
201- 'Expected type Int at value.foo; Int cannot represent non 32-bit signed integer value: abc' ,
202- 'Expected type Int at value.bar; Int cannot represent non 32-bit signed integer value: def' ,
222+ 'Expected type Int at value.foo; Int cannot represent non- integer value: abc' ,
223+ 'Expected type Int at value.bar; Int cannot represent non- integer value: def' ,
203224 ] ) ;
204225 } ) ;
205226
0 commit comments