Skip to content

Commit 26c4f34

Browse files
committed
test: initial version
1 parent 5aa58f7 commit 26c4f34

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

‎test.js‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
const{ suite }=require("uvu");
2+
constassert=require("uvu/assert");
3+
4+
constnock=require("nock");
5+
nock.disableNetConnect();
6+
7+
const{ Probot, ProbotOctokit }=require("probot");
8+
9+
constapp=require("./app");
10+
11+
/** @type{import('probot').Probot */
12+
letprobot;
13+
consttest=suite("app");
14+
test.before.each(()=>{
15+
probot=newProbot({
16+
// simple authentication as alternative to appId/privateKey
17+
githubToken: "test",
18+
// disable logs
19+
logLevel: "warn",
20+
// disable request throttling and retries
21+
Octokit: ProbotOctokit.defaults({
22+
throttle: {enabled: false},
23+
retry: {enabled: false},
24+
}),
25+
});
26+
probot.load(app);
27+
});
28+
29+
test("recieves issues.opened event",asyncfunction(){
30+
constmock=nock("https://api.github.com")
31+
// create new check run
32+
.post(
33+
"/repos/probot/example-aws-lambda-serverless/issues/1/comments",
34+
(requestBody)=>{
35+
assert.equal(requestBody,{body: "Hello, World!"});
36+
37+
returntrue;
38+
}
39+
)
40+
.reply(201,{});
41+
42+
awaitprobot.receive({
43+
name: "issues",
44+
id: "1",
45+
payload: {
46+
action: "opened",
47+
repository: {
48+
owner: {
49+
login: "probot",
50+
},
51+
name: "example-aws-lambda-serverless",
52+
},
53+
issue: {
54+
number: 1,
55+
},
56+
},
57+
});
58+
59+
assert.equal(mock.activeMocks(),[]);
60+
});
61+
62+
test.run();

0 commit comments

Comments
(0)