Skip to content

Commit a0298e6

Browse files
committed
test: deprecations
1 parent 21ded9b commit a0298e6

File tree

1 file changed

+44
-48
lines changed

1 file changed

+44
-48
lines changed

test/deprecations.test.ts

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,52 @@ import { restEndpointMethods } from "../src";
66
// All the commented out tests are no longer valid as the methods/parameters
77
// have been removed. We keep them here for future reference
88
describe("Deprecations", () => {
9-
it("There are no deprecations", () => {
10-
expect("ok").toBeTruthy();
9+
it("renamed method", async () => {
10+
const mock = fetchMock.sandbox().deleteOnce("path:/reactions/1", 204);
11+
const MyOctokit = Octokit.plugin(restEndpointMethods);
12+
let warnCalledCount = 0;
13+
const octokit = new MyOctokit({
14+
request: {
15+
fetch: mock
16+
},
17+
log: {
18+
warn: (deprecation: Error) => {
19+
warnCalledCount++;
20+
expect(deprecation).toMatch(
21+
"octokit.reactions.delete() has been renamed to octokit.reactions.deleteLegacy()"
22+
);
23+
}
24+
}
25+
});
26+
// See https://developer.github.com/v3/reactions/#delete-a-reaction-legacy
27+
await octokit.reactions.delete({ reaction_id: 1 });
28+
29+
expect(warnCalledCount).toEqual(1);
30+
});
31+
32+
it("deprecated method", async () => {
33+
const mock = fetchMock.sandbox().deleteOnce("path:/reactions/1", 204);
34+
const MyOctokit = Octokit.plugin(restEndpointMethods);
35+
let warnCalledCount = 0;
36+
const octokit = new MyOctokit({
37+
request: {
38+
fetch: mock
39+
},
40+
log: {
41+
warn: (deprecation: Error) => {
42+
warnCalledCount++;
43+
expect(deprecation).toMatch(
44+
"octokit.reactions.deleteLegacy() is deprecated, see https://developer.github.com/v3/reactions/#delete-a-reaction-legacy"
45+
);
46+
}
47+
}
48+
});
49+
// See https://developer.github.com/v3/reactions/#delete-a-reaction-legacy
50+
await octokit.reactions.deleteLegacy({ reaction_id: 1 });
51+
52+
expect(warnCalledCount).toEqual(1);
1153
});
1254

13-
// it("renamed method", async () => {
14-
// const mock = fetchMock.sandbox().get("path:/licenses", []);
15-
// const MyOctokit = Octokit.plugin(restEndpointMethods);
16-
// let warnCalledCount = 0;
17-
// const octokit = new MyOctokit({
18-
// request: {
19-
// fetch: mock
20-
// },
21-
// log: {
22-
// warn: (deprecation: Error) => {
23-
// warnCalledCount++;
24-
// expect(deprecation).toMatch(
25-
// "octokit.licenses.list() has been renamed to octokit.licenses.listCommonlyUsed()"
26-
// );
27-
// }
28-
// }
29-
// });
30-
// // See https://developer.github.com/v3/licenses/#list-commonly-used-licenses
31-
// const { data } = await octokit.licenses.list();
32-
// expect(data).toStrictEqual([]);
33-
// expect(warnCalledCount).toEqual(1);
34-
// });
35-
// it("deprecated method", async () => {
36-
// const mock = fetchMock
37-
// .sandbox()
38-
// .postOnce("path:/authorizations", { ok: true });
39-
// const MyOctokit = Octokit.plugin(restEndpointMethods);
40-
// let warnCalledCount = 0;
41-
// const octokit = new MyOctokit({
42-
// request: {
43-
// fetch: mock
44-
// },
45-
// log: {
46-
// warn: (deprecation: Error) => {
47-
// warnCalledCount++;
48-
// expect(deprecation).toMatch(
49-
// "octokit.oauthAuthorizations.createAuthorization() is deprecated, see https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization"
50-
// );
51-
// }
52-
// }
53-
// });
54-
// // See https://developer.github.com/v3/licenses/#list-commonly-used-licenses
55-
// const { data } = await octokit.oauthAuthorizations.createAuthorization();
56-
// expect(data).toStrictEqual({ ok: true });
57-
// expect(warnCalledCount).toEqual(1);
58-
// });
5955
// it("deprecated parameter", async () => {
6056
// const mock = fetchMock
6157
// .sandbox()

0 commit comments

Comments
 (0)