A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
// SPDX-License-Identifier: AGPL-3.0-or-later
import {parseString} from '@app/api/utils/StringUtils';
import {describe, expect, it} from 'vitest';
describe('parseString', () => {
it('keeps family emoji intact at the webhook title truncation boundary', () => {
expect(parseString('abπ¨βπ©βπ§cdefghij', 6)).toBe('abπ¨βπ©βπ§...');
expect(parseString(`${'π¨βπ©βπ§βπ¦'.repeat(5)}abcdef`, 6)).toBe(`${'π¨βπ©βπ§βπ¦'.repeat(3)}...`);
});
it('keeps combining marks and flags together and decodes entities before truncating', () => {
expect(parseString('e\u0301πΈπͺ&more text', 6)).toBe('e\u0301πΈπͺ&...');
expect(parseString(' &πΈπͺ ', 2)).toBe('&πΈπͺ');
});
});