more tests

This commit is contained in:
Meghan McLaughlin committed 2020-04-26 12:22:51 -05:00
1 parent 90352817be
commit f5bb768c0e
3 files changed
+35 -12

No files matched your search

+3 -2
View File
@@ -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"
}
]
}
+13 -3
View File
@@ -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(<DiagnosisForm />)
const { getByTestId } = render(<DiagnosisForm />)
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(<DiagnosisForm />)
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', () => {})
+19 -7
View File
@@ -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(
<List renderHeader={() => field['text-input-title']}>
<TextareaItem
autoHeight
id={field.id}
data-testid={field.id}
<InputItem
id={field['text-input-id']}
data-testid={field['text-input-id']}
type={
field['text-input-type'] == 'number'
? 'number'
: 'text'
}
maxLength={
field['text-input-id'] == 'pregnancy-weeks'
? 2
: null
}
/>
</List>,
)
@@ -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(
<CheckboxItem