Skip to content

Commit 3630233

Browse files
committed
- fix formatting
1 parent d82fbf8 commit 3630233

File tree

2 files changed

+45
-22
lines changed

2 files changed

+45
-22
lines changed

__tests__/annotator.test.ts

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ describe('attachComment', () => {
2424
// Import context after mocking
2525
const {context} = require('@actions/github/lib/utils.js')
2626
mockContext = context
27-
27+
2828
// Mock core.warning
2929
mockWarning = jest.spyOn(core, 'warning').mockImplementation(() => {})
30-
30+
3131
// Mock octokit
3232
mockOctokit = {
3333
paginate: jest.fn(),
@@ -52,7 +52,10 @@ describe('attachComment', () => {
5252
mockOctokit.paginate.mockResolvedValue([])
5353

5454
const checkName = ['Test Check']
55-
const table = [['Test', 'Result'], ['Example Test', 'Passed']]
55+
const table = [
56+
['Test', 'Result'],
57+
['Example Test', 'Passed']
58+
]
5659
const prId = '123'
5760

5861
await attachComment(mockOctokit, checkName, false, table, [], [], [], prId)
@@ -75,7 +78,10 @@ describe('attachComment', () => {
7578
mockOctokit.paginate.mockResolvedValue([])
7679

7780
const checkName = ['Test Check']
78-
const table = [['Test', 'Result'], ['Example Test', 'Passed']]
81+
const table = [
82+
['Test', 'Result'],
83+
['Example Test', 'Passed']
84+
]
7985

8086
await attachComment(mockOctokit, checkName, false, table, [], [], [])
8187

@@ -95,7 +101,10 @@ describe('attachComment', () => {
95101
mockContext.issue.number = undefined
96102

97103
const checkName = ['Test Check']
98-
const table = [['Test', 'Result'], ['Example Test', 'Passed']]
104+
const table = [
105+
['Test', 'Result'],
106+
['Example Test', 'Passed']
107+
]
99108

100109
await attachComment(mockOctokit, checkName, false, table, [], [], [])
101110

@@ -117,7 +126,10 @@ describe('attachComment', () => {
117126
mockOctokit.paginate.mockResolvedValue([existingComment])
118127

119128
const checkName = ['Test Check']
120-
const table = [['Test', 'Result'], ['Example Test', 'Updated']]
129+
const table = [
130+
['Test', 'Result'],
131+
['Example Test', 'Updated']
132+
]
121133

122134
await attachComment(mockOctokit, checkName, true, table, [], [], [])
123135

@@ -135,7 +147,10 @@ describe('attachComment', () => {
135147
mockContext.issue.number = undefined
136148

137149
const checkName = ['Test Check']
138-
const table = [['Test', 'Result'], ['Example Test', 'Passed']]
150+
const table = [
151+
['Test', 'Result'],
152+
['Example Test', 'Passed']
153+
]
139154
const prId = 'invalid-number'
140155

141156
await attachComment(mockOctokit, checkName, false, table, [], [], [], prId)
@@ -154,7 +169,10 @@ describe('attachComment', () => {
154169
mockOctokit.paginate.mockResolvedValue([])
155170

156171
const checkName = ['Test Check']
157-
const table = [['Test', 'Result'], ['Example Test', 'Passed']]
172+
const table = [
173+
['Test', 'Result'],
174+
['Example Test', 'Passed']
175+
]
158176
const prId = ' 123 '
159177

160178
await attachComment(mockOctokit, checkName, false, table, [], [], [], prId)
@@ -181,20 +199,20 @@ describe('attachComment', () => {
181199
mockOctokit.paginate.mockResolvedValue([existingComment])
182200

183201
const checkName = ['Test Check']
184-
const table = [['Test', 'Result'], ['Example Test', 'Updated']]
202+
const table = [
203+
['Test', 'Result'],
204+
['Example Test', 'Updated']
205+
]
185206
const prId = '789'
186207

187208
await attachComment(mockOctokit, checkName, true, table, [], [], [], prId)
188209

189210
// 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+
})
198216

199217
// Verify comment was updated
200218
expect(mockOctokit.rest.issues.updateComment).toHaveBeenCalledWith({
@@ -205,7 +223,6 @@ describe('attachComment', () => {
205223
})
206224
expect(mockOctokit.rest.issues.createComment).not.toHaveBeenCalled()
207225
})
208-
209226
})
210227

211228
describe('buildCommentIdentifier', () => {
@@ -214,4 +231,4 @@ describe('buildCommentIdentifier', () => {
214231
const identifier = buildCommentIdentifier(checkName)
215232
expect(identifier).toBe('<!-- Summary comment for ["Test Check"] by mikepenz/action-junit-report -->')
216233
})
217-
})
234+
})

src/annotator.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,11 @@ export async function attachComment(
185185
): Promise<void> {
186186
// Use provided prId or fall back to context issue number
187187
const issueNumber = prId ? parseInt(prId, 10) : context.issue.number
188-
188+
189189
if (!issueNumber) {
190-
core.warning(`⚠️ Action requires a valid issue number (PR reference) or pr_id input to be able to attach a comment..`)
190+
core.warning(
191+
`⚠️ Action requires a valid issue number (PR reference) or pr_id input to be able to attach a comment..`
192+
)
191193
return
192194
}
193195

@@ -237,7 +239,11 @@ export async function attachComment(
237239
}
238240
}
239241

240-
async function findPriorComment(octokit: InstanceType<typeof GitHub>, identifier: string, issueNumber: number): Promise<number | undefined> {
242+
async function findPriorComment(
243+
octokit: InstanceType<typeof GitHub>,
244+
identifier: string,
245+
issueNumber: number
246+
): Promise<number | undefined> {
241247
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
242248
owner: context.repo.owner,
243249
repo: context.repo.repo,

0 commit comments

Comments
 (0)