This commit is contained in:
Jeff Martin 2024-06-10 23:09:48 +00:00
Родитель 877eb501d7
Коммит eb6001cc27
4 изменённых файлов: 12 добавлений и 8 удалений

Просмотреть файл

@ -1,5 +1,5 @@
import {actionStatus} from '../../src/functions/action-status'
import { truncateCommentBody } from '../../src/functions/truncate-comment-body'
import {truncateCommentBody} from '../../src/functions/truncate-comment-body'
var context
var octokit
@ -160,7 +160,9 @@ test('uses default log url when the "message" variable is empty for a success',
test('truncates the message when it is too large for an issue comment', async () => {
const message = 'a'.repeat(65538)
expect(await actionStatus(context, octokit, 123, message, true)).toBe(undefined)
expect(await actionStatus(context, octokit, 123, message, true)).toBe(
undefined
)
expect(octokit.rest.issues.createComment).toHaveBeenCalledWith({
body: truncateCommentBody(message),
issue_number: 1,
@ -179,4 +181,4 @@ test('truncates the message when it is too large for an issue comment', async ()
reaction_id: 123,
repo: 'test'
})
})
})

Просмотреть файл

@ -1,4 +1,4 @@
import { truncateCommentBody } from '../../src/functions/truncate-comment-body'
import {truncateCommentBody} from '../../src/functions/truncate-comment-body'
test('truncates a long message', () => {
const message = 'a'.repeat(65537)
@ -8,7 +8,6 @@ test('truncates a long message', () => {
test('does not truncate a short message', () => {
const message = 'a'.repeat(65536)
const got= truncateCommentBody(message)
const got = truncateCommentBody(message)
expect(got).toEqual(message)
})

Просмотреть файл

@ -1,4 +1,4 @@
import { truncateCommentBody } from "./truncate-comment-body"
import {truncateCommentBody} from './truncate-comment-body'
// Default failure reaction
const thumbsDown = '-1'

Просмотреть файл

@ -12,6 +12,9 @@ export function truncateCommentBody(message) {
if (message.length <= maxCommentLength) {
return message
}
let truncated = message.substring(0, maxCommentLength - truncatedMessageStart.length - truncatedMessageEnd.length)
let truncated = message.substring(
0,
maxCommentLength - truncatedMessageStart.length - truncatedMessageEnd.length
)
return truncatedMessageStart + truncated + truncatedMessageEnd
}