@@ -24,15 +24,6 @@ const storyTests: Record<string, (result: RenderResult) => void | Promise<void>>
2424 ) ;
2525 } ,
2626 'SwapNodesBetweenDifferentLocations' : async ( { container, getByText } ) => {
27- const html = container . innerHTML ;
28- const initialText = container . textContent || '' ;
29-
30- expect ( html ) . toContain ( '<span>0</span>' ) ;
31- expect ( html ) . toContain ( '<span>1</span>' ) ;
32- expect ( html ) . toContain ( '<span>2</span>' ) ;
33- expect ( html ) . toContain ( '<span>3</span>' ) ;
34- expect ( html ) . toContain ( '<span>4</span>' ) ;
35-
3627 const spans = container . querySelectorAll ( 'span' ) ;
3728 const order = Array . from ( spans ) . map ( span => span . textContent ) ;
3829 expect ( order ) . toEqual ( [ '0' , '1' , '2' , '3' , '4' ] ) ;
@@ -45,6 +36,47 @@ const storyTests: Record<string, (result: RenderResult) => void | Promise<void>>
4536 const orderAfter = Array . from ( spansAfter ) . map ( span => span . textContent ) ;
4637 expect ( orderAfter ) . toEqual ( [ '4' , '3' , '2' , '1' , '0' ] ) ;
4738 } ,
39+ 'CanPassAttributesOptionToCreateHtmlPortalNode' : async ( { container, getByText } ) => {
40+ expect ( container . querySelector ( '#div-id-1' ) ) . toBeNull ( ) ;
41+
42+ const divsWithBgColor = Array . from ( container . querySelectorAll ( 'div' ) ) . filter ( div =>
43+ div . getAttribute ( 'style' ) ?. includes ( 'background-color: #aaf' )
44+ ) ;
45+ expect ( divsWithBgColor ) . toHaveLength ( 0 ) ;
46+
47+ const button = getByText ( 'Click to pass attributes option to the intermediary div' ) ;
48+ button . click ( ) ;
49+ await wait ( 10 ) ;
50+
51+ const divWithId = container . querySelector ( '#div-id-1' ) ;
52+ expect ( divWithId ) . not . toBeNull ( ) ;
53+ expect ( divWithId ?. getAttribute ( 'style' ) ) . toContain ( 'background-color: #aaf' ) ;
54+ expect ( divWithId ?. getAttribute ( 'style' ) ) . toContain ( 'width: 204px' ) ;
55+ } ,
56+ 'PortalContainerElementAsTr' : async ( { container, getByText } ) => {
57+ const tables = container . querySelectorAll ( 'table' ) ;
58+ expect ( tables ) . toHaveLength ( 2 ) ;
59+
60+ const firstTableBody = tables [ 0 ] . querySelector ( 'tbody' ) ;
61+ const secondTableBody = tables [ 1 ] . querySelector ( 'tbody' ) ;
62+
63+ expect ( firstTableBody ?. innerHTML ) . toContain ( 'Cell 1' ) ;
64+ expect ( firstTableBody ?. innerHTML ) . toContain ( 'Cell 2' ) ;
65+ expect ( firstTableBody ?. innerHTML ) . toContain ( 'Cell 3' ) ;
66+ expect ( secondTableBody ?. innerHTML ) . not . toContain ( 'Cell 1' ) ;
67+
68+ const button = getByText ( 'Move row to second table' ) ;
69+ button . click ( ) ;
70+ await wait ( 10 ) ;
71+
72+ const firstTableBodyAfter = tables [ 0 ] . querySelector ( 'tbody' ) ;
73+ const secondTableBodyAfter = tables [ 1 ] . querySelector ( 'tbody' ) ;
74+
75+ expect ( firstTableBodyAfter ?. innerHTML ) . not . toContain ( 'Cell 1' ) ;
76+ expect ( secondTableBodyAfter ?. innerHTML ) . toContain ( 'Cell 1' ) ;
77+ expect ( secondTableBodyAfter ?. innerHTML ) . toContain ( 'Cell 2' ) ;
78+ expect ( secondTableBodyAfter ?. innerHTML ) . toContain ( 'Cell 3' ) ;
79+ } ,
4880} ;
4981
5082// Skipped for now, until we have full test coverage of the stories:
0 commit comments