/
errors.test.ts
42 lines (38 loc) · 1.12 KB
/
errors.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
33
34
35
36
37
38
39
40
41
42
import { getInstance, OctokitType } from "../util";
describe("api.github.com", () => {
let octokit: OctokitType;
beforeEach(() => {
return getInstance("errors", {
auth: "token 0000000000000000000000000000000000000001",
}).then((instance) => {
octokit = instance;
});
});
it("(#684) errors-test", () => {
return octokit.rest.issues
.createLabel({
owner: "octokit-fixture-org",
repo: "errors",
name: "foo",
color: "invalid",
})
.catch((error) => {
expect(error.message).toEqual(
`Validation Failed: {"resource":"Label","code":"invalid","field":"color"}`,
);
// To-Do: Figure out why the objects are not strictly equal
expect(JSON.stringify(error.response.data.errors)).toStrictEqual(
JSON.stringify([
{
resource: "Label",
code: "invalid",
field: "color",
},
]),
);
expect(error.response.data.documentation_url).toMatch(
new RegExp("rest/reference/issues#create-a-label"),
);
});
});
});