-
Notifications
You must be signed in to change notification settings - Fork 14
/
test.js
65 lines (56 loc) · 1.37 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
63
64
65
const { suite } = require("uvu");
const assert = require("uvu/assert");
const nock = require("nock");
nock.disableNetConnect();
const {
Probot,
ProbotOctokit,
} = require("@probot/adapter-aws-lambda-serverless");
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-aws-lambda-serverless/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-aws-lambda-serverless",
},
issue: {
number: 1,
},
},
});
assert.equal(mock.activeMocks(), []);
});
test.run();