Skip to content

Commit 78bc983

Browse files
committed
test: deprecate octokit.gitdata.*, octokit.pullRequests.*
1 parent aab7d1d commit 78bc983

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

test/deprecations.test.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,62 @@ describe("Deprecations", () => {
111111
expect(data).toStrictEqual({ ok: true });
112112
expect(warnCalledCount).toEqual(1);
113113
});
114+
115+
it("octokit.pullRequests.get", () => {
116+
const mock = fetchMock
117+
.sandbox()
118+
.getOnce("path:/repos/octocat/hello-world/pulls/123", {
119+
ok: true
120+
});
121+
const MyOctokit = Octokit.plugin(restEndpointMethods);
122+
let warnCalledCount = 0;
123+
const octokit = new MyOctokit({
124+
log: {
125+
warn: (deprecation: Error) => {
126+
warnCalledCount++;
127+
expect(deprecation.message).toMatch(
128+
`[@octokit/plugin-rest-endpoint-methods] "octokit.pullRequests.*" methods are deprecated, use "octokit.pulls.*" instead`
129+
);
130+
}
131+
},
132+
request: {
133+
fetch: mock
134+
}
135+
});
136+
octokit.pullRequests.get({
137+
owner: "octocat",
138+
repo: "hello-world",
139+
pull_number: 123
140+
});
141+
expect(warnCalledCount).toEqual(1);
142+
});
143+
144+
it("octokit.gitdata.getCommit", () => {
145+
const mock = fetchMock
146+
.sandbox()
147+
.getOnce("path:/repos/octocat/hello-world/git/commits/sha123", {
148+
ok: true
149+
});
150+
const MyOctokit = Octokit.plugin(restEndpointMethods);
151+
let warnCalledCount = 0;
152+
const octokit = new MyOctokit({
153+
log: {
154+
warn: (deprecation: Error) => {
155+
warnCalledCount++;
156+
expect(deprecation.message).toMatch(
157+
`[@octokit/plugin-rest-endpoint-methods] "octokit.gitdata.*" methods are deprecated, use "octokit.git.*" instead`
158+
);
159+
}
160+
},
161+
request: {
162+
fetch: mock
163+
}
164+
});
165+
octokit.gitdata.getCommit({
166+
owner: "octocat",
167+
repo: "hello-world",
168+
commit_sha: "sha123"
169+
});
170+
expect(warnCalledCount).toEqual(1);
171+
});
114172
});

0 commit comments

Comments
 (0)