From 173a3e68355fae5e357c74ecef9c09d76728d1e4 Mon Sep 17 00:00:00 2001 From: Sanjeet Uppal Date: Mon, 30 Oct 2017 15:59:10 -0700 Subject: [PATCH] Pass tests --- .../__tests__/CodeSampleResponse.test.jsx | 11 ++++++++--- packages/api-explorer-ui/src/CodeSampleResponse.jsx | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/api-explorer-ui/__tests__/CodeSampleResponse.test.jsx b/packages/api-explorer-ui/__tests__/CodeSampleResponse.test.jsx index 3ee856b30..399236092 100644 --- a/packages/api-explorer-ui/__tests__/CodeSampleResponse.test.jsx +++ b/packages/api-explorer-ui/__tests__/CodeSampleResponse.test.jsx @@ -166,8 +166,6 @@ describe('Results body', () => { , ); - console.log(codeSampleResponseTabs.find('.hub-expired-token').html()); - expect(codeSampleResponseTabs.find('.hub-expired-token').length).toEqual(1); expect( codeSampleResponseTabs.containsMatchingElement( @@ -203,7 +201,14 @@ describe('Results body', () => { />, ); - expect(codeSampleResponseTabs.find('a.btn btn-primary').length).toEqual(1); + expect( + codeSampleResponseTabs.containsAllMatchingElements([ +
+

Your OAuth2 token has expired

+ Reauthenticate via OAuth2 +
, + ]), + ).toEqual(true); }); test('should display message authentication message if endpoint does not use oAuth', async () => { diff --git a/packages/api-explorer-ui/src/CodeSampleResponse.jsx b/packages/api-explorer-ui/src/CodeSampleResponse.jsx index d42e569b6..9f20e13a1 100644 --- a/packages/api-explorer-ui/src/CodeSampleResponse.jsx +++ b/packages/api-explorer-ui/src/CodeSampleResponse.jsx @@ -129,7 +129,7 @@ class CodeSampleResponse extends React.Component { {result.statusCode[0] === 401 && (
{securities.OAuth2 ? ( - () => { + (() => { if (oauthUrl) { return (
@@ -141,7 +141,7 @@ class CodeSampleResponse extends React.Component { ); } return

Your OAuth2 token is incorrect or has expired

; - } + })() ) : (

You couldn't be authenticated

)}