@@ -11,7 +11,13 @@ import { kitchenSinkQuery } from '../../__testUtils__/kitchenSinkQuery.js';
1111import { inspect } from '../../jsutils/inspect.js' ;
1212
1313import { 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' ;
1521import { Source } from '../source.js' ;
1622import { TokenKind } from '../tokenKind.js' ;
1723
@@ -20,10 +26,10 @@ function expectSyntaxError(text: string) {
2026}
2127
2228describe ( 'Parser' , ( ) => {
23- it ( 'parse provides useful errors' , ( ) => {
29+ it ( 'parse provides useful errors' , async ( ) => {
2430 let caughtError ;
2531 try {
26- parse ( '{' ) ;
32+ await parse ( '{' ) ;
2733 } catch ( error ) {
2834 caughtError = error ;
2935 }
@@ -71,10 +77,10 @@ describe('Parser', () => {
7177 } ) ;
7278 } ) ;
7379
74- it ( 'parse provides useful error when using source' , ( ) => {
80+ it ( 'parse provides useful error when using source' , async ( ) => {
7581 let caughtError ;
7682 try {
77- parse ( new Source ( 'query' , 'MyQuery.graphql' ) ) ;
83+ await parse ( new Source ( 'query' , 'MyQuery.graphql' ) ) ;
7884 } catch ( error ) {
7985 caughtError = error ;
8086 }
@@ -100,9 +106,10 @@ describe('Parser', () => {
100106 ) ;
101107 } ) ;
102108
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 ) ;
106113 } ) ;
107114
108115 it ( 'parses variable inline values' , ( ) => {
@@ -431,8 +438,8 @@ describe('Parser', () => {
431438 expect ( ( ) => parse ( document ) ) . to . throw ( ) ;
432439 } ) ;
433440
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 }' ) ;
436443
437444 expect ( Object . prototype . toString . call ( loc ) ) . to . equal ( '[object Location]' ) ;
438445 expect ( JSON . stringify ( loc ) ) . to . equal ( '{"start":0,"end":6}' ) ;
0 commit comments