@@ -11,7 +11,13 @@ import { kitchenSinkQuery } from '../../__testUtils__/kitchenSinkQuery.js';
11
11
import { inspect } from '../../jsutils/inspect.js' ;
12
12
13
13
import { Kind } from '../kinds.js' ;
14
- import { parse , parseConstValue , parseType , parseValue } from '../parser.js' ;
14
+ import {
15
+ parse ,
16
+ parseConstValue ,
17
+ parseSync ,
18
+ parseType ,
19
+ parseValue ,
20
+ } from '../parser.js' ;
15
21
import { Source } from '../source.js' ;
16
22
import { TokenKind } from '../tokenKind.js' ;
17
23
@@ -20,10 +26,10 @@ function expectSyntaxError(text: string) {
20
26
}
21
27
22
28
describe ( 'Parser' , ( ) => {
23
- it ( 'parse provides useful errors' , ( ) => {
29
+ it ( 'parse provides useful errors' , async ( ) => {
24
30
let caughtError ;
25
31
try {
26
- parse ( '{' ) ;
32
+ await parse ( '{' ) ;
27
33
} catch ( error ) {
28
34
caughtError = error ;
29
35
}
@@ -71,10 +77,10 @@ describe('Parser', () => {
71
77
} ) ;
72
78
} ) ;
73
79
74
- it ( 'parse provides useful error when using source' , ( ) => {
80
+ it ( 'parse provides useful error when using source' , async ( ) => {
75
81
let caughtError ;
76
82
try {
77
- parse ( new Source ( 'query' , 'MyQuery.graphql' ) ) ;
83
+ await parse ( new Source ( 'query' , 'MyQuery.graphql' ) ) ;
78
84
} catch ( error ) {
79
85
caughtError = error ;
80
86
}
@@ -100,9 +106,10 @@ describe('Parser', () => {
100
106
) ;
101
107
} ) ;
102
108
103
- it ( 'exposes the tokenCount' , ( ) => {
104
- expect ( parse ( '{ foo }' ) . tokenCount ) . to . equal ( 3 ) ;
105
- expect ( parse ( '{ foo(bar: "baz") }' ) . tokenCount ) . to . equal ( 8 ) ;
109
+ it ( 'exposes the tokenCount' , async ( ) => {
110
+ expect ( parseSync ( '{ foo }' ) . tokenCount ) . to . equal ( 3 ) ;
111
+ expect ( ( await parse ( '{ foo }' ) ) . tokenCount ) . to . equal ( 3 ) ;
112
+ expect ( ( await parse ( '{ foo(bar: "baz") }' ) ) . tokenCount ) . to . equal ( 8 ) ;
106
113
} ) ;
107
114
108
115
it ( 'parses variable inline values' , ( ) => {
@@ -431,8 +438,8 @@ describe('Parser', () => {
431
438
expect ( ( ) => parse ( document ) ) . to . throw ( ) ;
432
439
} ) ;
433
440
434
- it ( 'contains location that can be Object.toStringified, JSON.stringified, or jsutils.inspected' , ( ) => {
435
- const { loc } = parse ( '{ id }' ) ;
441
+ it ( 'contains location that can be Object.toStringified, JSON.stringified, or jsutils.inspected' , async ( ) => {
442
+ const { loc } = await parse ( '{ id }' ) ;
436
443
437
444
expect ( Object . prototype . toString . call ( loc ) ) . to . equal ( '[object Location]' ) ;
438
445
expect ( JSON . stringify ( loc ) ) . to . equal ( '{"start":0,"end":6}' ) ;
0 commit comments