@@ -430,3 +430,70 @@ test("sync supports backward compatibility: toc as format string", async () => {
430430 // Should NOT have frontmatter
431431 assert . ok ( ! sourceToc . includes ( "---" ) ) ;
432432} ) ;
433+
434+ test ( "sync supports backward compatibility: toc=false disables TOC generation" , async ( ) => {
435+ const tmpRoot = path . join (
436+ tmpdir ( ) ,
437+ `docs-cache-toc-false-compat-${ Date . now ( ) . toString ( 36 ) } ` ,
438+ ) ;
439+ await mkdir ( tmpRoot , { recursive : true } ) ;
440+ const cacheDir = path . join ( tmpRoot , ".docs" ) ;
441+ const repoDir = path . join ( tmpRoot , "repo" ) ;
442+ const configPath = path . join ( tmpRoot , "docs.config.json" ) ;
443+
444+ await mkdir ( repoDir , { recursive : true } ) ;
445+ await writeFile ( path . join ( repoDir , "README.md" ) , "hello" , "utf8" ) ;
446+
447+ const config = {
448+ $schema :
449+ "https://raw.githubusercontent.com/fbosch/docs-cache/main/docs.config.schema.json" ,
450+ sources : [
451+ {
452+ id : "local" ,
453+ repo : "https://example.com/repo.git" ,
454+ toc : false ,
455+ } ,
456+ ] ,
457+ } ;
458+ await writeFile ( configPath , `${ JSON . stringify ( config , null , 2 ) } \n` , "utf8" ) ;
459+
460+ await runSync (
461+ {
462+ configPath,
463+ cacheDirOverride : cacheDir ,
464+ json : false ,
465+ lockOnly : false ,
466+ offline : false ,
467+ failOnMiss : false ,
468+ } ,
469+ {
470+ resolveRemoteCommit : async ( ) => ( {
471+ repo : "https://example.com/repo.git" ,
472+ ref : "HEAD" ,
473+ resolvedCommit : "abc123" ,
474+ } ) ,
475+ fetchSource : async ( ) => ( {
476+ repoDir,
477+ cleanup : async ( ) => undefined ,
478+ } ) ,
479+ materializeSource : async ( { cacheDir : cacheRoot , sourceId } ) => {
480+ const outDir = path . join ( cacheRoot , sourceId ) ;
481+ await mkdir ( outDir , { recursive : true } ) ;
482+ await writeFile (
483+ path . join ( outDir , ".manifest.jsonl" ) ,
484+ `${ JSON . stringify ( { path : "README.md" , size : 5 } ) } \n` ,
485+ ) ;
486+ await writeFile ( path . join ( outDir , "README.md" ) , "hello" , "utf8" ) ;
487+ return { bytes : 5 , fileCount : 1 } ;
488+ } ,
489+ } ,
490+ ) ;
491+
492+ // Verify TOC.md was NOT created
493+ const sourceTocPath = path . join ( cacheDir , "local" , "TOC.md" ) ;
494+ await assert . rejects (
495+ ( ) => readFile ( sourceTocPath , "utf8" ) ,
496+ / E N O E N T / ,
497+ "TOC.md should not exist when toc is disabled" ,
498+ ) ;
499+ } ) ;
0 commit comments