Skip to content

Commit

Permalink
chore(tests): cleaner GraphQL schema snapshots (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
singingwolfboy authored and benjie committed Oct 15, 2019
1 parent 7007a43 commit d407d8e
Show file tree
Hide file tree
Showing 53 changed files with 48,323 additions and 47,995 deletions.
3 changes: 3 additions & 0 deletions packages/graphile-build-pg/package.json
Expand Up @@ -58,6 +58,9 @@
"jest": "^24.8.0"
},
"jest": {
"snapshotSerializers": [
"jest-serializer-graphql-schema"
],
"transform": {
"^.+\\.jsx?$": "../../.jest-wrapper.js"
},
Expand Down
@@ -1,32 +1,32 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`generates empty schema (with no Mutation type) 1`] = `
"\\"\\"\\"An object with a globally unique \`ID\`.\\"\\"\\"
"""An object with a globally unique \`ID\`."""
interface Node {
\\"\\"\\"
"""
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
"""
id: ID!
}
\\"\\"\\"The root query type which gives access points into the data universe.\\"\\"\\"
"""The root query type which gives access points into the data universe."""
type Query implements Node {
\\"\\"\\"
"""
Exposes the root query type nested one level down. This is helpful for Relay 1
which can only query top level fields if they are in a particular form.
\\"\\"\\"
"""
query: Query!
\\"\\"\\"
"""
The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
"""
id: ID!
\\"\\"\\"Fetches an object given its globally unique \`ID\`.\\"\\"\\"
"""Fetches an object given its globally unique \`ID\`."""
node(
\\"\\"\\"The globally unique \`ID\`.\\"\\"\\"
"""The globally unique \`ID\`."""
id: ID!
): Node
}
"
`;
30 changes: 15 additions & 15 deletions packages/graphile-build/__tests__/__snapshots__/enum.test.js.snap
@@ -1,40 +1,40 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`generated schema 1`] = `
"enum MyEnum {
ONE @deprecated(reason: \\"We no longer support numbers smaller than PI\\")
TWO @deprecated(reason: \\"We no longer support numbers smaller than PI\\")
THREE @deprecated(reason: \\"We no longer support numbers smaller than PI\\")
enum MyEnum {
ONE @deprecated(reason: "We no longer support numbers smaller than PI")
TWO @deprecated(reason: "We no longer support numbers smaller than PI")
THREE @deprecated(reason: "We no longer support numbers smaller than PI")
FOUR
}
\\"\\"\\"An object with a globally unique \`ID\`.\\"\\"\\"
"""An object with a globally unique \`ID\`."""
interface Node {
\\"\\"\\"
"""
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
"""
id: ID!
}
\\"\\"\\"The root query type which gives access points into the data universe.\\"\\"\\"
"""The root query type which gives access points into the data universe."""
type Query implements Node {
\\"\\"\\"
"""
Exposes the root query type nested one level down. This is helpful for Relay 1
which can only query top level fields if they are in a particular form.
\\"\\"\\"
"""
query: Query!
\\"\\"\\"
"""
The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
"""
id: ID!
\\"\\"\\"Fetches an object given its globally unique \`ID\`.\\"\\"\\"
"""Fetches an object given its globally unique \`ID\`."""
node(
\\"\\"\\"The globally unique \`ID\`.\\"\\"\\"
"""The globally unique \`ID\`."""
id: ID!
): Node
enum: MyEnum
}
"
`;
Expand Up @@ -36,7 +36,7 @@ Object {
`;

exports[`generated schema 1`] = `
"\\"\\"\\"A location in a connection that can be used for resuming pagination.\\"\\"\\"
"""A location in a connection that can be used for resuming pagination."""
scalar Cursor
type Dummy {
Expand All @@ -62,35 +62,35 @@ type DummyEdge {
node: Dummy
}
\\"\\"\\"An object with a globally unique \`ID\`.\\"\\"\\"
"""An object with a globally unique \`ID\`."""
interface Node {
\\"\\"\\"
"""
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
"""
id: ID!
}
\\"\\"\\"The root query type which gives access points into the data universe.\\"\\"\\"
"""The root query type which gives access points into the data universe."""
type Query implements Node {
\\"\\"\\"
"""
Exposes the root query type nested one level down. This is helpful for Relay 1
which can only query top level fields if they are in a particular form.
\\"\\"\\"
"""
query: Query!
\\"\\"\\"
"""
The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
"""
id: ID!
\\"\\"\\"Fetches an object given its globally unique \`ID\`.\\"\\"\\"
"""Fetches an object given its globally unique \`ID\`."""
node(
\\"\\"\\"The globally unique \`ID\`.\\"\\"\\"
"""The globally unique \`ID\`."""
id: ID!
): Node
dummyConnection(first: Int, after: Cursor, sortBy: DummyConnectionSortBy): DummyConnection
}
"
`;

exports[`no arguments 1`] = `
Expand Down
48 changes: 24 additions & 24 deletions packages/graphile-build/__tests__/__snapshots__/watch.test.js.snap
@@ -1,73 +1,73 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`generated schema n = 0, n = 3 1`] = `
"type Dummy0 {
type Dummy0 {
n: Int!
}
\\"\\"\\"An object with a globally unique \`ID\`.\\"\\"\\"
"""An object with a globally unique \`ID\`."""
interface Node {
\\"\\"\\"
"""
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
"""
id: ID!
}
\\"\\"\\"The root query type which gives access points into the data universe.\\"\\"\\"
"""The root query type which gives access points into the data universe."""
type Query implements Node {
\\"\\"\\"
"""
Exposes the root query type nested one level down. This is helpful for Relay 1
which can only query top level fields if they are in a particular form.
\\"\\"\\"
"""
query: Query!
\\"\\"\\"
"""
The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
"""
id: ID!
\\"\\"\\"Fetches an object given its globally unique \`ID\`.\\"\\"\\"
"""Fetches an object given its globally unique \`ID\`."""
node(
\\"\\"\\"The globally unique \`ID\`.\\"\\"\\"
"""The globally unique \`ID\`."""
id: ID!
): Node
dummy: Dummy0
}
"
`;

exports[`generated schema n = 0, n = 3 2`] = `
"type Dummy3 {
type Dummy3 {
n: Int!
}
\\"\\"\\"An object with a globally unique \`ID\`.\\"\\"\\"
"""An object with a globally unique \`ID\`."""
interface Node {
\\"\\"\\"
"""
A globally unique identifier. Can be used in various places throughout the system to identify this single value.
\\"\\"\\"
"""
id: ID!
}
\\"\\"\\"The root query type which gives access points into the data universe.\\"\\"\\"
"""The root query type which gives access points into the data universe."""
type Query implements Node {
\\"\\"\\"
"""
Exposes the root query type nested one level down. This is helpful for Relay 1
which can only query top level fields if they are in a particular form.
\\"\\"\\"
"""
query: Query!
\\"\\"\\"
"""
The root query type must be a \`Node\` to work well with Relay 1 mutations. This just resolves to \`query\`.
\\"\\"\\"
"""
id: ID!
\\"\\"\\"Fetches an object given its globally unique \`ID\`.\\"\\"\\"
"""Fetches an object given its globally unique \`ID\`."""
node(
\\"\\"\\"The globally unique \`ID\`.\\"\\"\\"
"""The globally unique \`ID\`."""
id: ID!
): Node
dummy: Dummy3
}
"
`;
3 changes: 1 addition & 2 deletions packages/graphile-build/__tests__/emptyMutation.test.js
@@ -1,7 +1,6 @@
const { printSchema } = require("graphql/utilities");
const { buildSchema, defaultPlugins } = require("../");

test("generates empty schema (with no Mutation type)", async () => {
const schema = await buildSchema([...defaultPlugins]);
expect(printSchema(schema)).toMatchSnapshot();
expect(schema).toMatchSnapshot();
});
3 changes: 1 addition & 2 deletions packages/graphile-build/__tests__/enum.test.js
@@ -1,5 +1,4 @@
const { GraphQLEnumType } = require("graphql");
const { printSchema } = require("graphql/utilities");
const { buildSchema, defaultPlugins } = require("../");

function EnumPlugin(builder) {
Expand Down Expand Up @@ -60,5 +59,5 @@ function EnumPlugin(builder) {

test("generated schema", async () => {
const schema = await buildSchema([...defaultPlugins, EnumPlugin]);
expect(printSchema(schema)).toMatchSnapshot();
expect(schema).toMatchSnapshot();
});
3 changes: 1 addition & 2 deletions packages/graphile-build/__tests__/fieldData.test.js
Expand Up @@ -7,7 +7,6 @@ const {
GraphQLNonNull,
GraphQLList,
} = require("graphql");
const { printSchema } = require("graphql/utilities");
const { buildSchema, defaultPlugins } = require("../");

const base64 = str => Buffer.from(String(str)).toString("base64");
Expand Down Expand Up @@ -291,7 +290,7 @@ const DummyConnectionPlugin = async builder => {

test("generated schema", async () => {
const schema = await buildSchema([...defaultPlugins, DummyConnectionPlugin]);
expect(printSchema(schema)).toMatchSnapshot();
expect(schema).toMatchSnapshot();
});

test("no arguments", async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/graphile-build/__tests__/watch.test.js
Expand Up @@ -3,8 +3,8 @@ const {
GraphQLObjectType,
GraphQLInt,
GraphQLNonNull,
printSchema,
} = require("graphql");
const { printSchema } = require("graphql/utilities");
const {
getBuilder,
defaultPlugins: allDefaultPlugins,
Expand Down Expand Up @@ -91,12 +91,12 @@ test("generated schema n = 0, n = 3", async () => {
...defaultPlugins,
makePluginEtc(0).plugin,
])).buildSchema();
expect(printSchema(schema0)).toMatchSnapshot();
expect(schema0).toMatchSnapshot();
const schema3 = (await getBuilder([
...defaultPlugins,
makePluginEtc(3).plugin,
])).buildSchema();
expect(printSchema(schema3)).toMatchSnapshot();
expect(schema3).toMatchSnapshot();
});

test("schema is cached if no watcher fires", async () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/graphile-build/package.json
Expand Up @@ -53,6 +53,9 @@
"graphql": ">=0.9 <0.14 || ^14.0.2"
},
"jest": {
"snapshotSerializers": [
"jest-serializer-graphql-schema"
],
"transform": {
"^.+\\.jsx?$": "../../.jest-wrapper.js"
},
Expand Down

0 comments on commit d407d8e

Please sign in to comment.