@@ -11,23 +11,40 @@ it("findPreviousComment", async () => {
1111 } ,
1212 body : "<!-- Sticky Pull Request Comment -->\nprevious message"
1313 } ;
14- const otherComment = {
14+ const commentWithCustomHeader = {
1515 user : {
16- login : "some-user "
16+ login : "github-actions[bot] "
1717 } ,
18- body : "lgtm "
18+ body : "<!-- Sticky Pull Request CommentTypeA -->\nprevious message "
1919 } ;
20+ const otherComments = [
21+ {
22+ user : {
23+ login : "some-user"
24+ } ,
25+ body : "lgtm"
26+ } ,
27+ {
28+ user : {
29+ login : "github-actions[bot]"
30+ } ,
31+ body : "<!-- Sticky Pull Request CommentTypeB -->\nprevious message"
32+ }
33+ ] ;
2034 const octokit = {
2135 issues : {
2236 listComments : jest . fn ( ( ) =>
2337 Promise . resolve ( {
24- data : [ otherComment , comment ]
38+ data : [ commentWithCustomHeader , comment , ... otherComments ]
2539 } )
2640 )
2741 }
2842 } ;
2943
30- expect ( await findPreviousComment ( octokit , repo , 123 ) ) . toBe ( comment ) ;
44+ expect ( await findPreviousComment ( octokit , repo , 123 , "" ) ) . toBe ( comment ) ;
45+ expect ( await findPreviousComment ( octokit , repo , 123 , "TypeA" ) ) . toBe (
46+ commentWithCustomHeader
47+ ) ;
3148 expect ( octokit . issues . listComments ) . toBeCalledWith ( { issue_number : 123 } ) ;
3249} ) ;
3350it ( "updateComment" , async ( ) => {
@@ -37,12 +54,19 @@ it("updateComment", async () => {
3754 }
3855 } ;
3956 expect (
40- await updateComment ( octokit , repo , 456 , "hello there" )
57+ await updateComment ( octokit , repo , 456 , "hello there" , "" )
4158 ) . toBeUndefined ( ) ;
4259 expect ( octokit . issues . updateComment ) . toBeCalledWith ( {
4360 comment_id : 456 ,
4461 body : "<!-- Sticky Pull Request Comment -->\nhello there"
4562 } ) ;
63+ expect (
64+ await updateComment ( octokit , repo , 456 , "hello there" , "TypeA" )
65+ ) . toBeUndefined ( ) ;
66+ expect ( octokit . issues . updateComment ) . toBeCalledWith ( {
67+ comment_id : 456 ,
68+ body : "<!-- Sticky Pull Request CommentTypeA -->\nhello there"
69+ } ) ;
4670} ) ;
4771it ( "createComment" , async ( ) => {
4872 const octokit = {
@@ -51,10 +75,17 @@ it("createComment", async () => {
5175 }
5276 } ;
5377 expect (
54- await createComment ( octokit , repo , 456 , "hello there" )
78+ await createComment ( octokit , repo , 456 , "hello there" , "" )
5579 ) . toBeUndefined ( ) ;
5680 expect ( octokit . issues . createComment ) . toBeCalledWith ( {
5781 issue_number : 456 ,
5882 body : "<!-- Sticky Pull Request Comment -->\nhello there"
5983 } ) ;
84+ expect (
85+ await createComment ( octokit , repo , 456 , "hello there" , "TypeA" )
86+ ) . toBeUndefined ( ) ;
87+ expect ( octokit . issues . createComment ) . toBeCalledWith ( {
88+ issue_number : 456 ,
89+ body : "<!-- Sticky Pull Request CommentTypeA -->\nhello there"
90+ } ) ;
6091} ) ;
0 commit comments