From 0e3e9dc7ca40463183b08a4b8f6e47a1b124a052 Mon Sep 17 00:00:00 2001 From: Dom Harrington Date: Mon, 2 Oct 2017 17:53:00 -0700 Subject: [PATCH] Add test for Doc for setting state that auth is okay after submission --- packages/api-explorer-ui/__tests__/Doc.test.jsx | 10 ++++++++++ packages/api-explorer-ui/src/Doc.jsx | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/api-explorer-ui/__tests__/Doc.test.jsx b/packages/api-explorer-ui/__tests__/Doc.test.jsx index 36da0e6e1..7c426ffa4 100644 --- a/packages/api-explorer-ui/__tests__/Doc.test.jsx +++ b/packages/api-explorer-ui/__tests__/Doc.test.jsx @@ -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.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', () => { diff --git a/packages/api-explorer-ui/src/Doc.jsx b/packages/api-explorer-ui/src/Doc.jsx index 56568b490..b2dde6c46 100644 --- a/packages/api-explorer-ui/src/Doc.jsx +++ b/packages/api-explorer-ui/src/Doc.jsx @@ -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; }