11import assert from 'node:assert/strict' ;
22import { describe , it } from 'node:test' ;
33
4+ import { loadGenerator } from '@doc-kit/core/generators/loader.mjs' ;
5+ import { loadMarkdownPlugins } from '@doc-kit/core/utils/markdown/plugins.mjs' ;
46import { u } from 'unist-builder' ;
57
68import { buildPages } from '../buildPages.mjs' ;
79
10+ // Pages are serialised with the pipeline of `llms-txt-full`
11+ await loadMarkdownPlugins (
12+ await loadGenerator ( import . meta. resolve ( '../../index.mjs' ) )
13+ ) ;
14+
815const entry = ( path , text , extra = { } ) => ( {
916 path,
1017 content : u ( 'root' , [ u ( 'paragraph' , [ u ( 'text' , text ) ] ) ] ) ,
@@ -25,6 +32,30 @@ describe('buildPages', () => {
2532 ] ) ;
2633 } ) ;
2734
35+ it ( 'serialises type annotations back to Markdown' , ( ) => {
36+ const content = u ( 'root' , [
37+ u ( 'paragraph' , [
38+ u ( 'text' , 'Returns a ' ) ,
39+ u ( 'typeAnnotation' , { value : 'Promise<string>' } ) ,
40+ u ( 'text' , '.' ) ,
41+ ] ) ,
42+ ] ) ;
43+
44+ assert . deepEqual ( buildPages ( [ { path : '/a' , content } ] ) , [
45+ { path : '/a' , markdown : 'Returns a {Promise<string>}.\n' } ,
46+ ] ) ;
47+ } ) ;
48+
49+ it ( 'serialises the JSX of MDX pages' , ( ) => {
50+ const content = u ( 'root' , [
51+ u ( 'mdxJsxFlowElement' , { name : 'Foo' , attributes : [ ] } , [ ] ) ,
52+ ] ) ;
53+
54+ assert . deepEqual ( buildPages ( [ { path : '/a' , content, mdx : true } ] ) , [
55+ { path : '/a' , markdown : '<Foo />\n' } ,
56+ ] ) ;
57+ } ) ;
58+
2859 it ( 'leaves out pages generated by other generators' , ( ) => {
2960 assert . deepEqual (
3061 buildPages ( [ entry ( '/all' , 'All.' , { synthetic : true } ) ] ) ,
0 commit comments