11import { page , userEvent } from 'vitest/browser' ;
22
33import { DataGrid } from '../../src' ;
4- import type { Column , DataGridProps } from '../../src' ;
4+ import type { Column } from '../../src' ;
55import { safeTab } from './utils' ;
66
77interface Row {
@@ -55,7 +55,9 @@ const rows: readonly Row[] = [
5555describe ( 'Events' , ( ) => {
5656 it ( 'should not select cell if onCellMouseDown prevents grid default' , async ( ) => {
5757 await page . render (
58- < EventTest
58+ < DataGrid
59+ columns = { columns }
60+ rows = { rows }
5961 onCellMouseDown = { ( args , event ) => {
6062 if ( args . column . key === 'col1' ) {
6163 event . preventGridDefault ( ) ;
@@ -71,7 +73,9 @@ describe('Events', () => {
7173
7274 it ( 'should be able to open editor editor on single click using onCellClick' , async ( ) => {
7375 await page . render (
74- < EventTest
76+ < DataGrid
77+ columns = { columns }
78+ rows = { rows }
7579 onCellClick = { ( args , event ) => {
7680 if ( args . column . key === 'col2' ) {
7781 event . preventGridDefault ( ) ;
@@ -88,7 +92,9 @@ describe('Events', () => {
8892
8993 it ( 'should not open editor editor on double click if onCellDoubleClick prevents default' , async ( ) => {
9094 await page . render (
91- < EventTest
95+ < DataGrid
96+ columns = { columns }
97+ rows = { rows }
9298 onCellDoubleClick = { ( args , event ) => {
9399 if ( args . column . key === 'col1' ) {
94100 event . preventGridDefault ( ) ;
@@ -104,7 +110,9 @@ describe('Events', () => {
104110
105111 it ( 'should call onCellContextMenu when cell is right clicked' , async ( ) => {
106112 const onCellContextMenu = vi . fn ( ) ;
107- await page . render ( < EventTest onCellContextMenu = { onCellContextMenu } /> ) ;
113+ await page . render (
114+ < DataGrid columns = { columns } rows = { rows } onCellContextMenu = { onCellContextMenu } />
115+ ) ;
108116 expect ( onCellContextMenu ) . not . toHaveBeenCalled ( ) ;
109117 await userEvent . click ( page . getCell ( { name : '1' } ) , { button : 'right' } ) ;
110118 expect ( onCellContextMenu ) . toHaveBeenCalledExactlyOnceWith (
@@ -122,7 +130,9 @@ describe('Events', () => {
122130 it ( 'should call onActivePositionChange when cell selection is changed' , async ( ) => {
123131 const onActivePositionChange = vi . fn ( ) ;
124132
125- await page . render ( < EventTest onActivePositionChange = { onActivePositionChange } /> ) ;
133+ await page . render (
134+ < DataGrid columns = { columns } rows = { rows } onActivePositionChange = { onActivePositionChange } />
135+ ) ;
126136
127137 expect ( onActivePositionChange ) . not . toHaveBeenCalled ( ) ;
128138
@@ -181,16 +191,3 @@ describe('Events', () => {
181191 expect ( onActivePositionChange ) . toHaveBeenCalledTimes ( 6 ) ;
182192 } ) ;
183193} ) ;
184-
185- type EventProps = Pick <
186- DataGridProps < Row > ,
187- | 'onCellMouseDown'
188- | 'onCellClick'
189- | 'onCellDoubleClick'
190- | 'onCellContextMenu'
191- | 'onActivePositionChange'
192- > ;
193-
194- function EventTest ( props : EventProps ) {
195- return < DataGrid columns = { columns } rows = { rows } { ...props } /> ;
196- }
0 commit comments