Skip to content

Commit 7bc40bd

Browse files
committed
Added a test to catch map integrity issues early
1 parent 8bd7a58 commit 7bc40bd

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import * as fs from 'fs'
2+
import * as path from 'path'
3+
import mapIndex from '@/public/maps/map-index.json'
4+
5+
describe('Interactive Map Integrity', () => {
6+
it('should have markdown files for all entries in map-index.json', () => {
7+
const missingFiles: string[] = []
8+
const documentsDir = path.join(__dirname, '../../..', 'documents')
9+
10+
Object.entries(mapIndex).forEach(([number, info]) => {
11+
const { category, slug } = info
12+
const markdownPath = path.join(documentsDir, category, `${slug}.md`)
13+
14+
if (!fs.existsSync(markdownPath)) {
15+
missingFiles.push(`${category}/${slug} (map node #${number})`)
16+
}
17+
})
18+
19+
if (missingFiles.length > 0) {
20+
throw new Error(
21+
`Map nodes reference missing markdown files:\n${missingFiles.map(f => ` - ${f}`).join('\n')}`
22+
)
23+
}
24+
})
25+
})

0 commit comments

Comments
 (0)