mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 22:05:50 +00:00
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
import { escapeXml, escapeXmlAttr } from '../xml'
|
|
|
|
describe('escapeXml', () => {
|
|
test('escapes ampersand', () => {
|
|
expect(escapeXml('a & b')).toBe('a & b')
|
|
})
|
|
|
|
test('escapes less-than', () => {
|
|
expect(escapeXml('<div>')).toBe('<div>')
|
|
})
|
|
|
|
test('escapes greater-than', () => {
|
|
expect(escapeXml('a > b')).toBe('a > b')
|
|
})
|
|
|
|
test('escapes multiple special chars', () => {
|
|
expect(escapeXml('<a & b>')).toBe('<a & b>')
|
|
})
|
|
|
|
test('returns empty string unchanged', () => {
|
|
expect(escapeXml('')).toBe('')
|
|
})
|
|
|
|
test('returns normal text unchanged', () => {
|
|
expect(escapeXml('hello world')).toBe('hello world')
|
|
})
|
|
})
|
|
|
|
describe('escapeXmlAttr', () => {
|
|
test('escapes double quotes', () => {
|
|
expect(escapeXmlAttr('say "hello"')).toBe('say "hello"')
|
|
})
|
|
|
|
test('escapes single quotes', () => {
|
|
expect(escapeXmlAttr("it's")).toBe('it's')
|
|
})
|
|
|
|
test('escapes all special chars', () => {
|
|
expect(escapeXmlAttr('<a & "b">')).toBe('<a & "b">')
|
|
})
|
|
})
|