@@ -28,26 +28,15 @@ const props = {
28
28
handleOpenPageStyleDialog : vi . fn ( ) ,
29
29
} satisfies ITableWrapperProps ;
30
30
31
- const mockCustomCell = ( ) => {
31
+ const mockCustomCellModule = ( variant : 'valid' | 'error' | 'noRender' | 'undefined' ) => {
32
+ const mod = {
33
+ valid : MockCustomCell ,
34
+ error : MockCustomCellError ,
35
+ noRender : MockCustomCellNoRender ,
36
+ undefined,
37
+ } [ variant ] ;
32
38
vi . doMock ( `${ getBuildDirPath ( ) } /custom/${ CUSTOM_CELL_FILE_NAME } .js` , ( ) => ( {
33
- default : MockCustomCell ,
34
- } ) ) ;
35
- } ;
36
-
37
- const mockCustomCellError = ( ) => {
38
- vi . doMock ( `${ getBuildDirPath ( ) } /custom/${ CUSTOM_CELL_FILE_NAME } .js` , ( ) => ( {
39
- default : MockCustomCellError ,
40
- } ) ) ;
41
- } ;
42
-
43
- const mockCustomCellWithoutRender = ( ) => {
44
- vi . doMock ( `${ getBuildDirPath ( ) } /custom/${ CUSTOM_CELL_FILE_NAME } .js` , ( ) => ( {
45
- default : MockCustomCellNoRender ,
46
- } ) ) ;
47
- } ;
48
- const mockCustomCellToUndefined = ( ) => {
49
- vi . doMock ( `${ getBuildDirPath ( ) } /custom/${ CUSTOM_CELL_FILE_NAME } .js` , ( ) => ( {
50
- default : undefined ,
39
+ default : mod ,
51
40
} ) ) ;
52
41
} ;
53
42
@@ -94,7 +83,7 @@ test.each([
94
83
{ interval : 14 , expected : '14' } ,
95
84
{ interval : 15 , expected : '15' } ,
96
85
] ) ( 'Render custom cell correctly for interval $interval' , async ( { interval, expected } ) => {
97
- mockCustomCell ( ) ;
86
+ mockCustomCellModule ( 'valid' ) ;
98
87
// render only one row as mock for custom cell work just for the first time
99
88
// so we need to render only one row
100
89
mocksAndRenderTable ( interval ) ;
@@ -109,7 +98,7 @@ test.each([
109
98
} ) ;
110
99
111
100
test ( 'Render custom cell with Error message' , async ( ) => {
112
- mockCustomCellError ( ) ;
101
+ mockCustomCellModule ( 'error' ) ;
113
102
const mockConsoleError = vi . fn ( ) ;
114
103
consoleError . mockImplementation ( mockConsoleError ) ;
115
104
mocksAndRenderTable ( 10 ) ;
@@ -130,7 +119,7 @@ test('Render custom cell with Error message', async () => {
130
119
} ) ;
131
120
132
121
test ( 'Error as custom cell without render method' , async ( ) => {
133
- mockCustomCellWithoutRender ( ) ;
122
+ mockCustomCellModule ( 'noRender' ) ;
134
123
mocksAndRenderTable ( ) ;
135
124
136
125
const row = await waitForRow ( ) ;
@@ -144,7 +133,8 @@ test('Error as custom cell without render method', async () => {
144
133
145
134
test ( 'Error as custom cell file is undefined' , async ( ) => {
146
135
consoleError . mockImplementation ( ( ) => { } ) ;
147
- mockCustomCellToUndefined ( ) ;
136
+ // mockCustomCellToUndefined();
137
+ mockCustomCellModule ( 'undefined' ) ;
148
138
mocksAndRenderTable ( ) ;
149
139
150
140
const row = await waitForRow ( ) ;
@@ -157,7 +147,7 @@ test('Error as custom cell file is undefined', async () => {
157
147
} ) ;
158
148
159
149
test ( 'should update custom Cell Row when Input has changed' , async ( ) => {
160
- mockCustomCell ( ) ;
150
+ mockCustomCellModule ( 'valid' ) ;
161
151
// render only one row as mock for custom cell work just for the first time
162
152
mocksAndRenderTable ( 11 ) ;
163
153
0 commit comments