Skip to content

Commit

Permalink
test: deprecated parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed May 18, 2020
1 parent 5807be8 commit b1e1022
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions test/deprecations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,36 +52,39 @@ describe("Deprecations", () => {
expect(warnCalledCount).toEqual(1);
});

// it("deprecated parameter", async () => {
// const mock = fetchMock
// .sandbox()
// .getOnce("path:/repos/octocat/hello-world/commits/sha123", {
// ok: true
// });
// const MyOctokit = Octokit.plugin(restEndpointMethods);
// let warnCalledCount = 0;
// const octokit = new MyOctokit({
// request: {
// fetch: mock
// },
// log: {
// warn: (deprecation: Error) => {
// warnCalledCount++;
// expect(deprecation).toMatch(
// '"commit_sha" parameter is deprecated for "octokit.repos.getCommit()". Use "ref" instead'
// );
// }
// }
// });
// // See https://developer.github.com/v3/issues/comments/#create-a-comment
// const { data } = await octokit.repos.getCommit({
// owner: "octocat",
// repo: "hello-world",
// commit_sha: "sha123"
// });
// expect(data).toStrictEqual({ ok: true });
// expect(warnCalledCount).toEqual(1);
// });
it("deprecated parameter", async () => {
const mock = fetchMock
.sandbox()
.putOnce("path:/repos/octocat/hello-world/secrets/MY_SECRET", {
ok: true,
});
const MyOctokit = Octokit.plugin(restEndpointMethods);

let warnCalledCount = 0;
const octokit = new MyOctokit({
request: {
fetch: mock,
},
log: {
warn: (deprecation: Error) => {
warnCalledCount++;
expect(deprecation).toMatch(
'"name" parameter is deprecated for "octokit.actions.createOrUpdateRepoSecret()". Use "secret_name" instead'
);
},
},
});
// See https://developer.github.com/v3/actions/secrets/#create-or-update-a-repository-secret
// The `:secret_name` URL parameter was `:name` until May 14, 2020
// @ts-ignore
const { data } = await octokit.actions.createOrUpdateRepoSecret({
owner: "octocat",
repo: "hello-world",
secret: "MY_SECRET",
});
expect(data).toStrictEqual({ ok: true });
expect(warnCalledCount).toEqual(1);
});
// it("deprecated parameter + new parameter", async () => {
// const mock = fetchMock.sandbox().post(
// "path:/repos/octocat/hello-world/issues/456/comments",
Expand Down

0 comments on commit b1e1022

Please sign in to comment.