From ee6fda9f8aca8954128ef8290be8dd88fa2f0155 Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Mon, 13 Apr 2020 15:30:35 -0400 Subject: [PATCH] moves validator function --- .../ErrorDetail/ErrorDetail.test.jsx | 1 - .../components/ErrorDetail/getErrorMessage.js | 6 +++--- .../LaunchPrompt/LaunchPrompt.test.jsx | 8 +++++++- .../DeleteRoleConfirmationModal.test.jsx.snap | 2 -- .../Template/Survey/SurveyQuestionForm.jsx | 19 ++++++++++++------- awx/ui_next/src/util/validators.jsx | 11 ----------- 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/awx/ui_next/src/components/ErrorDetail/ErrorDetail.test.jsx b/awx/ui_next/src/components/ErrorDetail/ErrorDetail.test.jsx index 409fefc3f8..383c41e4ed 100644 --- a/awx/ui_next/src/components/ErrorDetail/ErrorDetail.test.jsx +++ b/awx/ui_next/src/components/ErrorDetail/ErrorDetail.test.jsx @@ -41,6 +41,5 @@ describe('ErrorDetail', () => { ); wrapper.find('Expandable').prop('onToggle')(); wrapper.update(); - // console.log(wrapper.find('ErrorDetail').prop('error')); }); }); diff --git a/awx/ui_next/src/components/ErrorDetail/getErrorMessage.js b/awx/ui_next/src/components/ErrorDetail/getErrorMessage.js index 82783f8f63..ca6fbb23be 100644 --- a/awx/ui_next/src/components/ErrorDetail/getErrorMessage.js +++ b/awx/ui_next/src/components/ErrorDetail/getErrorMessage.js @@ -1,10 +1,10 @@ export default function getErrorMessage(response) { - if (typeof response.data === 'string') { - return response.data; - } if (!response.data) { return null; } + if (typeof response.data === 'string') { + return response.data; + } if (response.data.detail) { return response.data.detail; } diff --git a/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.test.jsx b/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.test.jsx index 3a490db6bc..78e8dc5504 100644 --- a/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.test.jsx +++ b/awx/ui_next/src/components/LaunchPrompt/LaunchPrompt.test.jsx @@ -6,9 +6,11 @@ import InventoryStep from './InventoryStep'; import CredentialsStep from './CredentialsStep'; import OtherPromptsStep from './OtherPromptsStep'; import PreviewStep from './PreviewStep'; -import { InventoriesAPI } from '@api'; +import { InventoriesAPI, CredentialsAPI, CredentialTypesAPI } from '@api'; jest.mock('@api/models/Inventories'); +jest.mock('@api/models/CredentialTypes'); +jest.mock('@api/models/Credentials'); let config; const resource = { @@ -25,6 +27,10 @@ describe('LaunchPrompt', () => { count: 1, }, }); + CredentialsAPI.read.mockResolvedValue({ + data: { results: [{ id: 1 }], count: 1 }, + }); + CredentialTypesAPI.loadAllTypes({ data: { results: [{ type: 'ssh' }] } }); config = { can_start_without_user_input: false, diff --git a/awx/ui_next/src/components/ResourceAccessList/__snapshots__/DeleteRoleConfirmationModal.test.jsx.snap b/awx/ui_next/src/components/ResourceAccessList/__snapshots__/DeleteRoleConfirmationModal.test.jsx.snap index 795f398ba2..e66d8780df 100644 --- a/awx/ui_next/src/components/ResourceAccessList/__snapshots__/DeleteRoleConfirmationModal.test.jsx.snap +++ b/awx/ui_next/src/components/ResourceAccessList/__snapshots__/DeleteRoleConfirmationModal.test.jsx.snap @@ -322,7 +322,6 @@ exports[` should render initially 1`] = ` className="pf-c-backdrop" > should render initially 1`] = ` } } paused={false} - tag="div" >
{ + return defaultValue => { + if (!choices.includes(defaultValue)) { + return i18n._( + t`Default choice must be answered from the choices listed.` + ); + } + return undefined; + }; + }; + return ( { - if (!choices.includes(defaultValue)) { - return i18n._( - t`Default choice must be answered from the choices listed.` - ); - } - return undefined; - }; -} - export function requiredEmail(i18n) { return value => { if (!value) {