PR-722301: fixing list tests.

This commit is contained in:
Alejandro Lembke Barrientos 2023-10-12 00:18:36 +00:00
parent d1da40fdd2
commit 93d1776d8b
3 changed files with 38 additions and 29 deletions

View File

@ -16,9 +16,11 @@ describe('Testing List Component', () => {
name: 'Third Item', name: 'Third Item',
status: Status.DONE status: Status.DONE
} }
]} />); ]}
handleChangeState={() => {}}
/>);
}) })
it('Show All Items in a list', () => { it('Show All Items in a list', () => {
cy.get('input').should('have.length', 3); cy.get('[role="textbox"]').should('have.length', 3);
}) })
}) })

View File

@ -18,7 +18,9 @@ describe('Testing List Component', () => {
name: 'Third Item', name: 'Third Item',
status: Status.DONE status: Status.DONE
} }
]} />) ]}
handleChangeState={() => {}}
/>)
}); });
it('Show All Items in a list', async () => { it('Show All Items in a list', async () => {
/* fetchMock.mockResponseOnce(JSON.stringify({ /* fetchMock.mockResponseOnce(JSON.stringify({

View File

@ -24,6 +24,10 @@ type TListProps = {
* Is this the onClick Event of the button. * Is this the onClick Event of the button.
*/ */
onClickRemoveItem?: MouseEventHandler<HTMLButtonElement> |undefined onClickRemoveItem?: MouseEventHandler<HTMLButtonElement> |undefined
/**
* Is this the on Event triggered by the checkbox.
*/
handleChangeState?: ChangeEventHandler<HTMLInputElement>
}; };
const List: FC<TListProps> = ({ const List: FC<TListProps> = ({
@ -31,7 +35,8 @@ const List: FC<TListProps> = ({
placeholderInput, placeholderInput,
onChangeInput, onChangeInput,
onClickAddItem, onClickAddItem,
onClickRemoveItem onClickRemoveItem,
handleChangeState
}) => { }) => {
return ( return (
<div className="List"> <div className="List">
@ -39,7 +44,7 @@ const List: FC<TListProps> = ({
<tbody> <tbody>
{ list !== undefined && list.map((item, index) => ( { list !== undefined && list.map((item, index) => (
<tr key={index}> <tr key={index}>
<td><Item name={item.name} status={item.status} /></td> <td><Item name={item.name} status={item.status} handleChange={handleChangeState} /></td>
<td> <td>
<div className="delete-button-container"> <div className="delete-button-container">
<Button <Button