Refactor to TypeScript ES modules and add metadata sidebar
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { escapeHtml } from '../src/utils/text'
|
||||
|
||||
describe('escapeHtml', () => {
|
||||
it('escapes the five HTML-significant characters', () => {
|
||||
expect(escapeHtml('<script>alert("xss")</script>')).toBe(
|
||||
'<script>alert("xss")</script>'
|
||||
)
|
||||
})
|
||||
|
||||
it('escapes ampersand first so other escapes are not re-escaped', () => {
|
||||
expect(escapeHtml('&')).toBe('&amp;')
|
||||
})
|
||||
|
||||
it('escapes single quotes', () => {
|
||||
expect(escapeHtml("it's")).toBe('it's')
|
||||
})
|
||||
|
||||
it('returns empty string unchanged', () => {
|
||||
expect(escapeHtml('')).toBe('')
|
||||
})
|
||||
|
||||
it('passes through strings with no special characters', () => {
|
||||
expect(escapeHtml('plain text 123')).toBe('plain text 123')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user