From f5bb768c0e8dd542468b0fbbefed6ed817cbdf83 Mon Sep 17 00:00:00 2001 From: Meghan McLaughlin Date: Fri, 24 Apr 2020 11:46:02 -0500 Subject: [PATCH] more tests --- pwa/src/components/DiagnosisFields.json | 5 +++-- pwa/src/components/DiagnosisForm.test.tsx | 16 +++++++++++--- pwa/src/components/DiagnosisForm.tsx | 26 +++++++++++++++++------ 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/pwa/src/components/DiagnosisFields.json b/pwa/src/components/DiagnosisFields.json index 8d2ee42..e6d16b1 100644 --- a/pwa/src/components/DiagnosisFields.json +++ b/pwa/src/components/DiagnosisFields.json @@ -132,6 +132,7 @@ "name": "Pregnancy", "id": "pregnancy", "text-input-title": "Weeks", + "text-input-id": "pregnancy-weeks", "text-input-type": "number" }, { @@ -185,11 +186,11 @@ }, { "text-input-title": "Other Diagnosis", - "id": "other-diagnosis" + "text-input-id": "other-diagnosis" }, { "text-input-title": "Diagnoses Comments", - "id": "comments" + "text-input-id": "comments" } ] } diff --git a/pwa/src/components/DiagnosisForm.test.tsx b/pwa/src/components/DiagnosisForm.test.tsx index c1696ed..4a53cde 100644 --- a/pwa/src/components/DiagnosisForm.test.tsx +++ b/pwa/src/components/DiagnosisForm.test.tsx @@ -45,7 +45,7 @@ test('renders each diagnoses.name data field', () => { }) test(' each diagnoses.name has a corresponding checkbox and is able to be checked/unchecked', () => { - const { getByText, getByTestId } = render() + const { getByTestId } = render() diagnosisFields.forEach((diagnosis) => { if (diagnosis.name != null) { @@ -58,9 +58,19 @@ test(' each diagnoses.name has a corresponding checkbox and is able to be checke }) }) -test('finds and element with each id in the DOM', () => {}) +test('renders each diagnoses.text-input-title data field as a text entry field', () => { + const { getByTestId } = render() -test('renders each diagnoses.text-input-title data field as a text entry field', () => {}) + diagnosisFields.forEach((diagnosis) => { + if (diagnosis['text-input-title'] != null) { + const re = new RegExp(diagnosis['text-input-id'], 'gi') + const field = getByTestId(re) + expect(field).toBeInTheDocument() + // TODO: + //expect(field).toHaveClass('textarea') + } + }) +}) test('each diagnoses.text-input-title data field is able to recieve text input', () => {}) diff --git a/pwa/src/components/DiagnosisForm.tsx b/pwa/src/components/DiagnosisForm.tsx index db8babb..6a22e68 100644 --- a/pwa/src/components/DiagnosisForm.tsx +++ b/pwa/src/components/DiagnosisForm.tsx @@ -1,5 +1,5 @@ import React, { ReactElement } from 'react' -import { List, Checkbox, TextareaItem, WhiteSpace } from 'antd-mobile' +import { List, Checkbox, InputItem, WhiteSpace } from 'antd-mobile' import '../scss/DiagnosisForm.scss' import * as data from './DiagnosisFields.json' @@ -47,13 +47,25 @@ export default function DiagnosisForm(): ReactElement { ) } - if (field['text-input-title'] != null) { + if ( + field['text-input-title'] != null && + field['text-input-id'] != null + ) { formElements.push( field['text-input-title']}> - , ) @@ -62,7 +74,7 @@ export default function DiagnosisForm(): ReactElement { if (field.group != null) { const groupElements: ReactElement[] = [] - // add each group element to the internalElement arrat + // add each group element to the internalElement array field.group.forEach((ele: any) => { groupElements.push(