Skip to content

Commit 972acb2

Browse files
authored
fix(xml): add unit test for xml stylesheet (#100)
1 parent ce39928 commit 972acb2

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

xml/parse_test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,40 @@ test("`parse()` xml syntax xml stylesheet", () =>
256256
},
257257
))
258258

259+
test("`parse()` xml syntax xml stylesheet (sitemap.xml example)", () => {
260+
expect(
261+
parse(`
262+
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
263+
<?xml-stylesheet type="text/xsl" href="sitemap-style.xml" ?>
264+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
265+
<url>
266+
<loc>https://example.com</loc>
267+
<lastmod>2025-05-30T03:50:28-04:00</lastmod>
268+
</url>
269+
</urlset>`),
270+
).toEqual(
271+
{
272+
"#instructions": {
273+
"xml-stylesheet": {
274+
"@href": "sitemap-style.xml",
275+
"@type": "text/xsl",
276+
},
277+
},
278+
"@encoding": "utf-8",
279+
"@standalone": "yes",
280+
"@version": "1.0",
281+
urlset: {
282+
"@xmlns": "http://www.sitemaps.org/schemas/sitemap/0.9",
283+
"@xmlns:xhtml": "http://www.w3.org/1999/xhtml",
284+
url: {
285+
lastmod: "2025-05-30T03:50:28-04:00",
286+
loc: "https://example.com",
287+
},
288+
},
289+
},
290+
)
291+
})
292+
259293
test("`parse()` xml syntax doctype", () =>
260294
expect(
261295
parse(

0 commit comments

Comments
 (0)