@@ -6,10 +6,7 @@ import path from 'node:path';
6
6
7
7
function cli ( args : string [ ] , cwd : string ) : Promise < { error : ExecException | null ; stdout : string ; stderr : string } > {
8
8
const pwd = process . env ?. PWD || '.' ;
9
- const cmd = `${ require . resolve ( 'ts-node/dist/bin' ) } -T -P ${ path . resolve ( pwd , 'tsconfig.json' ) } ${ path . resolve (
10
- pwd ,
11
- 'src/bin/cli.ts'
12
- ) } ${ args . join ( ' ' ) } `;
9
+ const cmd = `yarn cli ${ args . join ( ' ' ) } ` ;
13
10
return new Promise ( ( resolve ) => {
14
11
exec ( cmd , { cwd } , ( error , stdout , stderr ) => {
15
12
resolve ( {
@@ -21,7 +18,7 @@ function cli(args: string[], cwd: string): Promise<{ error: ExecException | null
21
18
} ) ;
22
19
}
23
20
24
- const tmpDir = path . resolve ( __dirname , 'tmp' ) ;
21
+ const tmpDir = path . join ( __dirname , 'tmp' ) ;
25
22
26
23
beforeAll ( async ( ) => {
27
24
if ( ! fs . existsSync ( tmpDir ) ) fs . mkdirSync ( tmpDir , { recursive : true } ) ;
@@ -32,8 +29,8 @@ afterEach(() => {
32
29
} ) ;
33
30
34
31
describe ( 'CLI options testing' , ( ) => {
35
- test . todo ( 'generation with `config.example.js`' , async ( ) => {
36
- const out = await cli ( [ `./ config.example.js` ] , __dirname ) ;
32
+ test ( 'generation with `config.example.js`' , async ( ) => {
33
+ const out = await cli ( [ './test/ config.example.js' ] , __dirname ) ;
37
34
38
35
expect ( out ) . toEqual ( {
39
36
stdout : `Generating ./tmp/example.ts
46
43
expect ( fs . readFileSync ( path . resolve ( tmpDir , 'example.ts' ) , 'utf-8' ) ) . toMatchSnapshot ( ) ;
47
44
} , 25_000 ) ;
48
45
49
- test . todo ( 'paths are relative to configfile , not to cwd' , async ( ) => {
50
- const out = await cli ( [ `.. /test/config.example.js` ] , path . resolve ( __dirname , '../src' ) ) ;
46
+ test ( 'paths are relative to config file , not to cwd' , async ( ) => {
47
+ const out = await cli ( [ `./test/config.example.js` ] , path . resolve ( __dirname , '../src' ) ) ;
51
48
52
49
expect ( out ) . toEqual ( {
53
50
stdout : `Generating ./tmp/example.ts
60
57
expect ( fs . readFileSync ( path . resolve ( tmpDir , 'example.ts' ) , 'utf-8' ) ) . toMatchSnapshot ( ) ;
61
58
} , 25_000 ) ;
62
59
63
- test . todo ( 'ts, js and json all work the same' , async ( ) => {
64
- await cli ( [ `./config.example.js` ] , __dirname ) ;
60
+ test ( 'ts, js and json all work the same' , async ( ) => {
61
+ await cli ( [ `./test/ config.example.js` ] , __dirname ) ;
65
62
const fromJs = fs . readFileSync ( path . resolve ( tmpDir , 'example.ts' ) , 'utf-8' ) ;
66
- await cli ( [ `./config.example.ts` ] , __dirname ) ;
63
+ await cli ( [ `./test/ config.example.ts` ] , __dirname ) ;
67
64
const fromTs = fs . readFileSync ( path . resolve ( tmpDir , 'example.ts' ) , 'utf-8' ) ;
68
- await cli ( [ `./config.example.json` ] , __dirname ) ;
65
+ await cli ( [ `./test/ config.example.json` ] , __dirname ) ;
69
66
const fromJson = fs . readFileSync ( path . resolve ( tmpDir , 'example.ts' ) , 'utf-8' ) ;
70
67
71
68
expect ( fromTs ) . toEqual ( fromJs ) ;
72
69
expect ( fromJson ) . toEqual ( fromJs ) ;
73
70
} , 120_000 ) ;
74
71
75
- test . todo ( ' missing parameters doesnt fail' , async ( ) => {
76
- const out = await cli ( [ `./config.invalid-example.json` ] , __dirname ) ;
72
+ test ( " missing parameters doesn't fail" , async ( ) => {
73
+ const out = await cli ( [ `./test/ config.invalid-example.json` ] , __dirname ) ;
77
74
expect ( out . stderr ) . toContain ( "Error: path parameter petId does not seem to be defined in '/pet/{petId}'!" ) ;
78
75
} , 25_000 ) ;
79
76
} ) ;
0 commit comments