@@ -9,7 +9,11 @@ import { inspect } from '../../jsutils/inspect.js';
9
9
import { GraphQLError } from '../../error/GraphQLError.js' ;
10
10
11
11
import type { Token } from '../ast.js' ;
12
- import { isPunctuatorTokenKind , Lexer } from '../lexer.js' ;
12
+ import {
13
+ isPunctuatorTokenKind ,
14
+ Lexer ,
15
+ SchemaCoordinateLexer ,
16
+ } from '../lexer.js' ;
13
17
import { Source } from '../source.js' ;
14
18
import { TokenKind } from '../tokenKind.js' ;
15
19
@@ -1189,6 +1193,33 @@ describe('Lexer', () => {
1189
1193
} ) ;
1190
1194
} ) ;
1191
1195
1196
+ describe ( 'SchemaCoordinateLexer' , ( ) => {
1197
+ it ( 'can be stringified' , ( ) => {
1198
+ const lexer = new SchemaCoordinateLexer ( new Source ( 'Name.field' ) ) ;
1199
+ expect ( Object . prototype . toString . call ( lexer ) ) . to . equal (
1200
+ '[object SchemaCoordinateLexer]' ,
1201
+ ) ;
1202
+ } ) ;
1203
+
1204
+ it ( 'tracks a schema coordinate' , ( ) => {
1205
+ const lexer = new SchemaCoordinateLexer ( new Source ( 'Name.field' ) ) ;
1206
+ expect ( lexer . advance ( ) ) . to . contain ( {
1207
+ kind : TokenKind . NAME ,
1208
+ start : 0 ,
1209
+ end : 4 ,
1210
+ value : 'Name' ,
1211
+ } ) ;
1212
+ } ) ;
1213
+
1214
+ it ( 'forbids ignored tokens' , ( ) => {
1215
+ const lexer = new SchemaCoordinateLexer ( new Source ( '\nName.field' ) ) ;
1216
+ expectToThrowJSON ( ( ) => lexer . advance ( ) ) . to . deep . equal ( {
1217
+ message : 'Syntax Error: Invalid character: U+000A.' ,
1218
+ locations : [ { line : 1 , column : 1 } ] ,
1219
+ } ) ;
1220
+ } ) ;
1221
+ } ) ;
1222
+
1192
1223
describe ( 'isPunctuatorTokenKind' , ( ) => {
1193
1224
function isPunctuatorToken ( text : string ) {
1194
1225
return isPunctuatorTokenKind ( lexOne ( text ) . kind ) ;
0 commit comments