forked from octokit/core.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
issues.test.ts
31 lines (24 loc) · 895 Bytes
/
issues.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Octokit } from "../src";
import fetchMock from "fetch-mock";
/*
💖 Welcome, dear contributor!
If you want to create a test that reproduces a problem reported in a GitHub issue, you came to the right place.
Copy the "#123 example issue" test below, replace 123 with the new issue number and "example issue" with a short
description.
You will likely have to mock http requests, for which we use `fetch-mock`: https://www.wheresrhys.co.uk/fetch-mock/
*/
describe("issues", () => {
test("#123 example issue", async () => {
const mock = fetchMock
.sandbox()
.getOnce("https://api.github.com/", { ok: true });
const octokit = new Octokit({
request: {
fetch: mock,
},
});
const response = await octokit.request("/");
expect(response.status).toEqual(200);
expect(response.data).toStrictEqual({ ok: true });
});
});