Skip to content

Commit

Permalink
printer-test: do more check on kitchen sink tests (#3016)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Apr 2, 2021
1 parent 31b442e commit 98feb57
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions src/language/__tests__/printer-test.js
Expand Up @@ -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');
Expand Down Expand Up @@ -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]
Expand Down
16 changes: 8 additions & 8 deletions src/language/__tests__/schema-printer-test.js
Expand Up @@ -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."""
Expand Down

0 comments on commit 98feb57

Please sign in to comment.