Add snapshot test for GitHub GraphQL query (#382)

Summary:
This has two primary benefits:
  - Humans can look at this snapshot file to see what’s being queried,
    or to manually issue a query.
  - When we change the programmatically generated query, we can easily
    see what the results are in the GraphQL output. This makes it easy
    to verify that a change is correct.

Test Plan:
None.

wchargin-branch: snapshot-query
This commit is contained in:
William Chargin 2018-06-12 14:09:58 -07:00 committed by GitHub
parent 773596755a
commit a3f2b82073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 132 additions and 1 deletions

View File

@ -200,3 +200,128 @@ Object {
},
}
`;
exports[`graphql creates a query 1`] = `
"query FetchData($repoOwner: String! $repoName: String!) {
repository(owner: $repoOwner name: $repoName) {
url
name
owner {
...whoami
}
id
issues(first: 50) {
...issues
}
pullRequests(first: 50) {
...prs
}
}
}
fragment whoami on Actor {
__typename
login
url
... on User {
id
}
... on Organization {
id
}
... on Bot {
id
}
}
fragment issues on IssueConnection {
pageInfo {
hasNextPage
endCursor
}
nodes {
id
url
title
body
number
author {
...whoami
}
comments(first: 20) {
...comments
}
}
}
fragment prs on PullRequestConnection {
pageInfo {
hasNextPage
endCursor
}
nodes {
id
url
title
body
number
mergeCommit {
oid
}
additions
deletions
author {
...whoami
}
comments(first: 20) {
...comments
}
reviews(first: 10) {
...reviews
}
}
}
fragment comments on IssueCommentConnection {
pageInfo {
hasNextPage
endCursor
}
nodes {
id
url
author {
...whoami
}
body
}
}
fragment reviews on PullRequestReviewConnection {
pageInfo {
hasNextPage
endCursor
}
nodes {
id
url
body
author {
...whoami
}
state
comments(first: 10) {
...reviewComments
}
}
}
fragment reviewComments on PullRequestReviewCommentConnection {
pageInfo {
hasNextPage
endCursor
}
nodes {
id
url
body
author {
...whoami
}
}
}"
`;

View File

@ -1,7 +1,7 @@
// @flow
import type {Continuation} from "./graphql";
import {build} from "../../graphql/queries";
import {build, stringify, multilineLayout} from "../../graphql/queries";
import {
PAGE_LIMIT,
createQuery,
@ -950,4 +950,10 @@ describe("graphql", () => {
expect(result).toMatchSnapshot();
});
});
it("creates a query", () => {
expect(
stringify.body(createQuery(), multilineLayout(" "))
).toMatchSnapshot();
});
});