|
4 | 4 | discoverAgentFiles, |
5 | 5 | fetchAgentFiles, |
6 | 6 | generateLlmsTxt, |
| 7 | + generateRootLlmsTxt, |
7 | 8 | } from '../../../../server/utils/llms-txt' |
8 | 9 |
|
9 | 10 | describe('discoverAgentFiles', () => { |
@@ -299,3 +300,36 @@ describe('generateLlmsTxt', () => { |
299 | 300 | expect(output).toContain('- npm: https://www.npmjs.com/package/@nuxt/kit/v/1.0.0') |
300 | 301 | }) |
301 | 302 | }) |
| 303 | + |
| 304 | +describe('generateRootLlmsTxt', () => { |
| 305 | + it('includes all route patterns', () => { |
| 306 | + const output = generateRootLlmsTxt('https://npmx.dev') |
| 307 | + |
| 308 | + expect(output).toContain('# npmx.dev') |
| 309 | + expect(output).toContain('https://npmx.dev/package/<name>/llms.txt') |
| 310 | + expect(output).toContain('https://npmx.dev/package/<name>/v/<version>/llms.txt') |
| 311 | + expect(output).toContain('https://npmx.dev/package/@<org>/<name>/llms.txt') |
| 312 | + expect(output).toContain('https://npmx.dev/package/@<org>/<name>/v/<version>/llms.txt') |
| 313 | + expect(output).toContain('https://npmx.dev/package/<name>/llms_full.txt') |
| 314 | + expect(output).toContain('https://npmx.dev/package/@<org>/llms.txt') |
| 315 | + }) |
| 316 | + |
| 317 | + it('includes example links', () => { |
| 318 | + const output = generateRootLlmsTxt('https://npmx.dev') |
| 319 | + |
| 320 | + expect(output).toContain('[nuxt llms.txt](https://npmx.dev/package/nuxt/llms.txt)') |
| 321 | + expect(output).toContain('[@nuxt org packages](https://npmx.dev/package/@nuxt/llms.txt)') |
| 322 | + }) |
| 323 | + |
| 324 | + it('uses provided base URL', () => { |
| 325 | + const output = generateRootLlmsTxt('http://localhost:3000') |
| 326 | + |
| 327 | + expect(output).toContain('http://localhost:3000/package/<name>/llms.txt') |
| 328 | + expect(output).not.toContain('https://npmx.dev') |
| 329 | + }) |
| 330 | + |
| 331 | + it('ends with newline', () => { |
| 332 | + const output = generateRootLlmsTxt('https://npmx.dev') |
| 333 | + expect(output.endsWith('\n')).toBe(true) |
| 334 | + }) |
| 335 | +}) |
0 commit comments