Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xuewei8910 committed May 21, 2021
1 parent 2cfa250 commit 956f729
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/language/__tests__/lexer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,16 @@ describe('Lexer', () => {
it('errors respect whitespace', () => {
let caughtError;
try {
lexOne(['', '', ' ?', ''].join('\n'));
lexOne(['', '', ' ~', ''].join('\n'));
} catch (error) {
caughtError = error;
}
expect(String(caughtError)).to.equal(dedent`
Syntax Error: Cannot parse the unexpected character "?".
Syntax Error: Cannot parse the unexpected character "~".
GraphQL request:3:5
2 |
3 | ?
3 | ~
| ^
4 |
`);
Expand All @@ -179,18 +179,18 @@ describe('Lexer', () => {
it('updates line numbers in error for file context', () => {
let caughtError;
try {
const str = ['', '', ' ?', ''].join('\n');
const str = ['', '', ' ~', ''].join('\n');
const source = new Source(str, 'foo.js', { line: 11, column: 12 });
new Lexer(source).advance();
} catch (error) {
caughtError = error;
}
expect(String(caughtError)).to.equal(dedent`
Syntax Error: Cannot parse the unexpected character "?".
Syntax Error: Cannot parse the unexpected character "~".
foo.js:13:6
12 |
13 | ?
13 | ~
| ^
14 |
`);
Expand All @@ -199,16 +199,16 @@ describe('Lexer', () => {
it('updates column numbers in error for file context', () => {
let caughtError;
try {
const source = new Source('?', 'foo.js', { line: 1, column: 5 });
const source = new Source('~', 'foo.js', { line: 1, column: 5 });
new Lexer(source).advance();
} catch (error) {
caughtError = error;
}
expect(String(caughtError)).to.equal(dedent`
Syntax Error: Cannot parse the unexpected character "?".
Syntax Error: Cannot parse the unexpected character "~".
foo.js:1:5
1 | ?
1 | ~
| ^
`);
});
Expand Down Expand Up @@ -819,8 +819,8 @@ describe('Lexer', () => {
locations: [{ line: 1, column: 1 }],
});

expectSyntaxError('?').to.deep.equal({
message: 'Syntax Error: Cannot parse the unexpected character "?".',
expectSyntaxError('~').to.deep.equal({
message: 'Syntax Error: Cannot parse the unexpected character "~".',
locations: [{ line: 1, column: 1 }],
});

Expand Down
10 changes: 10 additions & 0 deletions src/language/__tests__/visitor-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,16 @@ describe('Visitor', () => {
['enter', 'Name', 'name', 'Field'],
['leave', 'Name', 'name', 'Field'],
['leave', 'Field', 2, undefined],
['enter', 'Field', 3, undefined],
['enter', 'Name', 'name', 'Field'],
['leave', 'Name', 'name', 'Field'],
['leave', 'Field', 3, undefined],
['enter', 'Field', 4, undefined],
['enter', 'Name', 'alias', 'Field'],
['leave', 'Name', 'alias', 'Field'],
['enter', 'Name', 'name', 'Field'],
['leave', 'Name', 'name', 'Field'],
['leave', 'Field', 4, undefined],
['leave', 'SelectionSet', 'selectionSet', 'InlineFragment'],
['leave', 'InlineFragment', 1, undefined],
['enter', 'InlineFragment', 2, undefined],
Expand Down

0 comments on commit 956f729

Please sign in to comment.