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

@ -4,21 +4,23 @@ import { List, Status } from '@components';
describe('Testing List Component', () => {
beforeEach(() => {
cy.mount(<List list={[
{
name: 'First Item',
status: Status.DONE
},
{
name: 'Second Item',
status: Status.TODO
},
{
name: 'Third Item',
status: Status.DONE
}
]} />);
{
name: 'First Item',
status: Status.DONE
},
{
name: 'Second Item',
status: Status.TODO
},
{
name: 'Third Item',
status: Status.DONE
}
]}
handleChangeState={() => {}}
/>);
})
it('Show All Items in a list', () => {
cy.get('input').should('have.length', 3);
cy.get('[role="textbox"]').should('have.length', 3);
})
})

View File

@ -6,19 +6,21 @@ describe('Testing List Component', () => {
beforeEach(() => {
// fetchMock.resetMocks();
render(<List list={[
{
name: 'First Item',
status: Status.DONE
},
{
name: 'Second Item',
status: Status.TODO
},
{
name: 'Third Item',
status: Status.DONE
}
]} />)
{
name: 'First Item',
status: Status.DONE
},
{
name: 'Second Item',
status: Status.TODO
},
{
name: 'Third Item',
status: Status.DONE
}
]}
handleChangeState={() => {}}
/>)
});
it('Show All Items in a list', async () => {
/* fetchMock.mockResponseOnce(JSON.stringify({

View File

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