@@ -2,7 +2,7 @@ import fs from "fs";
22import path from "path" ;
33import ts from "typescript" ;
44import log from "loglevel" ;
5- import { execSync } from "child_process" ;
5+ import { execSync , execFileSync } from "child_process" ;
66import { generateInterfaces } from "../interfaceGenerationHelper" ;
77import {
88 getAllKnownGlobals ,
@@ -114,6 +114,66 @@ process.stdout.write(argv.jsdoc);`,
114114 } ) ;
115115} ) ;
116116
117+ describe ( "CLI end-to-end (issue #542)" , ( ) => {
118+ const cliEntryPoint = path . resolve (
119+ __dirname ,
120+ "../../dist/generateTSInterfaces.js" ,
121+ ) ;
122+ const testCaseDir = path . resolve (
123+ __dirname ,
124+ "testcases/tsconfig-path-relative" ,
125+ ) ;
126+ const genFile = path . join ( testCaseDir , "MyControl.gen.d.ts" ) ;
127+
128+ beforeAll ( ( ) => {
129+ if ( ! fs . existsSync ( cliEntryPoint ) ) {
130+ execSync ( "npx tsc" , { cwd : path . resolve ( __dirname , "../.." ) } ) ;
131+ }
132+ } ) ;
133+
134+ afterEach ( ( ) => {
135+ // Restore original gen files
136+ execSync ( "git checkout -- ." , { cwd : testCaseDir } ) ;
137+ } ) ;
138+
139+ test ( "--jsdoc minimal produces output without boilerplate JSDoc" , ( ) => {
140+ fs . unlinkSync ( genFile ) ;
141+ execFileSync ( "node" , [ cliEntryPoint , "--jsdoc" , "minimal" ] , {
142+ cwd : testCaseDir ,
143+ } ) ;
144+ const output = fs . readFileSync ( genFile , "utf-8" ) ;
145+
146+ expect ( output ) . toContain ( "getMyJSEnumVal(): MyJSEnum;" ) ;
147+ expect ( output ) . not . toContain ( "@returns" ) ;
148+ expect ( output ) . not . toContain ( "@param" ) ;
149+ expect ( output ) . not . toContain ( "Gets current value of property" ) ;
150+ } ) ;
151+
152+ test ( "--jsdoc none produces output without any method-level JSDoc" , ( ) => {
153+ fs . unlinkSync ( genFile ) ;
154+ execFileSync ( "node" , [ cliEntryPoint , "--jsdoc" , "none" ] , {
155+ cwd : testCaseDir ,
156+ } ) ;
157+ const output = fs . readFileSync ( genFile , "utf-8" ) ;
158+
159+ expect ( output ) . toContain ( "getMyJSEnumVal(): MyJSEnum;" ) ;
160+ expect ( output ) . not . toContain ( "@returns" ) ;
161+ expect ( output ) . not . toContain ( "@param" ) ;
162+ } ) ;
163+
164+ test ( "--jsdoc verbose produces output with full boilerplate JSDoc" , ( ) => {
165+ fs . unlinkSync ( genFile ) ;
166+ execFileSync ( "node" , [ cliEntryPoint , "--jsdoc" , "verbose" ] , {
167+ cwd : testCaseDir ,
168+ } ) ;
169+ const output = fs . readFileSync ( genFile , "utf-8" ) ;
170+
171+ expect ( output ) . toContain ( "@returns" ) ;
172+ expect ( output ) . toContain ( "@param" ) ;
173+ expect ( output ) . toContain ( 'Gets current value of property "myJSEnumVal"' ) ;
174+ } ) ;
175+ } ) ;
176+
117177describe ( "JSDoc preference modes" , ( ) => {
118178 beforeAll ( ( ) => {
119179 jest . spyOn ( log , "warn" ) . mockImplementation ( ( ) => { } ) ;
0 commit comments