-
Notifications
You must be signed in to change notification settings - Fork 309
/
issues.test.ts
32 lines (25 loc) · 967 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
32
import { Octokit } from "../src/index.ts";
import fetchMock from "fetch-mock";
import { describe, expect, test } from "vitest";
/*
💖 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
.createInstance()
.getOnce("https://api.github.com/", { ok: true });
const octokit = new Octokit({
request: {
fetch: mock.fetchHandler,
},
});
const response = await octokit.request("/");
expect(response.status).toEqual(200);
expect(response.data).toEqual({ ok: true });
});
});