import { describe, expect, it } from 'vitest'
import { escapeHtml } from '../escape-html.js'

describe('escapeHtml', () => {
  it('escapes & < > "', () => {
    expect(escapeHtml('&<>"')).toBe('&amp;&lt;&gt;&quot;')
  })

  it('returns empty string for null/undefined', () => {
    expect(escapeHtml(null)).toBe('')
    expect(escapeHtml(undefined)).toBe('')
  })

  it('passes safe text through', () => {
    expect(escapeHtml('hello world')).toBe('hello world')
  })

  it('escapes mixed content', () => {
    expect(escapeHtml('<script>alert("xss")</script>')).toBe(
      '&lt;script&gt;alert(&quot;xss&quot;)&lt;/script&gt;',
    )
  })
})
