Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp
742 B
Raw Blame
// 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('&πŸ‡ΈπŸ‡ͺ');
	});
});