/
register-endpoints-test.js
63 lines (54 loc) · 1.3 KB
/
register-endpoints-test.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const nock = require("nock");
const { Octokit } = require("../../");
require("../mocha-node-setup");
describe("registerEndpoints", () => {
it("optins are not altered in registered endpoint methods", () => {
nock("https://api.github.com")
.get("/repos/octocat/hello-world/issues/123")
.reply(200, {});
const octokit = new Octokit({
log: {
warn: () => {}
}
});
octokit.registerEndpoints({
foo: {
bar: {
method: "GET",
params: {
issue_number: {
required: true,
type: "integer"
},
number: {
alias: "issue_number",
deprecated: true,
type: "integer"
},
owner: {
required: true,
type: "string"
},
repo: {
required: true,
type: "string"
}
},
url: "/repos/:owner/:repo/issues/:issue_number"
}
}
});
const options = {
owner: "octocat",
repo: "hello-world",
number: 123
};
const promise = octokit.foo.bar(options);
expect(options).to.deep.equal({
owner: "octocat",
repo: "hello-world",
number: 123
});
return promise;
});
});