@@ -69,7 +69,7 @@ describe('Type System: Scalar coercion', () => {
69
69
'Int cannot represent non-integer value: Infinity' ,
70
70
) ;
71
71
expect ( ( ) => GraphQLInt . serialize ( [ 5 ] ) ) . to . throw (
72
- 'Int cannot represent an array value: [5]' ,
72
+ 'Int cannot represent non-integer value: [5]' ,
73
73
) ;
74
74
} ) ;
75
75
@@ -98,7 +98,7 @@ describe('Type System: Scalar coercion', () => {
98
98
'Float cannot represent non numeric value: ""' ,
99
99
) ;
100
100
expect ( ( ) => GraphQLFloat . serialize ( [ 5 ] ) ) . to . throw (
101
- 'Float cannot represent an array value: [5]' ,
101
+ 'Float cannot represent non numeric value: [5]' ,
102
102
) ;
103
103
} ) ;
104
104
@@ -109,15 +109,6 @@ describe('Type System: Scalar coercion', () => {
109
109
expect ( GraphQLString . serialize ( true ) ) . to . equal ( 'true' ) ;
110
110
expect ( GraphQLString . serialize ( false ) ) . to . equal ( 'false' ) ;
111
111
112
- expect ( ( ) => GraphQLString . serialize ( [ 1 ] ) ) . to . throw (
113
- 'String cannot represent value: [1]' ,
114
- ) ;
115
-
116
- const badObjValue = { } ;
117
- expect ( ( ) => GraphQLString . serialize ( badObjValue ) ) . to . throw (
118
- 'String cannot represent value: {}' ,
119
- ) ;
120
-
121
112
const stringableObjValue = {
122
113
valueOf ( ) {
123
114
return 'something useful' ;
@@ -126,19 +117,41 @@ describe('Type System: Scalar coercion', () => {
126
117
expect ( GraphQLString . serialize ( stringableObjValue ) ) . to . equal (
127
118
'something useful' ,
128
119
) ;
120
+
121
+ expect ( ( ) => GraphQLString . serialize ( NaN ) ) . to . throw (
122
+ 'String cannot represent value: NaN' ,
123
+ ) ;
124
+
125
+ expect ( ( ) => GraphQLString . serialize ( [ 1 ] ) ) . to . throw (
126
+ 'String cannot represent value: [1]' ,
127
+ ) ;
128
+
129
+ const badObjValue = { } ;
130
+ expect ( ( ) => GraphQLString . serialize ( badObjValue ) ) . to . throw (
131
+ 'String cannot represent value: {}' ,
132
+ ) ;
129
133
} ) ;
130
134
131
135
it ( 'serializes output as Boolean' , ( ) => {
132
- expect ( GraphQLBoolean . serialize ( 'string' ) ) . to . equal ( true ) ;
133
- expect ( GraphQLBoolean . serialize ( 'false' ) ) . to . equal ( true ) ;
134
- expect ( GraphQLBoolean . serialize ( '' ) ) . to . equal ( false ) ;
135
136
expect ( GraphQLBoolean . serialize ( 1 ) ) . to . equal ( true ) ;
136
137
expect ( GraphQLBoolean . serialize ( 0 ) ) . to . equal ( false ) ;
137
138
expect ( GraphQLBoolean . serialize ( true ) ) . to . equal ( true ) ;
138
139
expect ( GraphQLBoolean . serialize ( false ) ) . to . equal ( false ) ;
139
140
141
+ expect ( ( ) => GraphQLBoolean . serialize ( NaN ) ) . to . throw (
142
+ 'Boolean cannot represent a non boolean value: NaN' ,
143
+ ) ;
144
+ expect ( ( ) => GraphQLBoolean . serialize ( '' ) ) . to . throw (
145
+ 'Boolean cannot represent a non boolean value: ""' ,
146
+ ) ;
147
+ expect ( ( ) => GraphQLBoolean . serialize ( 'true' ) ) . to . throw (
148
+ 'Boolean cannot represent a non boolean value: "true"' ,
149
+ ) ;
140
150
expect ( ( ) => GraphQLBoolean . serialize ( [ false ] ) ) . to . throw (
141
- 'Boolean cannot represent an array value: [false]' ,
151
+ 'Boolean cannot represent a non boolean value: [false]' ,
152
+ ) ;
153
+ expect ( ( ) => GraphQLBoolean . serialize ( { } ) ) . to . throw (
154
+ 'Boolean cannot represent a non boolean value: {}' ,
142
155
) ;
143
156
} ) ;
144
157
@@ -148,6 +161,7 @@ describe('Type System: Scalar coercion', () => {
148
161
expect ( GraphQLID . serialize ( '' ) ) . to . equal ( '' ) ;
149
162
expect ( GraphQLID . serialize ( 123 ) ) . to . equal ( '123' ) ;
150
163
expect ( GraphQLID . serialize ( 0 ) ) . to . equal ( '0' ) ;
164
+ expect ( GraphQLID . serialize ( - 1 ) ) . to . equal ( '-1' ) ;
151
165
152
166
const objValue = {
153
167
_id : 123 ,
@@ -171,8 +185,8 @@ describe('Type System: Scalar coercion', () => {
171
185
'ID cannot represent value: true' ,
172
186
) ;
173
187
174
- expect ( ( ) => GraphQLID . serialize ( - 1.1 ) ) . to . throw (
175
- 'ID cannot represent value: -1.1 ' ,
188
+ expect ( ( ) => GraphQLID . serialize ( 3.14 ) ) . to . throw (
189
+ 'ID cannot represent value: 3.14 ' ,
176
190
) ;
177
191
178
192
expect ( ( ) => GraphQLID . serialize ( { } ) ) . to . throw (
0 commit comments