From aafe44add7a3b27d244320bf913d08104e41a13b Mon Sep 17 00:00:00 2001 From: Dom Harrington Date: Tue, 6 Feb 2018 13:41:24 -0800 Subject: [PATCH] Fix issue where api key couldnt be set manually for oauth --- packages/api-explorer/__tests__/SecurityInput.test.jsx | 6 ++++++ packages/api-explorer/__tests__/index.test.jsx | 4 ++-- packages/api-explorer/src/index.jsx | 2 +- packages/api-explorer/src/security-input-types/Oauth2.jsx | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/api-explorer/__tests__/SecurityInput.test.jsx b/packages/api-explorer/__tests__/SecurityInput.test.jsx index 41da1ee11..c13c9803e 100644 --- a/packages/api-explorer/__tests__/SecurityInput.test.jsx +++ b/packages/api-explorer/__tests__/SecurityInput.test.jsx @@ -60,6 +60,12 @@ describe('oauth2', () => { securityInput.find('input[type="text"]').simulate('change'); expect(onChange.mock.calls[0][0]).toEqual({ 'test-auth': '1234' }); + + expect(securityInput.find('input[type="text"]').instance().value).toEqual('1234'); + + securityInput.find('input[type="text"]').instance().value += '56'; + securityInput.find('input[type="text"]').simulate('change'); + expect(onChange.mock.calls[1][0]).toEqual({ 'test-auth': '123456' }); }); }); diff --git a/packages/api-explorer/__tests__/index.test.jsx b/packages/api-explorer/__tests__/index.test.jsx index 62983a0c7..9cb81c071 100644 --- a/packages/api-explorer/__tests__/index.test.jsx +++ b/packages/api-explorer/__tests__/index.test.jsx @@ -160,9 +160,9 @@ describe('apiKey', () => { expect(explorer.state('apiKey')).toBe(apiKey); }); - it('should default to empty string', () => { + it('should default to undefined', () => { const explorer = shallow(); - expect(explorer.state('apiKey')).toBe(''); + expect(explorer.state('apiKey')).toBe(undefined); }); }); diff --git a/packages/api-explorer/src/index.jsx b/packages/api-explorer/src/index.jsx index fd575541c..6bec59ca2 100644 --- a/packages/api-explorer/src/index.jsx +++ b/packages/api-explorer/src/index.jsx @@ -11,7 +11,7 @@ class ApiExplorer extends React.Component { const userData = Cookie.getJSON('user_data'); return userData.keys.api_key; } catch (e) { - return ''; + return undefined; } } diff --git a/packages/api-explorer/src/security-input-types/Oauth2.jsx b/packages/api-explorer/src/security-input-types/Oauth2.jsx index 69040d24b..2e4832f21 100644 --- a/packages/api-explorer/src/security-input-types/Oauth2.jsx +++ b/packages/api-explorer/src/security-input-types/Oauth2.jsx @@ -62,7 +62,7 @@ Oauth2.propTypes = { }; Oauth2.defaultProps = { - apiKey: '', + apiKey: undefined, authInputRef: () => {}, };