18
18
19
19
import '@testing-library/jest-dom/vitest' ;
20
20
21
- import { render , screen , within } from '@testing-library/svelte' ;
21
+ import { render , screen } from '@testing-library/svelte' ;
22
22
import { tick } from 'svelte' ;
23
23
import { expect , test } from 'vitest' ;
24
24
@@ -29,25 +29,7 @@ test('Expect each table receive its own grid-tables-column values', async () =>
29
29
const table = await screen . findByRole ( 'table' , { name : tableName } ) ;
30
30
expect ( table ) . toBeDefined ( ) ;
31
31
32
- // get the elements having the role "row" inside the table html element
33
- const rows = await within ( table ) . findAllByRole ( 'row' ) ;
34
- const gridTableColumnsValuesSet = new Set < string > ( ) ;
35
- for ( const element of rows ) {
36
- gridTableColumnsValuesSet . add ( element . style . gridTemplateColumns ) ;
37
- }
38
-
39
- // all values should be the same in the set gridTableColumnsValues
40
- const items = Array . from ( gridTableColumnsValuesSet . values ( ) ) ;
41
- expect ( items . length ) . toBe ( 1 ) ;
42
-
43
- const item = items [ 0 ] ;
44
-
45
- // split by space and keep the second value
46
- const values = item . split ( ' ' ) ;
47
-
48
- expect ( values . length ) . toBe ( 3 ) ;
49
-
50
- return values [ 1 ] ;
32
+ return table . style . getPropertyValue ( '--table-grid-table-columns' ) ;
51
33
} ;
52
34
53
35
render ( TestMultiTables , { } ) ;
@@ -57,8 +39,8 @@ test('Expect each table receive its own grid-tables-column values', async () =>
57
39
58
40
// expect to receive for each table, the good values of the width (which is different for each table)
59
41
const gridTableColumnsValuesPersonWidth = await extractGridTableColumnsWidth ( 'person' ) ;
60
- expect ( gridTableColumnsValuesPersonWidth ) . toBe ( '3fr' ) ;
42
+ expect ( gridTableColumnsValuesPersonWidth ) . toBe ( '20px 3fr 5px ' ) ;
61
43
62
44
const gridTableColumnsValuesBookWidth = await extractGridTableColumnsWidth ( 'book' ) ;
63
- expect ( gridTableColumnsValuesBookWidth ) . toBe ( '2fr' ) ;
45
+ expect ( gridTableColumnsValuesBookWidth ) . toBe ( '20px 2fr 5px ' ) ;
64
46
} ) ;
0 commit comments