Username UI Improvements
Co-authored-by: Fedor Indutny <238531+indutny@users.noreply.github.com>
This commit is contained in:
parent
ecafaa788a
commit
d811dd1ed4
9 changed files with 379 additions and 219 deletions
59
ts/test-node/util/splitText_test.ts
Normal file
59
ts/test-node/util/splitText_test.ts
Normal file
|
@ -0,0 +1,59 @@
|
|||
// Copyright 2024 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assert } from 'chai';
|
||||
|
||||
import type { SplitTextOptionsType } from '../../util/splitText';
|
||||
import { splitText } from '../../util/splitText';
|
||||
|
||||
describe('splitText', () => {
|
||||
describe('grapheme granularity', () => {
|
||||
const options: SplitTextOptionsType = {
|
||||
granularity: 'grapheme',
|
||||
shouldBreak: x => x.length > 6,
|
||||
};
|
||||
|
||||
it('splits text into one line', () => {
|
||||
assert.deepEqual(splitText('signal', options), ['signal']);
|
||||
});
|
||||
|
||||
it('splits text into two lines', () => {
|
||||
assert.deepEqual(splitText('signal.0123', options), ['signal', '.0123']);
|
||||
});
|
||||
|
||||
it('splits text into three lines', () => {
|
||||
assert.deepEqual(splitText('signal.01234567', options), [
|
||||
'signal',
|
||||
'.01234',
|
||||
'567',
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('word granularity', () => {
|
||||
const options: SplitTextOptionsType = {
|
||||
granularity: 'word',
|
||||
shouldBreak: x => x.length > 6,
|
||||
};
|
||||
|
||||
it('splits text into one line', () => {
|
||||
assert.deepEqual(splitText('signal', options), ['signal']);
|
||||
});
|
||||
|
||||
it('splits text into two lines', () => {
|
||||
assert.deepEqual(splitText('signal.0123', options), ['signal.', '0123']);
|
||||
});
|
||||
|
||||
it('splits text into three lines', () => {
|
||||
assert.deepEqual(splitText('aaaaaa b b ccccc', options), [
|
||||
'aaaaaa',
|
||||
'b b',
|
||||
'ccccc',
|
||||
]);
|
||||
});
|
||||
|
||||
it('trims lines', () => {
|
||||
assert.deepEqual(splitText('signa 0123', options), ['signa', '0123']);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue