File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { NestFactory } from '@nestjs/core' ;
2
+ import { OpenApiNestFactory } from './openapi-nest.factory' ;
3
+ import { OpenApiToolsModule } from './openapi-tools.module' ;
4
+ import { OpenApiService } from './openapi.service' ;
5
+
6
+ describe ( '' , ( ) => {
7
+ it ( 'should configure OpenApiToolsModule and create an instance of it' , async ( ) => {
8
+ // arrange
9
+ const app = {
10
+ get : jest . fn ( ) ,
11
+ } ;
12
+ const documentBuilder = {
13
+ build : jest . fn ( ) . mockReturnValue ( { info : { title : 'My API' } } ) ,
14
+ } ;
15
+ const swaggerOptions = { } ;
16
+
17
+ const openApiToolsModule = {
18
+ get : jest . fn ( ) . mockReturnValue ( {
19
+ configure : jest . fn ( ) ,
20
+ } ) ,
21
+ } ;
22
+
23
+ const createApplicationContextSpy = jest
24
+ . spyOn ( NestFactory , 'createApplicationContext' )
25
+ . mockResolvedValue ( openApiToolsModule as any ) ;
26
+
27
+ // act
28
+ await OpenApiNestFactory . configure (
29
+ app as any ,
30
+ documentBuilder as any ,
31
+ {
32
+ clientGeneratorOptions : {
33
+ type : 'typescript-axios' ,
34
+ outputFolderPath : '' ,
35
+ openApiFilePath : '' ,
36
+ enabled : true ,
37
+ } ,
38
+ } ,
39
+ swaggerOptions ,
40
+ ) ;
41
+
42
+ // assert
43
+ expect ( createApplicationContextSpy ) . toHaveBeenCalledWith (
44
+ OpenApiToolsModule ,
45
+ ) ;
46
+ expect ( openApiToolsModule . get ) . toHaveBeenCalledWith ( OpenApiService ) ;
47
+ } ) ;
48
+ } ) ;
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ export class OpenApiNestFactory {
59
59
}
60
60
61
61
toolsOptions . clientGeneratorOptions = new AxiosClientGeneratorOptions ( {
62
- ...toolsOptions . clientGeneratorOptions ,
62
+ ...( toolsOptions ? .clientGeneratorOptions || { } ) ,
63
63
outputFolderPath,
64
64
} ) ;
65
65
}
You can’t perform that action at this time.
0 commit comments