|
1 | | -import { describe, expect, it } from 'vitest'; |
| 1 | +import { describe, expect, it, beforeEach } from 'vitest'; |
2 | 2 | import { getRobotsTxt } from '../../src/pages/robots.txt'; |
3 | 3 |
|
4 | 4 | describe('Robots.txt', () => { |
| 5 | + let mockSite: URL; |
| 6 | + let mockSitemap: URL; |
| 7 | + let robotsTxt: string; |
| 8 | + |
| 9 | + beforeEach(() => { |
| 10 | + mockSite = new URL('https://whiskey.fm'); |
| 11 | + mockSitemap = new URL('sitemap-index.xml', mockSite); |
| 12 | + robotsTxt = getRobotsTxt(mockSitemap, mockSite); |
| 13 | + }); |
| 14 | + |
5 | 15 | describe('Generated content', () => { |
6 | 16 | it('should contain welcoming comment for AI agents', () => { |
7 | | - const mockSite = new URL('https://whiskey.fm'); |
8 | | - const mockSitemap = new URL('sitemap-index.xml', mockSite); |
9 | | - |
10 | | - const robotsTxt = getRobotsTxt(mockSitemap, mockSite); |
11 | | - |
12 | 17 | expect(robotsTxt).toContain('Welcome AI agents and crawlers'); |
13 | 18 | expect(robotsTxt).toContain('User-agent: *'); |
14 | 19 | expect(robotsTxt).toContain('Allow: /'); |
15 | 20 | }); |
16 | 21 |
|
17 | 22 | it('should include sitemap reference', () => { |
18 | | - const mockSite = new URL('https://whiskey.fm'); |
19 | | - const mockSitemap = new URL('sitemap-index.xml', mockSite); |
20 | | - |
21 | | - const robotsTxt = getRobotsTxt(mockSitemap, mockSite); |
22 | | - |
23 | 23 | expect(robotsTxt).toContain('Sitemap: https://whiskey.fm/sitemap-index.xml'); |
24 | 24 | }); |
25 | 25 |
|
26 | 26 | it('should reference LLM-specific resources', () => { |
27 | | - const mockSite = new URL('https://whiskey.fm'); |
28 | | - const mockSitemap = new URL('sitemap-index.xml', mockSite); |
29 | | - |
30 | | - const robotsTxt = getRobotsTxt(mockSitemap, mockSite); |
31 | | - |
32 | 27 | expect(robotsTxt).toContain('/llms.txt'); |
33 | 28 | expect(robotsTxt).toContain('/for-llms'); |
34 | 29 | expect(robotsTxt).toContain('/episodes-index.html.md'); |
35 | 30 | }); |
36 | 31 |
|
37 | 32 | it('should describe available content types', () => { |
38 | | - const mockSite = new URL('https://whiskey.fm'); |
39 | | - const mockSitemap = new URL('sitemap-index.xml', mockSite); |
40 | | - |
41 | | - const robotsTxt = getRobotsTxt(mockSitemap, mockSite); |
42 | | - |
43 | 33 | expect(robotsTxt).toContain('Podcast metadata'); |
44 | 34 | expect(robotsTxt).toContain('Episode information'); |
45 | 35 | expect(robotsTxt).toContain('Full transcripts'); |
46 | 36 | expect(robotsTxt).toContain('Guest information'); |
47 | 37 | }); |
48 | 38 |
|
49 | 39 | it('should include encouraging closing message', () => { |
50 | | - const mockSite = new URL('https://whiskey.fm'); |
51 | | - const mockSitemap = new URL('sitemap-index.xml', mockSite); |
52 | | - |
53 | | - const robotsTxt = getRobotsTxt(mockSitemap, mockSite); |
54 | | - |
55 | 40 | expect(robotsTxt).toContain('Feel free to crawl, index, and use this content'); |
56 | 41 | expect(robotsTxt).toContain('help users discover'); |
57 | 42 | }); |
|
0 commit comments