Initial Version of sitemap.xml spec

This commit is contained in:
2026-03-06 23:34:00 -06:00
parent fec5bfa5c7
commit e9495f65b5
41 changed files with 10665 additions and 35 deletions

View File

@@ -0,0 +1,63 @@
/**
* Unit Tests for XML Utilities
* Tests XML escaping functionality
*/
import { test, describe } from 'node:test';
import assert from 'node:assert';
import { escapeXml } from '../../src/xml-utils.js';
describe('Unit: XML Escaping', () => {
test('T045: Should escape ampersand (&)', () => {
const input = 'Rock & Roll';
const expected = 'Rock & Roll';
assert.strictEqual(escapeXml(input), expected);
});
test('T045: Should escape less than (<)', () => {
const input = '5 < 10';
const expected = '5 &lt; 10';
assert.strictEqual(escapeXml(input), expected);
});
test('T045: Should escape greater than (>)', () => {
const input = '10 > 5';
const expected = '10 &gt; 5';
assert.strictEqual(escapeXml(input), expected);
});
test('T045: Should escape double quote (")', () => {
const input = 'Say "Hello"';
const expected = 'Say &quot;Hello&quot;';
assert.strictEqual(escapeXml(input), expected);
});
test('T045: Should escape single quote (\')', () => {
const input = "It's working";
const expected = 'It&apos;s working';
assert.strictEqual(escapeXml(input), expected);
});
test('T045: Should escape multiple special characters', () => {
const input = '<tag attr="value">Content & stuff</tag>';
const expected = '&lt;tag attr=&quot;value&quot;&gt;Content &amp; stuff&lt;/tag&gt;';
assert.strictEqual(escapeXml(input), expected);
});
test('T045: Should handle empty string', () => {
assert.strictEqual(escapeXml(''), '');
});
test('T045: Should handle non-string input', () => {
assert.strictEqual(escapeXml(null), '');
assert.strictEqual(escapeXml(undefined), '');
assert.strictEqual(escapeXml(123), '');
});
test('T045: Should not modify safe strings', () => {
const input = 'This is a safe string 123';
assert.strictEqual(escapeXml(input), input);
});
});