From 47e5b5a4ff30c77b39c21ff4c7603aa38efccbc2 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Fri, 2 Apr 2021 18:18:42 +0300 Subject: [PATCH] printer-test: do more check on kitchen sink tests --- src/language/__tests__/printer-test.js | 18 +++++++++--------- src/language/__tests__/schema-printer-test.js | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/language/__tests__/printer-test.js b/src/language/__tests__/printer-test.js index ef5098e5f4..ff5a3b2669 100644 --- a/src/language/__tests__/printer-test.js +++ b/src/language/__tests__/printer-test.js @@ -8,13 +8,6 @@ import { parse } from '../parser'; import { print } from '../printer'; describe('Printer: Query document', () => { - it('does not alter ast', () => { - const ast = parse(kitchenSinkQuery); - const astBefore = JSON.stringify(ast); - print(ast); - expect(JSON.stringify(ast)).to.equal(astBefore); - }); - it('prints minimal ast', () => { const ast = { kind: 'Field', name: { kind: 'Name', value: 'foo' } }; expect(print(ast)).to.equal('foo'); @@ -145,8 +138,15 @@ describe('Printer: Query document', () => { `); }); - it('prints kitchen sink', () => { - const printed = print(parse(kitchenSinkQuery)); + it('prints kitchen sink without altering ast', () => { + const ast = parse(kitchenSinkQuery, { noLocation: true }); + + const astBeforePrintCall = JSON.stringify(ast); + const printed = print(ast); + const printedAST = parse(printed, { noLocation: true }); + + expect(printedAST).to.deep.equal(ast); + expect(JSON.stringify(ast)).to.equal(astBeforePrintCall); expect(printed).to.equal( // $FlowFixMe[incompatible-call] diff --git a/src/language/__tests__/schema-printer-test.js b/src/language/__tests__/schema-printer-test.js index 2b064f05a2..26311144cb 100644 --- a/src/language/__tests__/schema-printer-test.js +++ b/src/language/__tests__/schema-printer-test.js @@ -25,15 +25,15 @@ describe('Printer: SDL document', () => { ); }); - it('does not alter ast', () => { - const ast = parse(kitchenSinkSDL); - const astBefore = JSON.stringify(ast); - print(ast); - expect(JSON.stringify(ast)).to.equal(astBefore); - }); + it('prints kitchen sink without altering ast', () => { + const ast = parse(kitchenSinkSDL, { noLocation: true }); + + const astBeforePrintCall = JSON.stringify(ast); + const printed = print(ast); + const printedAST = parse(printed, { noLocation: true }); - it('prints kitchen sink', () => { - const printed = print(parse(kitchenSinkSDL)); + expect(printedAST).to.deep.equal(ast); + expect(JSON.stringify(ast)).to.equal(astBeforePrintCall); expect(printed).to.equal(dedent` """This is a description of the schema as a whole."""