11const nock = require ( "nock" ) ;
2- const { Probot } = require ( "probot" ) ;
2+ const { Probot, ProbotOctokit } = require ( "probot" ) ;
33const outdent = require ( "outdent" ) ;
4+ const pino = require ( "pino" ) ;
5+ const Stream = require ( "stream" ) ;
46
57const changesetBot = require ( "." ) ;
68
@@ -10,27 +12,65 @@ const releasePullRequestOpen = require("./test/fixtures/release_pull_request.ope
1012
1113nock . disableNetConnect ( ) ;
1214
15+ const output = [ ]
16+
17+ const streamLogsToOutput = new Stream . Writable ( { objectMode : true } ) ;
18+ streamLogsToOutput . _write = ( object , encoding , done ) => {
19+ output . push ( JSON . parse ( object ) ) ;
20+ done ( ) ;
21+ } ;
22+
1323/*
1424Oh god none of these tests work - we should really do something about having this tested
1525*/
16- describe . skip ( "changeset-bot" , ( ) => {
26+ describe ( "changeset-bot" , ( ) => {
1727 let probot ;
28+ let app
29+
30+ beforeEach ( async ( ) => {
31+ probot = new Probot ( {
32+ githubToken : "test" ,
33+ appId : 123 ,
34+ privateKey : 123 ,
35+ log : pino ( streamLogsToOutput ) ,
36+ Octokit : ProbotOctokit . defaults ( {
37+ retry : { enabled : false } ,
38+ throttle : { enabled : false } ,
39+ } ) ,
40+ } ) ;
1841
19- beforeEach ( ( ) => {
20- probot = new Probot ( { } ) ;
21- const app = probot . load ( changesetBot ) ;
42+
43+ app = changesetBot . default ( probot )
2244
2345 // just return a test token
2446 app . app = ( ) => "test.ts" ;
2547 } ) ;
2648
2749 it ( "should add a comment when there is no comment" , async ( ) => {
50+ nock ( "https://raw.githubusercontent.com" )
51+ . get ( "/changesets/bot/test/package.json" )
52+ . reply ( 200 , { } )
53+
54+ nock ( "https://raw.githubusercontent.com" )
55+ . get ( "/changesets/bot/test/.changeset/config.json" )
56+ . reply ( 200 , { } )
57+
58+ nock ( "https://api.github.com" )
59+ . get ( "/repos/changesets/bot/git/trees/test?recursive=1" )
60+ . reply ( 200 , {
61+ tree : [ ] ,
62+ } )
63+
64+ nock ( "https://api.github.com" )
65+ . post ( "/app/installations/2462428/access_tokens" )
66+ . reply ( 200 , [ ] )
67+
2868 nock ( "https://api.github.com" )
2969 . get ( "/repos/pyu/testing-things/issues/1/comments" )
3070 . reply ( 200 , [ ] ) ;
3171
3272 nock ( "https://api.github.com" )
33- . get ( "/repos/pyu/testing-things /pulls/1 /files" )
73+ . get ( "/repos/changesets/bot /pulls/2 /files" )
3474 . reply ( 200 , [
3575 { filename : ".changeset/something/changes.md" , status : "added" }
3676 ] ) ;
@@ -40,13 +80,13 @@ describe.skip("changeset-bot", () => {
4080 . reply ( 200 , [ { sha : "ABCDE" } ] ) ;
4181
4282 nock ( "https://api.github.com" )
43- . post ( "/repos/pyu/testing-things /issues/1 /comments" , body => {
44- expect ( body . comment_id ) . toBeNull ( ) ;
83+ . post ( "/repos/changesets/bot /issues/2 /comments" , body => {
84+ expect ( body . comment_id ) . toBeUndefined ( )
4585 return true ;
4686 } )
4787 . reply ( 200 ) ;
4888
49- await probot . receive ( {
89+ await app . receive ( {
5090 name : "pull_request" ,
5191 payload : pullRequestOpen
5292 } ) ;
0 commit comments