dom.spec.ts 651 B

12345678910111213141516171819202122232425
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { domFrom } from '../dom.ts'
  3. describe('domFrom', () => {
  4. const input = '<div>test</div>'
  5. it('parses dom and returns exact string representation', () => {
  6. const dom = domFrom(input)
  7. expect(dom.innerHTML).toBe(input)
  8. })
  9. it('parses dom and returns matching structure', () => {
  10. const dom = domFrom(input)
  11. expect(dom).toBeInstanceOf(HTMLElement)
  12. expect(dom.childNodes.length).toBe(1)
  13. const firstNode = dom.childNodes[0]
  14. expect(firstNode.textContent).toBe('test')
  15. expect(firstNode.childNodes[0]).toBeInstanceOf(Text)
  16. })
  17. })