@@ -77,6 +77,7 @@ function findAllKeys(obj, allKeys = new Set()) {
7777
7878const allExpectedKeys = new Set ( [
7979 'added' ,
80+ 'api' ,
8081 'changes' ,
8182 'classes' ,
8283 'classMethods' ,
@@ -96,6 +97,7 @@ const allExpectedKeys = new Set([
9697 'miscs' ,
9798 'modules' ,
9899 'name' ,
100+ 'optional' ,
99101 'napiVersion' ,
100102 'options' ,
101103 'params' ,
@@ -126,18 +128,18 @@ for await (const dirent of await fs.opendir(new URL('../../out/doc/api/', import
126128 console . log ( 'testing' , jsonPath , 'based on' , expectedSource ) ;
127129
128130 const fileContent = await fs . readFile ( jsonPath , 'utf8' ) ;
129- // A proxy to check if the file is human readable is to count if it contains
130- // at least 3 line return.
131- assert . strictEqual ( fileContent . split ( '\n' , 3 ) . length , 3 ) ;
132131
133132 const json = JSON . parse ( fileContent ) ;
134133
135134 assert . strictEqual ( json . type , 'module' ) ;
136135 assert . strictEqual ( json . source , expectedSource ) ;
136+
137137 if ( dirent . name !== 'index.md' ) {
138138 assert . ok ( json . introduced_in || Object . values ( json ) . at ( - 1 ) ?. [ 0 ] . introduced_in ) ;
139+ assert . partialDeepStrictEqual ( allExpectedKeys , findAllKeys ( json ) ) ;
139140 }
140- assert . deepStrictEqual ( Object . keys ( json ) , [ 'type' , 'source' , ...( {
141+
142+ assert . deepStrictEqual ( Object . keys ( json ) . sort ( ) , [ 'type' , 'api' , 'source' , ...( {
141143 'addons.md' : [ 'introduced_in' , 'miscs' ] ,
142144 'cli.md' : [ 'introduced_in' , 'miscs' ] ,
143145 'debugger.md' : [ 'introduced_in' , 'stability' , 'stabilityText' , 'miscs' ] ,
@@ -146,16 +148,14 @@ for await (const dirent of await fs.opendir(new URL('../../out/doc/api/', import
146148 'errors.md' : [ 'introduced_in' , 'classes' , 'miscs' ] ,
147149 'esm.md' : [ 'introduced_in' , 'meta' , 'stability' , 'stabilityText' , 'properties' , 'miscs' ] ,
148150 'globals.md' : [ 'introduced_in' , 'stability' , 'stabilityText' , 'classes' , 'methods' , 'miscs' ] ,
149- 'index.md' : [ ] ,
150151 'intl.md' : [ 'introduced_in' , 'miscs' ] ,
151152 'n-api.md' : [ 'introduced_in' , 'stability' , 'stabilityText' , 'miscs' ] ,
152153 'packages.md' : [ 'introduced_in' , 'meta' , 'miscs' ] ,
153154 'process.md' : [ 'globals' ] ,
155+ 'synopsis.md' : [ 'introduced_in' , 'miscs' ] ,
154156 'report.md' : [ 'introduced_in' , 'stability' , 'stabilityText' , 'meta' , 'miscs' ] ,
155- } [ dirent . name ] ?? [ 'modules' ] ) ] ) ;
156-
157- assert . partialDeepStrictEqual ( allExpectedKeys , findAllKeys ( json ) ) ;
157+ } [ dirent . name ] ?? [ 'modules' ] ) ] . sort ( ) ) ;
158158}
159159
160- assert . strictEqual ( numberOfDeprecatedSections , 39 ) ; // Increase this number every time a new API is deprecated.
160+ assert . strictEqual ( numberOfDeprecatedSections , 44 ) ; // Increase this number every time a new API is deprecated.
161161assert . strictEqual ( numberOfRemovedAPIs , 46 ) ; // Increase this number every time a section is marked as removed.
0 commit comments