-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #328 from adhocteam/TTAHUB-105/al-increase-unit-te…
…st-coverage Ttahub 105/al increase unit test coverage
- Loading branch information
Showing
4 changed files
with
162 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
frontend/src/pages/ActivityReport/Pages/components/__tests__/ObjectiveFormItem.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
import '@testing-library/jest-dom'; | ||
import { | ||
render, | ||
screen, | ||
} from '@testing-library/react'; | ||
import React from 'react'; | ||
import { TextInput } from '@trussworks/react-uswds'; | ||
import ObjectiveFormItem from '../ObjectiveFormItem'; | ||
|
||
const RenderObjectiveFormItem = ({ | ||
// eslint-disable-next-line react/prop-types | ||
isValid, formItemValue, onChange = () => { }, | ||
}) => ( | ||
<ObjectiveFormItem | ||
showErrors={!isValid} | ||
className="margin-top-0" | ||
message="objective form item required" | ||
label="Objective" | ||
value={formItemValue} | ||
> | ||
<TextInput | ||
name="text-input-name" | ||
aria-label="text-input-label" | ||
onChange={onChange} | ||
value={formItemValue} | ||
/> | ||
</ObjectiveFormItem> | ||
); | ||
|
||
describe('ObjectiveFormItem', () => { | ||
it('renders correctly', async () => { | ||
const onChange = jest.fn(); | ||
render(<RenderObjectiveFormItem isValid formItemValue="some value" onChange={onChange} />); | ||
const save = await screen.findByText('Objective'); | ||
expect(save).toBeVisible(); | ||
const errorMessage = screen.queryByText('objective form item required'); | ||
expect(errorMessage).toBeNull(); | ||
}); | ||
|
||
it('renders with required message', async () => { | ||
const onChange = jest.fn(); | ||
render(<RenderObjectiveFormItem isValid={false} formItemValue="" onChange={onChange} />); | ||
const save = await screen.findByText('Objective'); | ||
expect(save).toBeVisible(); | ||
const errorMessage = await screen.findByText('objective form item required'); | ||
expect(errorMessage).toBeVisible(); | ||
}); | ||
}); |