This repository was archived by the owner on Nov 28, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -151,13 +151,26 @@ describe('oas', () => {
151
151
expect ( explorer . find ( 'Doc' ) . get ( 0 ) . props . oas ) . toBe ( oas ) ;
152
152
} ) ;
153
153
154
+ // Of course... `typeof null === 'object'`
155
+ it ( 'should not error if `doc.api.apiSetting` is null' , ( ) => {
156
+ const explorer = shallow (
157
+ < ApiExplorer
158
+ { ...props }
159
+ docs = { [
160
+ Object . assign ( { } , baseDoc , {
161
+ api : { method : 'get' , apiSetting : null } ,
162
+ } ) ,
163
+ ] }
164
+ /> ,
165
+ ) ;
166
+
167
+ expect ( explorer . find ( 'Doc' ) . get ( 0 ) . props . oas ) . toEqual ( { } ) ;
168
+ } ) ;
169
+
154
170
it ( 'should set it to empty object' , ( ) => {
155
171
const explorer = shallow (
156
172
< ApiExplorer
157
173
{ ...props }
158
- oasFiles = { {
159
- 'api-setting' : oas ,
160
- } }
161
174
docs = { [ baseDoc ] }
162
175
/> ,
163
176
) ;
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ class ApiExplorer extends React.Component {
50
50
const apiSetting =
51
51
doc . category . apiSetting ||
52
52
( typeof doc . api . apiSetting === 'string' && doc . api . apiSetting ) ||
53
- ( typeof doc . api . apiSetting === 'object' && doc . api . apiSetting . _id ) ;
53
+ ( typeof doc . api . apiSetting === 'object' && doc . api . apiSetting && doc . api . apiSetting . _id ) ;
54
54
55
55
return this . props . oasFiles [ apiSetting ] ;
56
56
}
You can’t perform that action at this time.
0 commit comments