From b1e1022c7076407c7b23eb4e46e6e5dcaf0e9a8c Mon Sep 17 00:00:00 2001 From: Gregor Martynus Date: Mon, 18 May 2020 10:16:18 -0700 Subject: [PATCH] test: deprecated parameter --- test/deprecations.test.ts | 63 ++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/test/deprecations.test.ts b/test/deprecations.test.ts index 3b5259fbc..9b6ac2b86 100644 --- a/test/deprecations.test.ts +++ b/test/deprecations.test.ts @@ -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",