@@ -153,11 +153,28 @@ describe('Parser', () => {
153
153
type alpha{ field(arg: string):string }
154
154
` ) ;
155
155
156
- expect ( ast ) . to . have . nested . property (
157
- 'comments[0].value' ,
158
- 'This comment has a \u0A0A multi-byte character.' ,
159
- ) ;
160
- expect ( ast . comments ) . to . have . length ( 1 ) ;
156
+ expect ( toJSONDeep ( ast . comments ) ) . to . deep . equal ( [
157
+ {
158
+ kind : 'Comment' ,
159
+ loc : { start : 7 , end : 50 } ,
160
+ value : 'This comment has a ਊ multi-byte character.' ,
161
+ } ,
162
+ ] ) ;
163
+ } ) ;
164
+
165
+ it ( 'Add empty comments from in AST' , ( ) => {
166
+ const ast = parse ( `
167
+ #
168
+ type alpha{ field(arg: string):string }
169
+ ` ) ;
170
+
171
+ expect ( toJSONDeep ( ast . comments ) ) . to . deep . equal ( [
172
+ {
173
+ kind : 'Comment' ,
174
+ loc : { start : 7 , end : 8 } ,
175
+ value : '' ,
176
+ } ,
177
+ ] ) ;
161
178
} ) ;
162
179
163
180
it ( 'Add multiple comments in AST' , ( ) => {
@@ -169,15 +186,18 @@ describe('Parser', () => {
169
186
}
170
187
` ) ;
171
188
172
- expect ( ast ) . to . have . nested . property (
173
- 'comments[0].value' ,
174
- 'This comment is demo comment.' ,
175
- ) ;
176
- expect ( ast ) . to . have . nested . property (
177
- 'comments[1].value' ,
178
- 'This is another demo comment having # inside' ,
179
- ) ;
180
- expect ( ast . comments ) . to . have . length ( 2 ) ;
189
+ expect ( toJSONDeep ( ast . comments ) ) . to . deep . equal ( [
190
+ {
191
+ kind : 'Comment' ,
192
+ loc : { start : 27 , end : 57 } ,
193
+ value : 'This comment is demo comment.' ,
194
+ } ,
195
+ {
196
+ kind : 'Comment' ,
197
+ loc : { start : 101 , end : 146 } ,
198
+ value : 'This is another demo comment having # inside' ,
199
+ } ,
200
+ ] ) ;
181
201
} ) ;
182
202
183
203
it ( 'parses kitchen sink' , ( ) => {
@@ -264,7 +284,6 @@ describe('Parser', () => {
264
284
265
285
expect ( toJSONDeep ( result ) ) . to . deep . equal ( {
266
286
kind : Kind . DOCUMENT ,
267
- comments : [ ] ,
268
287
loc : { start : 0 , end : 41 } ,
269
288
definitions : [
270
289
{
@@ -355,7 +374,6 @@ describe('Parser', () => {
355
374
356
375
expect ( toJSONDeep ( result ) ) . to . deep . equal ( {
357
376
kind : Kind . DOCUMENT ,
358
- comments : [ ] ,
359
377
loc : { start : 0 , end : 30 } ,
360
378
definitions : [
361
379
{
0 commit comments