import { describe, it, expect } from 'vitest' import { linkifyAndClean } from '@/utils/inputs' describe('linkifyAndClean (clean input remains unchanged)', () => { const testInputs = [ 'just a text\nfor "test"', 'link: example', 'link: example', ] testInputs.map((testInput) => { it(`it returns unmodified input: '${testInput}'`, () => { expect(linkifyAndClean(testInput)).toBe(testInput) }) }) }) describe('linkifyAndClean (URL is linkified)', () => { it('it returns URL as link with target blank', () => { expect(linkifyAndClean('link: http://www.example.com')).toBe( 'link: http://www.example.com' ) }) }) describe('linkifyAndClean (input sanitization)', () => { const testsParams = [ { description: 'it escapes "script" tags', inputString: "", expectedString: "<script>alert('evil!')</script>", }, { description: 'it escapes nested tags', inputString: '
test
', expectedString: '<p><b>test</b></p>', }, { description: 'it escapes single tag', inputString: 'test', expectedString: '<p>test', }, { description: 'it removes css classe', inputString: '