Skip to content

Commit a3674e3

Browse files
committed
add test check for path in xml output
1 parent 1299e9c commit a3674e3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

packages/router-sitemap/tests/generateSitemap.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,4 +544,28 @@ describe('generateSitemap', () => {
544544
}),
545545
).rejects.toThrow('Invalid entry /array-return: entry must be an object')
546546
})
547+
548+
test('path property should not appear in XML output', async () => {
549+
const result = await generateSitemap({
550+
siteUrl: 'https://example.com',
551+
routes: [
552+
[
553+
'/posts/$postId' as any,
554+
() => [
555+
{ path: '/posts/1', priority: 0.8 },
556+
{ path: '/posts/2', priority: 0.8 },
557+
],
558+
],
559+
],
560+
})
561+
562+
// Should contain the correct loc elements
563+
expect(result).toContain('<loc>https://example.com/posts/1</loc>')
564+
expect(result).toContain('<loc>https://example.com/posts/2</loc>')
565+
566+
// Should NOT contain path elements in XML
567+
expect(result).not.toContain('<path>/posts/1</path>')
568+
expect(result).not.toContain('<path>/posts/2</path>')
569+
expect(result).not.toContain('<path>')
570+
})
547571
})

0 commit comments

Comments
 (0)