mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Merge pull request #31038 from overleaf/jdt-mj-rm-chat-ide-redesign
Editor Redesign Cleanup: Chat GitOrigin-RevId: 98f969ee84a86761466de182787443b8c9bacefd
This commit is contained in:
committed by
Copybot
parent
551d7b3908
commit
6890f1bb3c
@@ -0,0 +1,51 @@
|
||||
import firstCharacter from '@/shared/utils/first-character'
|
||||
import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
|
||||
const CASES_ALL = [
|
||||
// Regular ASCII characters
|
||||
['Hello', 'H'],
|
||||
// Multi-byte characters (e.g. Chinese)
|
||||
['你好', '你'],
|
||||
// Multi-byte characters (e.g. emojis)
|
||||
['😀 Smile', '😀'],
|
||||
// Empty string
|
||||
['', ''],
|
||||
]
|
||||
|
||||
const CASES_SEGMENTER = [
|
||||
// Regional indicator symbols (e.g. flag emojis)
|
||||
['🇩🇰 Denmark', '🇩🇰'],
|
||||
// ZWJ sequences (e.g. family emoji)
|
||||
['👩👩👧👦 Family', '👩👩👧👦'],
|
||||
// Combining characters (e.g. accented characters)
|
||||
['e\u0301 Accented', 'e\u0301'],
|
||||
['é Accented', 'é'],
|
||||
]
|
||||
|
||||
describe('firstCharacter', function () {
|
||||
it('works for different types of strings', function () {
|
||||
for (const [input, expected] of CASES_ALL) {
|
||||
expect(firstCharacter(input)).to.equal(expected)
|
||||
}
|
||||
for (const [input, expected] of CASES_SEGMENTER) {
|
||||
expect(firstCharacter(input)).to.equal(expected)
|
||||
}
|
||||
})
|
||||
|
||||
describe('when Intl.Segmenter is unavailable', function () {
|
||||
before(function () {
|
||||
this.segmenterStub = sinon.stub(Intl, 'Segmenter').value(undefined)
|
||||
})
|
||||
|
||||
after(function () {
|
||||
this.segmenterStub.restore()
|
||||
})
|
||||
|
||||
it('falls back to the code point approach', function () {
|
||||
for (const [input, expected] of CASES_ALL) {
|
||||
expect(firstCharacter(input)).to.equal(expected)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user