Skip to content

Commit

Permalink
TTAHUB-105: Fix new lint errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamAdHocTeam committed Jun 9, 2021
1 parent c69f165 commit 90f7d02
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ describe('Goal', () => {
const objName = screen.getByText(/first/i);
expect(objName).toBeVisible();

const objDesc = screen.getByText(/this is the tta desc/i)
expect(objDesc).toBeVisible();;
const objDesc = screen.getByText(/this is the tta desc/i);
expect(objDesc).toBeVisible();
});

it('can be updated', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,49 @@
/* eslint-disable react/jsx-props-no-spreading */
import '@testing-library/jest-dom';
import {
render,
screen,
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 = () => { },
}) => {
return (
<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>
);
};
// 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 correctly', async () => {
const onChange = jest.fn();
render(<RenderObjectiveFormItem isValid={true} 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();
});
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();
});
});



0 comments on commit 90f7d02

Please sign in to comment.