Skip to content

Commit

Permalink
fix: adapt for latest @octokit/types
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Dec 3, 2020
1 parent 0acdef4 commit 9c96cc8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion test/compose-paginate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test("composePaginateRest(octokit, route)", async () => {
per_page: 1,
}
);
expect(organizations).toStrictEqual([ORG1, ORG2]);
expect(organizations.map((o) => o.id)).toStrictEqual([1, 2]);
});

test("composePaginateRest.iterator(octokit, route)", () => {
Expand Down
4 changes: 2 additions & 2 deletions test/issues.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("https://github.com/octokit/plugin-paginate-rest.js/issues/46", () => {
}
);

expect(result).toStrictEqual([{ id: 123 }]);
expect(result[0].id).toEqual(123);
});

it("octokit.paginate(octokit.projects.listCards, { column })", async () => {
Expand All @@ -50,6 +50,6 @@ describe("https://github.com/octokit/plugin-paginate-rest.js/issues/46", () => {
column_id: 123,
});

expect(result).toStrictEqual([{ id: 123 }]);
expect(result[0].id).toEqual(123);
});
});
19 changes: 10 additions & 9 deletions test/paginate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("pagination", () => {
org: "octokit",
per_page: 1,
});
expect(organizations).toStrictEqual([ORG1, ORG2]);
expect(organizations.map((o) => o.id)).toStrictEqual([1, 2]);

await octokit
.paginate(
Expand Down Expand Up @@ -84,7 +84,7 @@ describe("pagination", () => {
});

const organizations = await octokit.paginate(octokit.orgs.list);
expect(organizations).toStrictEqual([ORG1, ORG2]);
expect(organizations.map((o) => o.id)).toStrictEqual([1, 2]);
});

it(".paginate(request, options)", async () => {
Expand Down Expand Up @@ -116,7 +116,7 @@ describe("pagination", () => {
org: "octokit",
per_page: 1,
});
expect(organizations).toStrictEqual([ORG1, ORG2]);
expect(organizations.map((o) => o.id)).toStrictEqual([1, 2]);
});

it(".paginate(request, options, mapFunction)", async () => {
Expand Down Expand Up @@ -228,15 +228,15 @@ describe("pagination", () => {
const mock = fetchMock
.sandbox()
.get("https://api.github.com/orgs/octokit/repos?per_page=1", {
body: [ORG1],
body: [{ id: 1 }],
headers: {
link:
'<https://pagination-test.com/foobar?page=2&per_page=1>; rel="next"',
"X-GitHub-Media-Type": "github.v3; format=json",
},
})
.get("https://pagination-test.com/foobar?page=2&per_page=1", {
body: [ORG2],
body: [{ id: 2 }],
headers: {},
});

Expand All @@ -248,24 +248,24 @@ describe("pagination", () => {

return octokit
.paginate("GET /orgs/{org}/repos", { org: "octokit", per_page: 1 })
.then((organizations) => {
expect(organizations).toStrictEqual([{ id: 1 }, { id: 2 }]);
.then((repos) => {
expect(repos.map((o) => o.id)).toStrictEqual([1, 2]);
});
});

it("autopagination", () => {
const mock = fetchMock
.sandbox()
.get("https://api.github.com/orgs/octokit/repos?per_page=1", {
body: [ORG1],
body: [{ id: 1 }],
headers: {
link:
'<https://pagination-test.com/orgs/octokit/repos?page=2&per_page=1>; rel="next"',
"X-GitHub-Media-Type": "github.v3; format=json",
},
})
.get("https://pagination-test.com/orgs/octokit/repos?page=2&per_page=1", {
body: [ORG2],
body: [{ id: 2 }],
headers: {},
});

Expand All @@ -291,6 +291,7 @@ describe("pagination", () => {
request: { paginate: true },
})
.then((organizations) => {
// @ts-ignore
expect(organizations).toStrictEqual([{ id: 1 }, { id: 2 }]);
});
});
Expand Down

0 comments on commit 9c96cc8

Please sign in to comment.