Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Fix regression introduced in 0.9.4 which caused the reference guides …
Browse files Browse the repository at this point in the history
…to fail
  • Loading branch information
Dom Harrington committed Aug 28, 2018
1 parent 9b44ac7 commit 2dc341e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions packages/api-explorer/__tests__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,26 @@ describe('oas', () => {
expect(explorer.find('Doc').get(0).props.oas).toBe(oas);
});

// Of course... `typeof null === 'object'`
it('should not error if `doc.api.apiSetting` is null', () => {
const explorer = shallow(
<ApiExplorer
{...props}
docs={[
Object.assign({}, baseDoc, {
api: { method: 'get', apiSetting: null },
}),
]}
/>,
);

expect(explorer.find('Doc').get(0).props.oas).toEqual({});
});

it('should set it to empty object', () => {
const explorer = shallow(
<ApiExplorer
{...props}
oasFiles={{
'api-setting': oas,
}}
docs={[baseDoc]}
/>,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/api-explorer/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ApiExplorer extends React.Component {
const apiSetting =
doc.category.apiSetting ||
(typeof doc.api.apiSetting === 'string' && doc.api.apiSetting) ||
(typeof doc.api.apiSetting === 'object' && doc.api.apiSetting._id);
(typeof doc.api.apiSetting === 'object' && doc.api.apiSetting && doc.api.apiSetting._id);

return this.props.oasFiles[apiSetting];
}
Expand Down

0 comments on commit 2dc341e

Please sign in to comment.