mentionsAuthorReference: remove legacy GraphQL dep (#963)

Summary:
This test has data in the old format, and uses the `RelationalView`
method that automatically translates it. As we prepare to delete that
code, we upgrade the underlying format of this test data. The end code
is nicer to read, too (e.g., we don’t need the `connection` helper
function).

Recommend reviewing with `git show -b`.

Test Plan:
Running `yarn test` suffices.

wchargin-branch: mentionsAuthorReference-remove-legacy-graphql
This commit is contained in:
William Chargin 2018-10-31 12:36:48 -07:00 committed by GitHub
parent b77db72c1d
commit 2e0b17cef7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 94 additions and 96 deletions

View File

@ -2,7 +2,7 @@
import * as RV from "../relationalView";
import * as N from "../nodes";
import type {ConnectionJSON} from "../graphql";
import type {Repository} from "../graphqlTypes";
import deepEqual from "lodash.isequal";
import {findMentionsAuthorReferences} from "./mentionsAuthorReference";
@ -10,15 +10,6 @@ import {findMentionsAuthorReferences} from "./mentionsAuthorReference";
describe("plugins/github/heuristics/mentionsAuthorReference", () => {
function exampleRelationalView(): RV.RelationalView {
const view = new RV.RelationalView();
function connection<T>(nodes: $ReadOnlyArray<T>): ConnectionJSON<T> {
return {
nodes,
pageInfo: {
endCursor: "cursor:ignored",
hasNextPage: false,
},
};
}
const authors = {
steven: () => ({
@ -61,69 +52,77 @@ describe("plugins/github/heuristics/mentionsAuthorReference", () => {
return `${issueUrl(issueNumber)}#issuecomment-${commentNumber}`;
}
const data = {
repository: {
const repository: Repository = {
__typename: "Repository",
id: "repo:my-repo",
issues: connection([
issues: [
{
__typename: "Issue",
id: "issue:1",
url: issueUrl(1),
number: 1,
title: "calling into the void",
body: "hi @amethyst",
author: authors.steven(),
comments: connection([]),
reactions: connection([]),
comments: [],
reactions: [],
},
{
__typename: "Issue",
id: "issue:2",
number: 2,
url: issueUrl(2),
title: "an issue with many types of references",
body: "it is me, @steven\n\nPaired with: @pearl",
author: authors.steven(),
reactions: connection([]),
comments: connection([
reactions: [],
comments: [
{
__typename: "IssueComment",
id: "comment:2_1",
url: issueCommentUrl(2, 1),
body: "parry parry thrust @pearl\nparry parry thrust @steven",
author: authors.holo(),
reactions: connection([]),
reactions: [],
},
{
__typename: "IssueComment",
id: "comment:2_2",
url: issueCommentUrl(2, 2),
body: "@holo-pearl: stop!",
author: authors.steven(),
reactions: connection([]),
reactions: [],
},
{
__typename: "IssueComment",
id: "comment:2_3",
url: issueCommentUrl(2, 3),
body: "@amethyst @garnet why aren't you helping",
author: authors.pearl(),
reactions: connection([]),
reactions: [],
},
{
__typename: "IssueComment",
id: "comment:2_4",
url: issueCommentUrl(2, 4),
body: "@amethyst! come quickly, @amethyst!",
author: authors.garnet(),
reactions: connection([]),
reactions: [],
},
{
__typename: "IssueComment",
id: "comment:2_5",
url: issueCommentUrl(2, 5),
body: "i am busy fighting @boomerang-blade guy",
author: authors.amethyst(),
reactions: connection([]),
reactions: [],
},
]),
],
},
]),
pulls: connection([
],
pullRequests: [
{
__typename: "PullRequest",
id: "pull:3",
url: "https://github.com/my-owner/my-repo/pulls/3",
number: 3,
@ -132,12 +131,12 @@ describe("plugins/github/heuristics/mentionsAuthorReference", () => {
mergeCommit: null,
additions: 0,
deletions: 0,
reactions: connection([]),
comments: connection([]),
reactions: [],
comments: [],
author: authors.steven(),
reviews: connection([]),
reviews: [],
},
]),
],
url: "https://github.com/my-owner/my-repo",
name: "my-repo",
owner: {
@ -147,9 +146,8 @@ describe("plugins/github/heuristics/mentionsAuthorReference", () => {
url: "https://github.com/my-owner",
},
defaultBranchRef: null,
},
};
view.addData(data);
view.addRepository(repository);
return view;
}