Skip to content

Commit

Permalink
fixed tests that were using print (#4341)
Browse files Browse the repository at this point in the history
There were a few tests that broke due to changes to print params
  • Loading branch information
twof authored Feb 7, 2025
1 parent e0c2425 commit 7121006
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/utilities/__tests__/buildASTSchema-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function expectASTNode(obj: Maybe<{ readonly astNode: Maybe<ASTNode> }>) {
function expectExtensionASTNodes(obj: {
readonly extensionASTNodes: ReadonlyArray<ASTNode>;
}) {
return expect(obj.extensionASTNodes.map(print).join('\n\n'));
return expect(obj.extensionASTNodes.map((node) => print(node)).join('\n\n'));
}

describe('Schema Builder', () => {
Expand Down
8 changes: 5 additions & 3 deletions src/utilities/__tests__/extendSchema-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { printSchema } from '../printSchema';
function expectExtensionASTNodes(obj: {
readonly extensionASTNodes: ReadonlyArray<ASTNode>;
}) {
return expect(obj.extensionASTNodes.map(print).join('\n\n'));
return expect(obj.extensionASTNodes.map((node) => print(node)).join('\n\n'));
}

function expectASTNode(obj: Maybe<{ readonly astNode: Maybe<ASTNode> }>) {
Expand All @@ -51,10 +51,12 @@ function expectSchemaChanges(
schema: GraphQLSchema,
extendedSchema: GraphQLSchema,
) {
const schemaDefinitions = parse(printSchema(schema)).definitions.map(print);
const schemaDefinitions = parse(printSchema(schema)).definitions.map((node) =>
print(node),
);
return expect(
parse(printSchema(extendedSchema))
.definitions.map(print)
.definitions.map((node) => print(node))
.filter((def) => !schemaDefinitions.includes(def))
.join('\n\n'),
);
Expand Down
20 changes: 15 additions & 5 deletions src/utilities/__tests__/separateOperations-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ describe('separateOperations', () => {
}
`);

const separatedASTs = mapValue(separateOperations(ast), print);
const separatedASTs = mapValue(separateOperations(ast), (node) =>
print(node),
);
expect(separatedASTs).to.deep.equal({
'': dedent`
{
Expand Down Expand Up @@ -128,7 +130,9 @@ describe('separateOperations', () => {
}
`);

const separatedASTs = mapValue(separateOperations(ast), print);
const separatedASTs = mapValue(separateOperations(ast), (node) =>
print(node),
);
expect(separatedASTs).to.deep.equal({
One: dedent`
query One {
Expand Down Expand Up @@ -178,7 +182,9 @@ describe('separateOperations', () => {
}
`);

const separatedASTs = mapValue(separateOperations(ast), print);
const separatedASTs = mapValue(separateOperations(ast), (node) =>
print(node),
);
expect(separatedASTs).to.deep.equal({
'': dedent`
{
Expand Down Expand Up @@ -215,7 +221,9 @@ describe('separateOperations', () => {
type Bar
`);

const separatedASTs = mapValue(separateOperations(ast), print);
const separatedASTs = mapValue(separateOperations(ast), (node) =>
print(node),
);
expect(separatedASTs).to.deep.equal({
Foo: dedent`
query Foo {
Expand All @@ -241,7 +249,9 @@ describe('separateOperations', () => {
}
`);

const separatedASTs = mapValue(separateOperations(ast), print);
const separatedASTs = mapValue(separateOperations(ast), (node) =>
print(node),
);
expect(separatedASTs).to.deep.equal({
'': dedent`
{
Expand Down

0 comments on commit 7121006

Please sign in to comment.