| 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; |
| 3 | |
| 4 | import { robotsTxt } from "./robots.ts"; |
| 5 | |
| 6 | test("everything may be crawled but a file's blame", () => { |
| 7 | const text = robotsTxt("https://g1t.example"); |
| 8 | assert.match(text, /^User-agent: \*\nAllow: \/\n/); |
| 9 | assert.match(text, /^Disallow: \/\*\?blame=$/m); |
| 10 | assert.match(text, /^Disallow: \/\*&blame=$/m); |
| 11 | assert.match(text, /^Disallow: \/\*\/\*\/blame\/$/m); |
| 12 | assert.match(text, /^Disallow: \/\*\/\*\/ref\/$/m); |
| 13 | assert.match(text, /^Sitemap: https:\/\/g1t\.example\/sitemap\.xml$/m); |
| 14 | assert.doesNotMatch(text, /docs\.g1t\.sh/, "a self-hosted g1t has no docs site"); |
| 15 | assert.ok(text.endsWith("\n")); |
| 16 | }); |
| 17 | |
| 18 | test("g1t.sh names its docs' map too", () => { |
| 19 | assert.match(robotsTxt("https://g1t.sh"), /^Sitemap: https:\/\/docs\.g1t\.sh\/sitemap-index\.xml$/m); |
| 20 | }); |