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

* feat: truncate short description exceeding the byte limit

* fix tests
This commit is contained in:
Peter Evans
2023-04-07 09:16:46 +09:00
committed by GitHub
parent 3ba533f0ff
commit 4b1a4bb484
7 changed files with 80 additions and 47 deletions

View File

@@ -1,4 +1,4 @@
import {completeRelativeUrls, truncateToBytes} from '../src/readme-helper'
import {completeRelativeUrls} from '../src/readme-helper'
describe('complete relative urls tests', () => {
const GITHUB_SERVER_URL = process.env['GITHUB_SERVER_URL']
@@ -333,12 +333,3 @@ 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('😀😁')
})
})

View File

@@ -0,0 +1,10 @@
import {truncateToBytes} from '../src/utils'
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('😀😁')
})
})