File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
packages/react-from-markup/src/__tests__ Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -13,3 +13,14 @@ exports[`reactFromMarkupContainer E2E tests Should rehydrate valid HTML markup 1
1313 <p>paragraph</p>
1414 </div>"
1515`;
16+
17+ exports[`reactFromMarkupContainer E2E tests Should work for nested markup containers 1`] = `
18+ "
19+ <div data-react-from-markup-container=\\" \\">
20+ <span>rehydrated component</span>
21+ <div data-react-from-markup-container =\\"\\">
22+ <span>rehydrated component</span>
23+ <span>rehydrated component</span>
24+ </div>
25+ </div>"
26+ `;
Original file line number Diff line number Diff line change @@ -37,4 +37,39 @@ describe("reactFromMarkupContainer E2E tests", async () => {
3737
3838 expect ( documentElement . innerHTML ) . toMatchSnapshot ( ) ;
3939 } ) ;
40+
41+ it ( "Should work for nested markup containers" , async ( ) => {
42+ const componentName : string = "mycomponentName" ;
43+
44+ const mockCall = jest . fn ( ) ;
45+ const rehydrators = {
46+ [ componentName ] : async ( ) => {
47+ mockCall ( ) ;
48+
49+ return React . createElement ( "span" , { } , "rehydrated component" ) ;
50+ }
51+ } ;
52+
53+ const documentElement = document . createElement ( "div" ) ;
54+
55+ documentElement . innerHTML = `
56+ <div data-react-from-markup-container>
57+ <div data-rehydratable="${ componentName } "></div>
58+ <div data-react-from-markup-container>
59+ <div data-rehydratable="${ componentName } ">
60+ <div data-react-from-markup-container>
61+ <div data-rehydratable="${ componentName } "></div>
62+ </div>
63+ </div>
64+ <div data-rehydratable="${ componentName } "></div>
65+ </div>
66+ </div>` ;
67+
68+ await reactFromMarkupContainer ( documentElement , rehydrators , {
69+ extra : { }
70+ } ) ;
71+
72+ expect ( documentElement . innerHTML ) . toMatchSnapshot ( ) ;
73+ expect ( mockCall ) . toBeCalledTimes ( 3 ) ;
74+ } ) ;
4075} ) ;
You can’t perform that action at this time.
0 commit comments