@@ -83,7 +83,7 @@ describe('convertV2WithTypes', function() {
83
83
expect ( err ) . to . be . null ;
84
84
expect ( conversionResult . result ) . to . equal ( true ) ;
85
85
expect ( conversionResult . extractedTypes ) . to . not . be . undefined ;
86
- expect ( conversionResult . extractedTypes . length ) . to . not . equal ( 0 ) ;
86
+ expect ( Object . keys ( conversionResult . extractedTypes ) . length ) . to . not . equal ( 0 ) ;
87
87
}
88
88
) ;
89
89
} ) ;
@@ -97,24 +97,25 @@ describe('convertV2WithTypes', function() {
97
97
{ type : 'file' , data : testSpec1 } , { requestNameSource : 'url' } , ( err , conversionResult ) => {
98
98
99
99
expect ( err ) . to . be . null ;
100
- expect ( conversionResult . extractedTypes ) . to . be . an ( 'array' ) . that . is . not . empty ;
101
- const element = conversionResult . extractedTypes [ 0 ] ;
102
-
103
- expect ( element ) . to . be . an ( 'object' ) . that . includes . keys ( 'request' ) ;
104
- expect ( element ) . to . be . an ( 'object' ) . that . includes . keys ( 'response' ) ;
105
- const { response } = element ;
106
- expect ( response ) . to . be . an ( 'object' ) . that . is . not . empty ;
107
- const [ key , value ] = Object . entries ( response ) [ 1 ] ;
108
- expect ( key ) . to . be . a ( 'string' ) ;
109
- const schema = JSON . parse ( value . body ) ,
110
- transformedSchema = transformSchema ( schema ) ,
111
- validate = ajv . compile ( transformedSchema ) ,
112
- valid = validate ( example ) ;
113
-
114
- expect ( value ) . to . have . property ( 'body' ) . that . is . a ( 'string' ) ;
115
-
116
-
117
- expect ( valid , `Validation failed for key: ${ key } with errors: ${ JSON . stringify ( validate . errors ) } ` ) . to . be . true ;
100
+ expect ( conversionResult . extractedTypes ) . to . be . an ( 'object' ) . that . is . not . empty ;
101
+ for ( const [ path , element ] of Object . entries ( conversionResult . extractedTypes ) ) {
102
+ expect ( element ) . to . be . an ( 'object' ) . that . includes . keys ( 'request' ) ;
103
+ expect ( element ) . to . be . an ( 'object' ) . that . includes . keys ( 'response' ) ;
104
+ expect ( path ) . to . be . a ( 'string' ) ;
105
+
106
+ const { response } = element ;
107
+ expect ( response ) . to . be . an ( 'object' ) . that . is . not . empty ;
108
+ const [ key , value ] = Object . entries ( response ) [ 1 ] ;
109
+ expect ( key ) . to . be . a ( 'string' ) ;
110
+
111
+ const schema = JSON . parse ( value . body ) ,
112
+ transformedSchema = transformSchema ( schema ) ,
113
+ validate = ajv . compile ( transformedSchema ) ,
114
+ valid = validate ( example ) ;
115
+
116
+ expect ( value ) . to . have . property ( 'body' ) . that . is . a ( 'string' ) ;
117
+ expect ( valid , `Validation failed for key: ${ key } with errors: ${ JSON . stringify ( validate . errors ) } ` ) . to . be . true ;
118
+ }
118
119
} ) ;
119
120
} ) ;
120
121
@@ -137,12 +138,10 @@ describe('convertV2WithTypes', function() {
137
138
138
139
Converter . convertV2WithTypes ( { type : 'string' , data : openapi } , options , ( err , conversionResult ) => {
139
140
expect ( err ) . to . be . null ;
140
- expect ( conversionResult . extractedTypes ) . to . be . an ( 'array ' ) . that . is . not . empty ;
141
+ expect ( conversionResult . extractedTypes ) . to . be . an ( 'object ' ) . that . is . not . empty ;
141
142
142
- // Validate the first extracted type
143
- const element = conversionResult . extractedTypes [ 0 ] ;
143
+ const element = Object . values ( conversionResult . extractedTypes ) [ 0 ] ;
144
144
const { response } = element ;
145
-
146
145
// Get the schema from the response
147
146
const [ key , value ] = Object . entries ( response ) [ 0 ] ;
148
147
expect ( value ) . to . have . property ( 'body' ) . that . is . a ( 'string' ) ;
@@ -153,6 +152,7 @@ describe('convertV2WithTypes', function() {
153
152
valid = validate ( example ) ;
154
153
expect ( valid , `Validation failed for key: ${ key } with errors: ${ JSON . stringify ( validate . errors ) } ` ) . to . be . true ;
155
154
done ( ) ;
156
- } ) ;
155
+ }
156
+ ) ;
157
157
} ) ;
158
158
} ) ;
0 commit comments