@@ -5,9 +5,12 @@ import { test } from 'node:test';
55import { Validator } from 'jsonschema' ;
66import { SemVer } from 'semver' ;
77
8+ import { BASE_URL } from '../../../constants.mjs' ;
89import createGenerator from '../../../generators.mjs' ;
910import createMarkdownLoader from '../../../loaders/markdown.mjs' ;
1011import createMarkdownParser from '../../../parsers/markdown.mjs' ;
12+ import { SCHEMA_FILENAME } from '../constants.mjs' ;
13+ import jsonAll from '../index.mjs' ;
1114import { generateJsonSchema } from '../util/generateJsonSchema.mjs' ;
1215
1316const FIXTURES_DIR = join (
@@ -53,3 +56,65 @@ test('generator output complies with json schema', async () => {
5356
5457 assert . ok ( validator . validate ( result , schema ) . valid ) ;
5558} ) ;
59+
60+ test ( 'combines json correctly' , async ( ) => {
61+ const version = 'v1.2.3' ;
62+
63+ /**
64+ * @type {Array<import('../../json/generated.d.ts').NodeJsAPIDocumentationSchema> }
65+ */
66+ const jsonOutput = [
67+ {
68+ $schema : `https://nodejs.org/docs/${ version } /api/node-doc-schema.json` ,
69+ source : 'doc/api/some-module.md' ,
70+ type : 'module' ,
71+ '@name' : 'Some Module' ,
72+ '@module' : 'node:module' ,
73+ classes : [ ] ,
74+ } ,
75+ {
76+ $schema : `https://nodejs.org/docs/${ version } /api/node-doc-schema.json` ,
77+ source : 'doc/api/some-module.md' ,
78+ type : 'text' ,
79+ '@name' : 'Some Module' ,
80+ description : 'asdf' ,
81+ text : [
82+ {
83+ type : 'text' ,
84+ '@name' : 'asdf' ,
85+ description : 'bla bla bla' ,
86+ } ,
87+ ] ,
88+ } ,
89+ ] ;
90+
91+ const result = await jsonAll . generate ( jsonOutput , {
92+ version : new SemVer ( version ) ,
93+ } ) ;
94+
95+ assert . deepStrictEqual ( result , {
96+ $schema : `${ BASE_URL } docs/${ version } /api/${ SCHEMA_FILENAME } ` ,
97+ modules : [
98+ {
99+ type : 'module' ,
100+ '@name' : 'Some Module' ,
101+ '@module' : 'node:module' ,
102+ classes : [ ] ,
103+ } ,
104+ ] ,
105+ text : [
106+ {
107+ type : 'text' ,
108+ '@name' : 'Some Module' ,
109+ description : 'asdf' ,
110+ text : [
111+ {
112+ type : 'text' ,
113+ '@name' : 'asdf' ,
114+ description : 'bla bla bla' ,
115+ } ,
116+ ] ,
117+ } ,
118+ ] ,
119+ } ) ;
120+ } ) ;
0 commit comments