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

Commit aafe44a

Browse files
author
Dom Harrington
committed
Fix issue where api key couldnt be set manually for oauth
1 parent 4010334 commit aafe44a

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

packages/api-explorer/__tests__/SecurityInput.test.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ describe('oauth2', () => {
6060
securityInput.find('input[type="text"]').simulate('change');
6161

6262
expect(onChange.mock.calls[0][0]).toEqual({ 'test-auth': '1234' });
63+
64+
expect(securityInput.find('input[type="text"]').instance().value).toEqual('1234');
65+
66+
securityInput.find('input[type="text"]').instance().value += '56';
67+
securityInput.find('input[type="text"]').simulate('change');
68+
expect(onChange.mock.calls[1][0]).toEqual({ 'test-auth': '123456' });
6369
});
6470
});
6571

packages/api-explorer/__tests__/index.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ describe('apiKey', () => {
160160
expect(explorer.state('apiKey')).toBe(apiKey);
161161
});
162162

163-
it('should default to empty string', () => {
163+
it('should default to undefined', () => {
164164
const explorer = shallow(<ApiExplorer {...props} />);
165165

166-
expect(explorer.state('apiKey')).toBe('');
166+
expect(explorer.state('apiKey')).toBe(undefined);
167167
});
168168
});

packages/api-explorer/src/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ApiExplorer extends React.Component {
1111
const userData = Cookie.getJSON('user_data');
1212
return userData.keys.api_key;
1313
} catch (e) {
14-
return '';
14+
return undefined;
1515
}
1616
}
1717

packages/api-explorer/src/security-input-types/Oauth2.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Oauth2.propTypes = {
6262
};
6363

6464
Oauth2.defaultProps = {
65-
apiKey: '',
65+
apiKey: undefined,
6666
authInputRef: () => {},
6767
};
6868

0 commit comments

Comments
 (0)