feat: truncate content exceeding the byte limit (#129)
Some checks failed
Publish Docker Image / publish (push) Has been cancelled

This commit is contained in:
Peter Evans
2023-03-06 12:50:56 +09:00
committed by GitHub
parent 728b36f7bb
commit 202973a37c
6 changed files with 116 additions and 5116 deletions

View File

@@ -1,4 +1,4 @@
import {completeRelativeUrls} from '../src/readme-helper'
import {completeRelativeUrls, truncateToBytes} from '../src/readme-helper'
describe('complete relative urls tests', () => {
const GITHUB_SERVER_URL = process.env['GITHUB_SERVER_URL']
@@ -333,3 +333,12 @@ describe('complete relative urls tests', () => {
)
})
})
describe('truncate to bytes tests', () => {
test('unicode aware truncation to a number of bytes', async () => {
expect(truncateToBytes('test string to be truncated', 10)).toEqual(
'test strin'
)
expect(truncateToBytes('😀😁😂🤣😃😄😅', 10)).toEqual('😀😁')
})
})