From 2dc341e25e7ec8933e719561eb524db3ff868a89 Mon Sep 17 00:00:00 2001 From: Dom Harrington Date: Tue, 28 Aug 2018 10:16:26 -0700 Subject: [PATCH] Fix regression introduced in 0.9.4 which caused the reference guides to fail --- .../api-explorer/__tests__/index.test.jsx | 19 ++++++++++++++++--- packages/api-explorer/src/index.jsx | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/api-explorer/__tests__/index.test.jsx b/packages/api-explorer/__tests__/index.test.jsx index 1079a5f06..399ce3c68 100644 --- a/packages/api-explorer/__tests__/index.test.jsx +++ b/packages/api-explorer/__tests__/index.test.jsx @@ -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( + , + ); + + expect(explorer.find('Doc').get(0).props.oas).toEqual({}); + }); + it('should set it to empty object', () => { const explorer = shallow( , ); diff --git a/packages/api-explorer/src/index.jsx b/packages/api-explorer/src/index.jsx index 803090729..8ddbb3f0c 100644 --- a/packages/api-explorer/src/index.jsx +++ b/packages/api-explorer/src/index.jsx @@ -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]; }