-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
62 lines (53 loc) · 1.32 KB
/
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
const { suite } = require("uvu");
const assert = require("uvu/assert");
const nock = require("nock");
nock.disableNetConnect();
const { Probot, ProbotOctokit } = require("probot");
const app = require("./app");
/** @type {import('probot').Probot */
let probot;
const test = suite("app");
test.before.each(() => {
probot = new Probot({
// simple authentication as alternative to appId/privateKey
githubToken: "test",
// disable logs
logLevel: "warn",
// disable request throttling and retries
Octokit: ProbotOctokit.defaults({
throttle: { enabled: false },
retry: { enabled: false },
}),
});
probot.load(app);
});
test("recieves issues.opened event", async function () {
const mock = nock("https://api.github.com")
// create new check run
.post(
"/repos/probot/example-azure-function/issues/1/comments",
(requestBody) => {
assert.equal(requestBody, { body: "Hello, World!" });
return true;
}
)
.reply(201, {});
await probot.receive({
name: "issues",
id: "1",
payload: {
action: "opened",
repository: {
owner: {
login: "probot",
},
name: "example-azure-function",
},
issue: {
number: 1,
},
},
});
assert.equal(mock.activeMocks(), []);
});
test.run();