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

Commit 8e6ddbd

Browse files
committed
Remove hacky fix and tests for Basic auth change
1 parent 8521284 commit 8e6ddbd

File tree

3 files changed

+4
-29
lines changed

3 files changed

+4
-29
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,8 @@ test("should work for Basic (Basic has it's own state)", () => {
9797
basic.inputChange('user', 'user');
9898
basic.inputChange('password', 'password');
9999

100-
// TODO this should be removed. See comment above componentDidMount in Basic
101-
expect(onChange.mock.calls[0][0]).toEqual({ auth: { basic: { user: '', password: '' } } });
102-
expect(onChange.mock.calls[1][0]).toEqual({ auth: { basic: { user: 'user', password: '' } } });
103-
expect(onChange.mock.calls[2][0]).toEqual({
100+
expect(onChange.mock.calls[0][0]).toEqual({ auth: { basic: { user: 'user', password: '' } } });
101+
expect(onChange.mock.calls[1][0]).toEqual({
104102
auth: { basic: { user: 'user', password: 'password' } },
105103
});
106104
});

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,7 @@ describe('basic', () => {
121121
securityInput.find('input[name="password"]').instance().value = 'pass';
122122
securityInput.find('input[name="password"]').simulate('change');
123123

124-
// TODO this should eventually be removed
125-
// see comment above componentDidMount in Basic.jsx
126-
expect(onChange.mock.calls[0][0]).toEqual({
127-
'test-basic': {
128-
user: '',
129-
password: '',
130-
},
131-
});
132-
133-
expect(onChange.mock.calls[2][0]).toEqual({
124+
expect(onChange.mock.calls[1][0]).toEqual({
134125
'test-basic': {
135126
user: 'user',
136127
password: 'pass',

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,7 @@ class Basic extends React.Component {
77
this.state = { user: props.user || '', password: props.pass || '' };
88
this.inputChange = this.inputChange.bind(this);
99
}
10-
// TODO refactor this
11-
// This is not ideal... we're having to update the state
12-
// here so that the code sample updates with the base64
13-
// encoded user/pass on first render. This is a sign of
14-
// bad prop passing somewhere and is quite un-reacty.
15-
// Maybe we should be calling getAuth from the top level
16-
// so the value is correct on the first pass through to
17-
// the CodeSample component. Let me mull this over a little more.
18-
//
19-
// This also has the unfortunate side-effect of making the "Try It"
20-
// button in the explorer turn active by default, as though an edit
21-
// has been made
22-
componentDidMount() {
23-
this.props.change({ user: this.state.user, password: this.state.password });
24-
}
10+
2511
componentDidUpdate(prevProps, prevState) {
2612
// Without this if block the code spirals into an infinite loop
2713
if (prevState.user !== this.state.user || prevState.password !== this.state.password)

0 commit comments

Comments
 (0)