helpers.spec.ts 717 B

123456789101112131415161718192021
  1. // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. import { textToHtml } from '../helpers'
  3. describe('textToHtml', () => {
  4. it('adds links to URL-like text', () => {
  5. const input = 'Some Text\n\nhttp://example.com'
  6. const output =
  7. '<div>Some Text</div><div><br></div><div><a href="http://example.com">http://example.com</a></div>'
  8. expect(textToHtml(input)).toBe(output)
  9. })
  10. it('escapes HTML-like text to make sure it is presented as-is', () => {
  11. const input = '<p>&It;div&gt;hello world&lt;/div&gt;</p>'
  12. const output =
  13. '<div>&lt;p&gt;&amp;It;div&amp;gt;hello world&amp;lt;/div&amp;gt;&lt;/p&gt;</div>'
  14. expect(textToHtml(input)).toBe(output)
  15. })
  16. })