@@ -3,30 +3,30 @@ import { page } from 'vitest/browser';
33import { render } from 'vitest-browser-svelte' ;
44import type { TableContextOptions } from '$lib/types.js' ;
55import Layout from '$lib/tests/Layout.svelte' ;
6- import Children1Col from '$lib/tests/Children1Col .svelte' ;
6+ import { children1Col , childrenEmptyCell } from '$lib/tests/TestSnippets .svelte' ;
77
88describe ( 'RsTr' , ( ) => {
9- test ( " Should render data rows as lists." , async ( ) => {
9+ test ( ' Should render data rows as lists.' , async ( ) => {
1010 const optionsCtx : TableContextOptions = {
1111 breakpoint : window . innerWidth ,
1212 } ;
1313 render ( Layout , {
1414 props : {
1515 optionsCtx,
16- children : Children1Col ,
17- }
16+ children : children1Col ,
17+ } ,
1818 } ) ;
1919 await expect . element ( page . getByRole ( 'list' ) ) . toBeInTheDocument ( ) ;
2020 } ) ;
21- test ( " Should render header content as list items." , async ( ) => {
21+ test ( ' Should render header content as list items.' , async ( ) => {
2222 const optionsCtx : TableContextOptions = {
2323 breakpoint : window . innerWidth ,
2424 } ;
2525 render ( Layout , {
2626 props : {
2727 optionsCtx,
28- children : Children1Col ,
29- }
28+ children : children1Col ,
29+ } ,
3030 } ) ;
3131 const el = page . getByRole ( 'listitem' ) . element ( ) ;
3232 await expect . element ( el ) . toBeInTheDocument ( ) ;
@@ -39,8 +39,8 @@ describe('RsTr', () => {
3939 render ( Layout , {
4040 props : {
4141 optionsCtx,
42- children : Children1Col ,
43- }
42+ children : children1Col ,
43+ } ,
4444 } ) ;
4545 const el = page . getByRole ( 'cell' ) . element ( ) ;
4646 await expect . element ( el ) . toBeInTheDocument ( ) ;
@@ -53,13 +53,29 @@ describe('RsTr', () => {
5353 render ( Layout , {
5454 props : {
5555 optionsCtx,
56- children : Children1Col ,
57- }
56+ children : children1Col ,
57+ } ,
5858 } ) ;
5959 const el = page . getByRole ( 'cell' ) . element ( ) ;
6060 await expect . element ( el ) . toBeInTheDocument ( ) ;
6161 expect ( el . getAttribute ( 'data-mdsvex-table' ) ) . toBe ( 'td' ) ;
6262 expect ( el . getAttribute ( 'aria-rowindex' ) ) . toBe ( '1' ) ;
6363 expect ( el . getAttribute ( 'aria-colindex' ) ) . toBe ( '1' ) ;
6464 } ) ;
65+ test ( '#7: Should render the correct cell content when the row has one empty cell.' , async ( ) => {
66+ const optionsCtx : TableContextOptions = {
67+ breakpoint : window . innerWidth ,
68+ } ;
69+ render ( Layout , {
70+ props : {
71+ optionsCtx,
72+ children : childrenEmptyCell ,
73+ } ,
74+ } ) ;
75+ const els = page . getByRole ( 'cell' ) . all ( ) ;
76+ await expect . element ( els [ 0 ] . element ( ) ) . toBeInTheDocument ( ) ;
77+ expect ( els [ 0 ] . element ( ) . textContent ) . toBe ( '' ) ;
78+ await expect . element ( els [ 1 ] . element ( ) ) . toBeInTheDocument ( ) ;
79+ expect ( els [ 1 ] . element ( ) . textContent ) . toBe ( 'Cell 2' ) ;
80+ } ) ;
6581} ) ;
0 commit comments