File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import * as fs from 'fs'
2+ import * as path from 'path'
3+ import { getAllRelationships } from '@/lib/relationships'
4+
5+ describe ( 'Relationship Graph Integrity' , ( ) => {
6+ it ( 'should have markdown files for all nodes referenced in relationships.mmd' , ( ) => {
7+ const { relationships } = getAllRelationships ( )
8+ const missingFiles : string [ ] = [ ]
9+ const documentsDir = path . join ( __dirname , '../../..' , 'documents' )
10+ const checkedSlugs = new Set < string > ( )
11+
12+ relationships . forEach ( rel => {
13+ [ rel . from , rel . to ] . forEach ( fullSlug => {
14+ if ( checkedSlugs . has ( fullSlug ) ) return
15+ checkedSlugs . add ( fullSlug )
16+
17+ const [ category , slug ] = fullSlug . split ( '/' )
18+ const markdownPath = path . join ( documentsDir , category , `${ slug } .md` )
19+
20+ if ( ! fs . existsSync ( markdownPath ) ) {
21+ missingFiles . push ( fullSlug )
22+ }
23+ } )
24+ } )
25+
26+ if ( missingFiles . length > 0 ) {
27+ throw new Error (
28+ `Relationships reference missing markdown files:\n${ missingFiles . map ( f => ` - ${ f } ` ) . join ( '\n' ) } `
29+ )
30+ }
31+ } )
32+ } )
You can’t perform that action at this time.
0 commit comments