11// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22// SPDX-License-Identifier: Apache-2.0
33const path = require ( 'path' ) ;
4- const { writeComponentsDocumentation, writeTestUtilsDocumentation } = require ( '@cloudscape-design/documenter' ) ;
4+ const { writeComponentsDocumentation, documentTestUtils } = require ( '@cloudscape-design/documenter' ) ;
5+ const { writeFile } = require ( '../utils/files' ) ;
56const workspace = require ( '../utils/workspace' ) ;
67
78module . exports = function docs ( ) {
@@ -14,17 +15,27 @@ module.exports = function docs() {
1415 TagEditor : [ 'getTagsDiff' ] ,
1516 } ,
1617 } ) ;
17- writeTestUtilsDocumentation ( {
18- outDir : path . join ( workspace . apiDocsPath , 'test-utils-doc' ) ,
19- tsconfigPath : require . resolve ( '../../src/test-utils/tsconfig.json' ) ,
20- domUtils : {
21- root : 'src/test-utils/dom/index.ts' ,
22- extraExports : [ 'default' , 'ElementWrapper' ] ,
23- } ,
24- selectorsUtils : {
25- root : 'src/test-utils/selectors/index.ts' ,
26- extraExports : [ 'default' , 'ElementWrapper' ] ,
27- } ,
28- } ) ;
18+ testUtilDocs ( ) ;
2919 return Promise . resolve ( ) ;
3020} ;
21+
22+ function testUtilDocs ( ) {
23+ [ 'dom' , 'selectors' ] . forEach ( testUtilType => {
24+ const baseWrapperDefinitions = require ( `@cloudscape-design/test-utils-core/test-utils-doc/${ testUtilType } ` ) ;
25+ const componentWrapperDefinitions = documentTestUtils (
26+ {
27+ tsconfig : require . resolve ( '../../src/test-utils/tsconfig.json' ) ,
28+ } ,
29+ `**/{${ testUtilType } ,types}/**/*`
30+ ) ;
31+
32+ const definitions = [ ...baseWrapperDefinitions . classes , ...componentWrapperDefinitions ] ;
33+ const indexContent = `module.exports = {
34+ classes: ${ JSON . stringify ( definitions ) }
35+ }
36+ ` ;
37+
38+ const outPath = path . join ( workspace . apiDocsPath , 'test-utils-doc' , `${ testUtilType } .js` ) ;
39+ writeFile ( outPath , indexContent ) ;
40+ } ) ;
41+ }
0 commit comments