File tree Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ const { suite } = require ( "uvu" ) ;
2
+ const assert = require ( "uvu/assert" ) ;
3
+
4
+ const nock = require ( "nock" ) ;
5
+ nock . disableNetConnect ( ) ;
6
+
7
+ const { Probot, ProbotOctokit } = require ( "probot" ) ;
8
+
9
+ const app = require ( "./app" ) ;
10
+
11
+ /** @type {import('probot').Probot */
12
+ let probot ;
13
+ const test = suite ( "app" ) ;
14
+ test . before . each ( ( ) => {
15
+ probot = new Probot ( {
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" , async function ( ) {
30
+ const mock = 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
+ return true ;
38
+ }
39
+ )
40
+ . reply ( 201 , { } ) ;
41
+
42
+ await probot . 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 ( ) ;
You can’t perform that action at this time.
0 commit comments