/* * Copyright (C) 2026 Fluxer Contributors * * This file is part of Fluxer. * * Fluxer is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Fluxer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Fluxer. If not, see . */ import {parseString} from '@fluxer/api/src/utils/StringUtils'; import {describe, expect, it} from 'vitest'; describe('parseString', () => { it('returns trimmed string within max length', () => { expect(parseString('Hello World', 50)).toBe('Hello World'); }); it('trims whitespace from the string', () => { expect(parseString(' Hello World ', 50)).toBe('Hello World'); }); it('truncates string exceeding max length', () => { const result = parseString('This is a very long string that needs truncation', 20); expect(result.length).toBeLessThanOrEqual(20); expect(result).toContain('...'); }); it('handles exact max length', () => { const result = parseString('12345', 5); expect(result).toBe('12345'); }); it('decodes HTML entities before processing', () => { expect(parseString('Hello & World', 50)).toBe('Hello & World'); expect(parseString('<script>', 50)).toBe('