@@ -2,7 +2,7 @@ import { render } from "@testing-library/react";
22import GoabButton from "../../lib/button/button" ;
33import { GoabModal , GoabModalProps } from "./modal" ;
44
5- describe ( "Modal Tests " , ( ) => {
5+ describe ( "Modal" , ( ) => {
66 it ( "should render" , async ( ) => {
77 const { baseElement } = render ( < GoabModal > Modal Content</ GoabModal > ) ;
88
@@ -12,7 +12,7 @@ describe("Modal Tests", () => {
1212 expect ( modal ?. getAttribute ( "closable" ) ) . toBe ( "false" ) ;
1313 } ) ;
1414
15- it ( "Modal - should render with close capability via icon and background" , async ( ) => {
15+ it ( "should render with close capability via icon and background" , async ( ) => {
1616 const props = {
1717 heading : "Modal Heading" ,
1818 open : true ,
@@ -35,15 +35,29 @@ describe("Modal Tests", () => {
3535 const { baseElement } = render ( < GoabModal { ...props } > Modal Content</ GoabModal > ) ;
3636 const modal = baseElement . querySelector ( "goa-modal" ) ;
3737 const actionContent = modal ?. querySelector ( "[slot='actions']" ) ;
38- const heading = modal ?. querySelector ( "[slot='heading']" ) ;
3938 // Role attribute is no longer passed to the web component (deprecated)
4039 expect ( modal ?. getAttribute ( "role" ) ) . toBeNull ( ) ;
4140
42- expect ( heading ?. textContent ) . toContain ( "Modal Heading" ) ;
41+ expect ( modal ?. getAttribute ( "heading" ) ) . toBe ( "Modal Heading" ) ;
4342 expect ( modal ?. getAttribute ( "open" ) ) . toBe ( "true" ) ;
4443 expect ( modal ?. getAttribute ( "maxwidth" ) ) . toBe ( "500px" ) ;
4544 expect ( modal ?. getAttribute ( "closable" ) ) . toBe ( "true" ) ;
4645 expect ( modal ?. textContent ) . toContain ( "Modal Content" ) ;
4746 expect ( actionContent ?. textContent ) . toContain ( "Close" ) ;
4847 } ) ;
48+
49+ it ( "should render with React node heading" , async ( ) => {
50+ const headingNode = < div > Custom Heading</ div > ;
51+ const { baseElement } = render (
52+ < GoabModal open heading = { headingNode } >
53+ Modal Content
54+ </ GoabModal > ,
55+ ) ;
56+
57+ const modal = baseElement . querySelector ( "goa-modal" ) ;
58+ const headingContent = modal ?. querySelector ( "[slot='heading']" ) ;
59+
60+ expect ( modal ?. getAttribute ( "open" ) ) . toBe ( "true" ) ;
61+ expect ( headingContent ?. textContent ) . toBe ( "Custom Heading" ) ;
62+ } ) ;
4963} ) ;
0 commit comments