Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printer-test: do more check on kitchen sink tests #3016

Merged
merged 1 commit into from Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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