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

Commit

Permalink
Add test for Doc for setting state that auth is okay after submission
Browse files Browse the repository at this point in the history
  • Loading branch information
Dom Harrington committed Oct 3, 2017
1 parent 1bebb8e commit 0e3e9dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/api-explorer-ui/__tests__/Doc.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ describe('onSubmit', () => {
expect(doc.state('showAuthBox')).toBe(true);
expect(doc.state('needsAuth')).toBe(true);
});

it('should hide authBox on successful submit', () => {
const doc = mount(<Doc {...props} />);
doc.instance().onSubmit();
doc.instance().onChange({ auth: { api_key: 'api-key' } });
doc.instance().onSubmit();

expect(doc.state('showAuthBox')).toBe(false);
expect(doc.state('needsAuth')).toBe(false);
});
});

describe('state.loading', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/api-explorer-ui/src/Doc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Doc extends React.Component {
return false;
}

this.setState({ loading: true });
this.setState({ loading: true, showAuthBox: false, needsAuth: false });
return true;
}

Expand Down

0 comments on commit 0e3e9dc

Please sign in to comment.