Skip to content

Commit

Permalink
fix: octokit.git.listRefs() logs deprecation (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m authored Oct 7, 2020
1 parent ff5629f commit 9e80cb3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/generated/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,8 @@ export default {
per_page: { type: "integer" },
repo: { required: true, type: "string" }
},
url: "/repos/:owner/:repo/git/refs/:namespace"
url: "/repos/:owner/:repo/git/refs/:namespace",
deprecated: "`[@octokit/plugin-rest-endpoint-methods] \"octokit.git.listRefs({ owner, repo, namespace })\" is deprecated. Use \"octokit.git.listMatchingRefs({ owner, repo, ref })\" instead"
},
updateRef: {
method: "PATCH",
Expand Down
29 changes: 29 additions & 0 deletions test/deprecations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,33 @@ describe("Deprecations", () => {
});
expect(warnCalledCount).toEqual(1);
});

it("octokit.git.listRefs()", () => {
const mock = fetchMock
.sandbox()
.getOnce("path:/repos/octocat/hello-world/git/refs/heads/", {
ok: true
});
const MyOctokit = Octokit.plugin(restEndpointMethods);
let warnCalledCount = 0;
const octokit = new MyOctokit({
log: {
warn: (deprecation: Error) => {
warnCalledCount++;
expect(deprecation.message).toMatch(
`[@octokit/plugin-rest-endpoint-methods] "octokit.git.listRefs({ owner, repo, namespace })" is deprecated. Use "octokit.git.listMatchingRefs({ owner, repo, ref })" instead`
);
}
},
request: {
fetch: mock
}
});
octokit.git.listRefs({
owner: "octocat",
repo: "hello-world",
namespace: "heads/"
});
expect(warnCalledCount).toEqual(1);
});
});

0 comments on commit 9e80cb3

Please sign in to comment.