@@ -58,21 +58,35 @@ const EXAMPLE_CUSTOM_DATA_VIEWER_PROPS: Types.DataViewerProps = {
5858} ;
5959const EXAMPLE_POINT : Point . Point = { row : EXAMPLE_ROW , column : EXAMPLE_COLUMN } ;
6060
61+ const wrapper = ( { children } : { children ?: React . ReactNode } ) => {
62+ return (
63+ < table >
64+ < tbody >
65+ < tr > { children } </ tr >
66+ </ tbody >
67+ </ table >
68+ ) ;
69+ } ;
70+
6171beforeEach ( ( ) => {
6272 jest . clearAllMocks ( ) ;
6373} ) ;
6474
6575describe ( "<Cell />" , ( ) => {
6676 test ( "renders" , ( ) => {
67- render ( < Cell { ...EXAMPLE_PROPS } /> ) ;
77+ render ( < Cell { ...EXAMPLE_PROPS } /> , {
78+ wrapper,
79+ } ) ;
6880 const element = document . querySelector ( ".Spreadsheet__cell" ) ;
6981 expect ( element ) . not . toBeNull ( ) ;
7082 expect ( MOCK_DATA_VIEWER ) . toBeCalledTimes ( 1 ) ;
7183 expect ( MOCK_DATA_VIEWER ) . toBeCalledWith ( EXAMPLE_DATA_VIEWER_PROPS , { } ) ;
7284 expect ( MOCK_SET_CELL_DIMENSIONS ) . toBeCalledTimes ( 0 ) ;
7385 } ) ;
7486 test ( "renders read only" , ( ) => {
75- render ( < Cell { ...EXAMPLE_PROPS } data = { EXAMPLE_READ_ONLY_DATA } /> ) ;
87+ render ( < Cell { ...EXAMPLE_PROPS } data = { EXAMPLE_READ_ONLY_DATA } /> , {
88+ wrapper,
89+ } ) ;
7690 const element = document . querySelector (
7791 ".Spreadsheet__cell.Spreadsheet__cell--readonly"
7892 ) ;
@@ -85,7 +99,9 @@ describe("<Cell />", () => {
8599 expect ( MOCK_SET_CELL_DIMENSIONS ) . toBeCalledTimes ( 0 ) ;
86100 } ) ;
87101 test ( "renders with given class name" , ( ) => {
88- render ( < Cell { ...EXAMPLE_PROPS } data = { EXAMPLE_DATA_WITH_CLASS_NAME } /> ) ;
102+ render ( < Cell { ...EXAMPLE_PROPS } data = { EXAMPLE_DATA_WITH_CLASS_NAME } /> , {
103+ wrapper,
104+ } ) ;
89105 const element = document . querySelector (
90106 `.Spreadsheet__cell.${ EXAMPLE_DATA_WITH_CLASS_NAME . className } `
91107 ) ;
@@ -98,7 +114,9 @@ describe("<Cell />", () => {
98114 expect ( MOCK_SET_CELL_DIMENSIONS ) . toBeCalledTimes ( 0 ) ;
99115 } ) ;
100116 test ( "renders selected" , ( ) => {
101- render ( < Cell { ...EXAMPLE_PROPS } selected /> ) ;
117+ render ( < Cell { ...EXAMPLE_PROPS } selected /> , {
118+ wrapper,
119+ } ) ;
102120 const element = document . querySelector < HTMLElement > ( ".Spreadsheet__cell" ) ;
103121 expect ( element ) . not . toBeNull ( ) ;
104122 if ( ! element ) {
@@ -111,7 +129,9 @@ describe("<Cell />", () => {
111129 ) ;
112130 } ) ;
113131 test ( "renders active" , ( ) => {
114- render ( < Cell { ...EXAMPLE_PROPS } active /> ) ;
132+ render ( < Cell { ...EXAMPLE_PROPS } active /> , {
133+ wrapper,
134+ } ) ;
115135 const element = document . querySelector < HTMLElement > ( ".Spreadsheet__cell" ) ;
116136 expect ( element ) . not . toBeNull ( ) ;
117137 if ( ! element ) {
@@ -121,7 +141,9 @@ describe("<Cell />", () => {
121141 expect ( MOCK_SET_CELL_DIMENSIONS ) . toBeCalledTimes ( 0 ) ;
122142 } ) ;
123143 test ( "handles mouse down" , ( ) => {
124- render ( < Cell { ...EXAMPLE_PROPS } /> ) ;
144+ render ( < Cell { ...EXAMPLE_PROPS } /> , {
145+ wrapper,
146+ } ) ;
125147 const element = document . querySelector < HTMLElement > ( ".Spreadsheet__cell" ) ;
126148 expect ( element ) . not . toBeNull ( ) ;
127149 if ( ! element ) {
@@ -139,7 +161,9 @@ describe("<Cell />", () => {
139161 expect ( MOCK_SELECT ) . toBeCalledTimes ( 0 ) ;
140162 } ) ;
141163 test ( "handles mouse down + shift" , ( ) => {
142- render ( < Cell { ...EXAMPLE_PROPS } /> ) ;
164+ render ( < Cell { ...EXAMPLE_PROPS } /> , {
165+ wrapper,
166+ } ) ;
143167 const element = document . querySelector < HTMLElement > ( ".Spreadsheet__cell" ) ;
144168 expect ( element ) . not . toBeNull ( ) ;
145169 if ( ! element ) {
@@ -157,7 +181,9 @@ describe("<Cell />", () => {
157181 expect ( MOCK_SELECT ) . toBeCalledWith ( EXAMPLE_POINT ) ;
158182 } ) ;
159183 test ( "handles mouse over with dragging" , ( ) => {
160- render ( < Cell { ...EXAMPLE_PROPS } dragging /> ) ;
184+ render ( < Cell { ...EXAMPLE_PROPS } dragging /> , {
185+ wrapper,
186+ } ) ;
161187 const element = document . querySelector < HTMLElement > ( ".Spreadsheet__cell" ) ;
162188 expect ( element ) . not . toBeNull ( ) ;
163189 if ( ! element ) {
@@ -176,7 +202,10 @@ describe("<Cell />", () => {
176202 } ) ;
177203 test ( "custom cell DataViewer" , ( ) => {
178204 render (
179- < Cell { ...EXAMPLE_PROPS } data = { EXAMPLE_DATA_WITH_CUSTOM_DATA_VIEWER } />
205+ < Cell { ...EXAMPLE_PROPS } data = { EXAMPLE_DATA_WITH_CUSTOM_DATA_VIEWER } /> ,
206+ {
207+ wrapper,
208+ }
180209 ) ;
181210 const element = document . querySelector ( ".Spreadsheet__cell" ) ;
182211 expect ( element ) . not . toBeNull ( ) ;
0 commit comments