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

chore(tests): cleaner GraphQL schema snapshots #533

Merged
merged 17 commits into from Oct 15, 2019
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
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")
singingwolfboy marked this conversation as resolved.
Show resolved Hide resolved
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