@@ -24,10 +24,10 @@ describe('attachComment', () => {
24
24
// Import context after mocking
25
25
const { context} = require ( '@actions/github/lib/utils.js' )
26
26
mockContext = context
27
-
27
+
28
28
// Mock core.warning
29
29
mockWarning = jest . spyOn ( core , 'warning' ) . mockImplementation ( ( ) => { } )
30
-
30
+
31
31
// Mock octokit
32
32
mockOctokit = {
33
33
paginate : jest . fn ( ) ,
@@ -52,7 +52,10 @@ describe('attachComment', () => {
52
52
mockOctokit . paginate . mockResolvedValue ( [ ] )
53
53
54
54
const checkName = [ 'Test Check' ]
55
- const table = [ [ 'Test' , 'Result' ] , [ 'Example Test' , 'Passed' ] ]
55
+ const table = [
56
+ [ 'Test' , 'Result' ] ,
57
+ [ 'Example Test' , 'Passed' ]
58
+ ]
56
59
const prId = '123'
57
60
58
61
await attachComment ( mockOctokit , checkName , false , table , [ ] , [ ] , [ ] , prId )
@@ -75,7 +78,10 @@ describe('attachComment', () => {
75
78
mockOctokit . paginate . mockResolvedValue ( [ ] )
76
79
77
80
const checkName = [ 'Test Check' ]
78
- const table = [ [ 'Test' , 'Result' ] , [ 'Example Test' , 'Passed' ] ]
81
+ const table = [
82
+ [ 'Test' , 'Result' ] ,
83
+ [ 'Example Test' , 'Passed' ]
84
+ ]
79
85
80
86
await attachComment ( mockOctokit , checkName , false , table , [ ] , [ ] , [ ] )
81
87
@@ -95,7 +101,10 @@ describe('attachComment', () => {
95
101
mockContext . issue . number = undefined
96
102
97
103
const checkName = [ 'Test Check' ]
98
- const table = [ [ 'Test' , 'Result' ] , [ 'Example Test' , 'Passed' ] ]
104
+ const table = [
105
+ [ 'Test' , 'Result' ] ,
106
+ [ 'Example Test' , 'Passed' ]
107
+ ]
99
108
100
109
await attachComment ( mockOctokit , checkName , false , table , [ ] , [ ] , [ ] )
101
110
@@ -117,7 +126,10 @@ describe('attachComment', () => {
117
126
mockOctokit . paginate . mockResolvedValue ( [ existingComment ] )
118
127
119
128
const checkName = [ 'Test Check' ]
120
- const table = [ [ 'Test' , 'Result' ] , [ 'Example Test' , 'Updated' ] ]
129
+ const table = [
130
+ [ 'Test' , 'Result' ] ,
131
+ [ 'Example Test' , 'Updated' ]
132
+ ]
121
133
122
134
await attachComment ( mockOctokit , checkName , true , table , [ ] , [ ] , [ ] )
123
135
@@ -135,7 +147,10 @@ describe('attachComment', () => {
135
147
mockContext . issue . number = undefined
136
148
137
149
const checkName = [ 'Test Check' ]
138
- const table = [ [ 'Test' , 'Result' ] , [ 'Example Test' , 'Passed' ] ]
150
+ const table = [
151
+ [ 'Test' , 'Result' ] ,
152
+ [ 'Example Test' , 'Passed' ]
153
+ ]
139
154
const prId = 'invalid-number'
140
155
141
156
await attachComment ( mockOctokit , checkName , false , table , [ ] , [ ] , [ ] , prId )
@@ -154,7 +169,10 @@ describe('attachComment', () => {
154
169
mockOctokit . paginate . mockResolvedValue ( [ ] )
155
170
156
171
const checkName = [ 'Test Check' ]
157
- const table = [ [ 'Test' , 'Result' ] , [ 'Example Test' , 'Passed' ] ]
172
+ const table = [
173
+ [ 'Test' , 'Result' ] ,
174
+ [ 'Example Test' , 'Passed' ]
175
+ ]
158
176
const prId = ' 123 '
159
177
160
178
await attachComment ( mockOctokit , checkName , false , table , [ ] , [ ] , [ ] , prId )
@@ -181,20 +199,20 @@ describe('attachComment', () => {
181
199
mockOctokit . paginate . mockResolvedValue ( [ existingComment ] )
182
200
183
201
const checkName = [ 'Test Check' ]
184
- const table = [ [ 'Test' , 'Result' ] , [ 'Example Test' , 'Updated' ] ]
202
+ const table = [
203
+ [ 'Test' , 'Result' ] ,
204
+ [ 'Example Test' , 'Updated' ]
205
+ ]
185
206
const prId = '789'
186
207
187
208
await attachComment ( mockOctokit , checkName , true , table , [ ] , [ ] , [ ] , prId )
188
209
189
210
// Verify paginate was called with correct issue number
190
- expect ( mockOctokit . paginate ) . toHaveBeenCalledWith (
191
- mockOctokit . rest . issues . listComments ,
192
- {
193
- owner : 'test-owner' ,
194
- repo : 'test-repo' ,
195
- issue_number : 789
196
- }
197
- )
211
+ expect ( mockOctokit . paginate ) . toHaveBeenCalledWith ( mockOctokit . rest . issues . listComments , {
212
+ owner : 'test-owner' ,
213
+ repo : 'test-repo' ,
214
+ issue_number : 789
215
+ } )
198
216
199
217
// Verify comment was updated
200
218
expect ( mockOctokit . rest . issues . updateComment ) . toHaveBeenCalledWith ( {
@@ -205,7 +223,6 @@ describe('attachComment', () => {
205
223
} )
206
224
expect ( mockOctokit . rest . issues . createComment ) . not . toHaveBeenCalled ( )
207
225
} )
208
-
209
226
} )
210
227
211
228
describe ( 'buildCommentIdentifier' , ( ) => {
@@ -214,4 +231,4 @@ describe('buildCommentIdentifier', () => {
214
231
const identifier = buildCommentIdentifier ( checkName )
215
232
expect ( identifier ) . toBe ( '<!-- Summary comment for ["Test Check"] by mikepenz/action-junit-report -->' )
216
233
} )
217
- } )
234
+ } )
0 commit comments