11import { describe , expect , it } from 'vitest' ;
2+ import { getRobotsTxt } from '../../src/pages/robots.txt' ;
23
34describe ( 'Robots.txt' , ( ) => {
45 describe ( 'Generated content' , ( ) => {
56 it ( 'should contain welcoming comment for AI agents' , ( ) => {
67 const mockSite = new URL ( 'https://whiskey.fm' ) ;
78 const mockSitemap = new URL ( 'sitemap-index.xml' , mockSite ) ;
89
9- // Simulate the getRobotsTxt function behavior
10- const robotsTxt = `
11- # Welcome AI agents and crawlers!
12- # This is a podcast website built with Starpod - all content is freely accessible.
13-
14- User-agent: *
15- Allow: /
16-
17- # Sitemap for all pages
18- Sitemap: ${ mockSitemap . href }
19-
20- # Special resources for AI/LLM agents:
21- # - ${ mockSite . origin } /llms.txt - Structured overview following the llms.txt spec
22- # - ${ mockSite . origin } /for-llms - Human-readable guide for AI assistants
23- # - ${ mockSite . origin } /episodes-index.html.md - Complete episode listing in markdown
24- # - ${ mockSite . origin } /[episode-slug].html.md - Individual episodes with transcripts
25- #
26- # All content includes:
27- # - Podcast metadata (hosts, description, platforms)
28- # - Episode information (titles, descriptions, publish dates)
29- # - Full transcripts (when available)
30- # - Guest information
31- #
32- # Feel free to crawl, index, and use this content to help users discover
33- # and learn about our podcast!
34- ` ;
10+ const robotsTxt = getRobotsTxt ( mockSitemap , mockSite ) ;
3511
3612 expect ( robotsTxt ) . toContain ( 'Welcome AI agents and crawlers' ) ;
3713 expect ( robotsTxt ) . toContain ( 'User-agent: *' ) ;
@@ -42,34 +18,27 @@ Sitemap: ${mockSitemap.href}
4218 const mockSite = new URL ( 'https://whiskey.fm' ) ;
4319 const mockSitemap = new URL ( 'sitemap-index.xml' , mockSite ) ;
4420
45- const robotsTxt = `Sitemap: ${ mockSitemap . href } ` ;
21+ const robotsTxt = getRobotsTxt ( mockSitemap , mockSite ) ;
4622
4723 expect ( robotsTxt ) . toContain ( 'Sitemap: https://whiskey.fm/sitemap-index.xml' ) ;
4824 } ) ;
4925
5026 it ( 'should reference LLM-specific resources' , ( ) => {
5127 const mockSite = new URL ( 'https://whiskey.fm' ) ;
28+ const mockSitemap = new URL ( 'sitemap-index.xml' , mockSite ) ;
5229
53- const robotsTxt = `
54- # Special resources for AI/LLM agents:
55- # - ${ mockSite . origin } /llms.txt - Structured overview following the llms.txt spec
56- # - ${ mockSite . origin } /for-llms - Human-readable guide for AI assistants
57- # - ${ mockSite . origin } /episodes-index.html.md - Complete episode listing in markdown
58- ` ;
30+ const robotsTxt = getRobotsTxt ( mockSitemap , mockSite ) ;
5931
6032 expect ( robotsTxt ) . toContain ( '/llms.txt' ) ;
6133 expect ( robotsTxt ) . toContain ( '/for-llms' ) ;
6234 expect ( robotsTxt ) . toContain ( '/episodes-index.html.md' ) ;
6335 } ) ;
6436
6537 it ( 'should describe available content types' , ( ) => {
66- const robotsTxt = `
67- # All content includes:
68- # - Podcast metadata (hosts, description, platforms)
69- # - Episode information (titles, descriptions, publish dates)
70- # - Full transcripts (when available)
71- # - Guest information
72- ` ;
38+ const mockSite = new URL ( 'https://whiskey.fm' ) ;
39+ const mockSitemap = new URL ( 'sitemap-index.xml' , mockSite ) ;
40+
41+ const robotsTxt = getRobotsTxt ( mockSitemap , mockSite ) ;
7342
7443 expect ( robotsTxt ) . toContain ( 'Podcast metadata' ) ;
7544 expect ( robotsTxt ) . toContain ( 'Episode information' ) ;
@@ -78,10 +47,10 @@ Sitemap: ${mockSitemap.href}
7847 } ) ;
7948
8049 it ( 'should include encouraging closing message' , ( ) => {
81- const robotsTxt = `
82- # Feel free to crawl, index, and use this content to help users discover
83- # and learn about our podcast!
84- ` ;
50+ const mockSite = new URL ( 'https://whiskey.fm' ) ;
51+ const mockSitemap = new URL ( 'sitemap-index.xml' , mockSite ) ;
52+
53+ const robotsTxt = getRobotsTxt ( mockSitemap , mockSite ) ;
8554
8655 expect ( robotsTxt ) . toContain ( 'Feel free to crawl, index, and use this content' ) ;
8756 expect ( robotsTxt ) . toContain ( 'help users discover' ) ;
0 commit comments