11import { describe , expect , it } from "vitest" ;
22import { fireEvent , render , screen } from "@testing-library/react" ;
3- import { Table } from "./Table " ;
3+ import { DataGrid } from "./DataGrid " ;
44import { createChangeHandler } from "@/plugins/mui/common.test" ;
55
6- describe ( "Table " , ( ) => {
6+ describe ( "DataGrid " , ( ) => {
77 const mockColumns = [
88 { field : "id" , headerName : "ID" } ,
99 { field : "name" , headerName : "Name" } ,
1010 ] ;
1111 const mockRows = [ { id : 1 , name : "MockRow" } ] ;
1212 const paginationModel = { page : 1 , pageSize : 10 } ;
1313
14- it ( "should render the Table component" , ( ) => {
14+ it ( "should render the DataGrid component" , ( ) => {
1515 render (
16- < Table
16+ < DataGrid
1717 columns = { mockColumns }
1818 rows = { mockRows }
19- type = "Table "
20- id = "tableId "
21- ariaLabel = "Test Table "
19+ type = "DataGrid "
20+ id = "datagridId "
21+ ariaLabel = "Test DataGrid "
2222 onChange = { ( ) => { } }
2323 paginationModel = { paginationModel }
2424 pageSizeOptions = { [ 10 , 25 , 50 ] }
@@ -28,17 +28,17 @@ describe("Table", () => {
2828 expect ( screen . getByText ( "MockRow" ) ) . toBeInTheDocument ( ) ;
2929
3030 const grid = screen . getByTestId ( "data-grid-test-id" ) ;
31- expect ( grid ) . toHaveAttribute ( "aria-label" , "Test Table " ) ;
31+ expect ( grid ) . toHaveAttribute ( "aria-label" , "Test DataGrid " ) ;
3232 } ) ;
3333
3434 it ( "should handle row click" , ( ) => {
3535 const { recordedEvents, onChange } = createChangeHandler ( ) ;
3636 render (
37- < Table
37+ < DataGrid
3838 columns = { mockColumns }
3939 rows = { mockRows }
40- type = "Table "
41- id = "tableId "
40+ type = "DataGrid "
41+ id = "datagridId "
4242 onChange = { onChange }
4343 /> ,
4444 ) ;
@@ -47,21 +47,21 @@ describe("Table", () => {
4747 fireEvent . click ( row ) ;
4848
4949 expect ( recordedEvents . length ) . toBe ( 1 ) ;
50- expect ( recordedEvents [ 0 ] . componentType ) . toBe ( "Table " ) ;
51- expect ( recordedEvents [ 0 ] . id ) . toBe ( "tableId " ) ;
50+ expect ( recordedEvents [ 0 ] . componentType ) . toBe ( "DataGrid " ) ;
51+ expect ( recordedEvents [ 0 ] . id ) . toBe ( "datagridId " ) ;
5252 expect ( recordedEvents [ 0 ] . property ) . toBe ( "value" ) ;
5353 expect ( recordedEvents [ 0 ] . value ) . toEqual ( mockRows [ 0 ] ) ;
5454 } ) ;
5555
5656 it ( "should render with other props correctly" , ( ) => {
5757 render (
58- < Table
58+ < DataGrid
5959 columns = { mockColumns }
6060 rows = { mockRows }
61- type = "Table "
62- id = "tableId "
61+ type = "DataGrid "
62+ id = "datagridId "
6363 onChange = { ( ) => { } }
64- ariaLabel = "Test Table "
64+ ariaLabel = "Test DataGrid "
6565 autoPageSize = { true }
6666 checkboxSelection = { true }
6767 density = "compact"
@@ -86,7 +86,12 @@ describe("Table", () => {
8686
8787 it ( "should not render if no columns are provided" , ( ) => {
8888 render (
89- < Table rows = { mockRows } type = "Table" id = "tableId" onChange = { ( ) => { } } /> ,
89+ < DataGrid
90+ rows = { mockRows }
91+ type = "DataGrid"
92+ id = "datagridId"
93+ onChange = { ( ) => { } }
94+ /> ,
9095 ) ;
9196 expect ( screen . queryByRole ( "grid" ) ) . not . toBeInTheDocument ( ) ;
9297 } ) ;
0 commit comments