I want to write the test cases for mockup data of the table. Following are the sample snippets of files.
import {Grid, Table, TableBody, TableCell, TableHead, TableRow} from '@material-ui/core';
export const renderTableData = (item) => {
const classes = useStyles();
return (
<Grid item xs={12} className={classes.tableContianer}>
<Table>
<TableHead>
<TableRow classes={{root: classes.tableRow}}>
{item.columns &&
item.columns.map((subItem, index) => {
return (
<TableCell padding="none" key={index}>
{subItem}
</TableCell>
);
})}
</TableRow>
</TableHead>
<TableBody>
{item.rows.map((row, index) => (
<TableRow key={index} classes={{root: classes.tableRow}}>
{Object.keys(row).map((key, index) => {
return (
<TableCell padding="none" key={index} classes={{root: classes.tableCell}}>
{row[key]}
</TableCell>
);
})}
</TableRow>
))}
</TableBody>
</Table>
</Grid>
);
};
And here is my sample test files for the test cases
import React from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import {renderTableData} from "./Table"
it('renders without crashing', async () => {
const props = {
columns:['one','two','three','four'],
rows:[{one:"onedata",two:"twodata",three:"threedata",four:"fourdata"}]
}
render(<renderTable props={props}/>)
screen.debug();
}
when I am running the test cases of this files and check the console because of the screen.debug() ,it only shows me the props ={object object} rather it should render the html view of the files but I can not get it. Could some one take a look and let me know what should I modify the code to render the table with data into the screen.debug().
Thanks