@@ -2,6 +2,9 @@ import { render, screen } from "@testing-library/svelte";
22import { tick } from "svelte" ;
33import { user } from "../setup-tests" ;
44import DataTable from "./DataTable.test.svelte" ;
5+ import DataTableCustomSlots from "./DataTableCustomSlots.test.svelte" ;
6+ import DataTableCustomDescription from "./DataTableCustomDescription.test.svelte" ;
7+ import DataTableCustomBoth from "./DataTableCustomBoth.test.svelte" ;
58
69describe ( "DataTable" , ( ) => {
710 beforeEach ( ( ) => {
@@ -857,4 +860,39 @@ describe("DataTable", () => {
857860
858861 expect ( component ) . toBeTruthy ( ) ;
859862 } ) ;
863+
864+ // Regression test for https://github.com/carbon-design-system/carbon-components-svelte/issues/1594
865+ it ( "renders custom title element with props" , ( ) => {
866+ render ( DataTableCustomSlots ) ;
867+
868+ const customTitle = screen . getByRole ( "heading" , { level : 2 } ) ;
869+ expect ( customTitle ) . toBeInTheDocument ( ) ;
870+ expect ( customTitle ) . toHaveTextContent ( "Custom Title" ) ;
871+ expect ( customTitle ) . toHaveClass ( "bx--data-table-header__title" ) ;
872+ } ) ;
873+
874+ it ( "renders custom description element with props" , ( ) => {
875+ const { container } = render ( DataTableCustomDescription ) ;
876+
877+ const customDescription = container . querySelector (
878+ "div.bx--data-table-header__description" ,
879+ ) ;
880+ expect ( customDescription ) . toBeInTheDocument ( ) ;
881+ expect ( customDescription ) . toHaveTextContent ( "Custom Description" ) ;
882+ expect ( customDescription ) . toHaveClass ( "bx--data-table-header__description" ) ;
883+ } ) ;
884+
885+ it ( "renders both custom title and description elements" , ( ) => {
886+ const { container } = render ( DataTableCustomBoth ) ;
887+
888+ const customTitle = screen . getByRole ( "heading" , { level : 2 } ) ;
889+ expect ( customTitle ) . toBeInTheDocument ( ) ;
890+ expect ( customTitle ) . toHaveClass ( "bx--data-table-header__title" ) ;
891+
892+ const customDescription = container . querySelector (
893+ "div.bx--data-table-header__description" ,
894+ ) ;
895+ expect ( customDescription ) . toBeInTheDocument ( ) ;
896+ expect ( customDescription ) . toHaveClass ( "bx--data-table-header__description" ) ;
897+ } ) ;
860898} ) ;
0 commit comments