Skip to content

Commit

Permalink
test(e2e): Fixes e2e test import and adds iterator test (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
davelosert authored Sep 18, 2022
1 parent 0ffc417 commit 8a3832c
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion test/paginate-graphql.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Octokit } from "@octokit/core";
import { paginateGraphql } from "../src";
import { MissingCursorChange } from "../src/errors";

const PatchedOctokit = Octokit.plugin(paginateGraphql);

Expand Down Expand Up @@ -36,4 +35,36 @@ describe("paginate-graphql-js E2E Test", () => {
expect(result).toBeDefined();
expect(result.repository.repositoryTopics.nodes).toHaveLength(3);
});

it("works with iterated paginated query.", async () => {
const myOctokit = new PatchedOctokit({
auth: token,
});
const iterator = myOctokit.graphql.paginate.iterator(
`query paginate($cursor: String) {
repository(owner: "octokit", name: "plugin-paginate-graphql.js") {
repositoryTopics(first: 1, after: $cursor) {
nodes{
topic {
name
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}`
);

let iterations = 0;
for await (const result of iterator) {
expect(result).toBeDefined();
expect(result.repository.repositoryTopics.nodes).toHaveLength(1);
iterations += 1;
}

expect(iterations).toEqual(3);
});
});

0 comments on commit 8a3832c

Please sign in to comment.