Skip to content

Commit 98feb57

Browse files
printer-test: do more check on kitchen sink tests (#3016)
1 parent 31b442e commit 98feb57

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/language/__tests__/printer-test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ import { parse } from '../parser';
88
import { print } from '../printer';
99

1010
describe('Printer: Query document', () => {
11-
it('does not alter ast', () => {
12-
const ast = parse(kitchenSinkQuery);
13-
const astBefore = JSON.stringify(ast);
14-
print(ast);
15-
expect(JSON.stringify(ast)).to.equal(astBefore);
16-
});
17-
1811
it('prints minimal ast', () => {
1912
const ast = { kind: 'Field', name: { kind: 'Name', value: 'foo' } };
2013
expect(print(ast)).to.equal('foo');
@@ -145,8 +138,15 @@ describe('Printer: Query document', () => {
145138
`);
146139
});
147140

148-
it('prints kitchen sink', () => {
149-
const printed = print(parse(kitchenSinkQuery));
141+
it('prints kitchen sink without altering ast', () => {
142+
const ast = parse(kitchenSinkQuery, { noLocation: true });
143+
144+
const astBeforePrintCall = JSON.stringify(ast);
145+
const printed = print(ast);
146+
const printedAST = parse(printed, { noLocation: true });
147+
148+
expect(printedAST).to.deep.equal(ast);
149+
expect(JSON.stringify(ast)).to.equal(astBeforePrintCall);
150150

151151
expect(printed).to.equal(
152152
// $FlowFixMe[incompatible-call]

src/language/__tests__/schema-printer-test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ describe('Printer: SDL document', () => {
2525
);
2626
});
2727

28-
it('does not alter ast', () => {
29-
const ast = parse(kitchenSinkSDL);
30-
const astBefore = JSON.stringify(ast);
31-
print(ast);
32-
expect(JSON.stringify(ast)).to.equal(astBefore);
33-
});
28+
it('prints kitchen sink without altering ast', () => {
29+
const ast = parse(kitchenSinkSDL, { noLocation: true });
30+
31+
const astBeforePrintCall = JSON.stringify(ast);
32+
const printed = print(ast);
33+
const printedAST = parse(printed, { noLocation: true });
3434

35-
it('prints kitchen sink', () => {
36-
const printed = print(parse(kitchenSinkSDL));
35+
expect(printedAST).to.deep.equal(ast);
36+
expect(JSON.stringify(ast)).to.equal(astBeforePrintCall);
3737

3838
expect(printed).to.equal(dedent`
3939
"""This is a description of the schema as a whole."""

0 commit comments

Comments
 (0)