@@ -77,12 +77,16 @@ describe('rendering React components at document', () => {
77
77
await act ( ( ) => {
78
78
root = ReactDOMClient . hydrateRoot ( testDocument , < Root hello = "world" /> ) ;
79
79
} ) ;
80
- expect ( testDocument . body . innerHTML ) . toBe ( 'Hello world' ) ;
80
+ expect ( testDocument . body . innerHTML ) . toBe (
81
+ 'Hello world' + '<template id="«R»"></template>' ,
82
+ ) ;
81
83
82
84
await act ( ( ) => {
83
85
root . render ( < Root hello = "moon" /> ) ;
84
86
} ) ;
85
- expect ( testDocument . body . innerHTML ) . toBe ( 'Hello moon' ) ;
87
+ expect ( testDocument . body . innerHTML ) . toBe (
88
+ 'Hello moon' + '<template id="«R»"></template>' ,
89
+ ) ;
86
90
87
91
expect ( body === testDocument . body ) . toBe ( true ) ;
88
92
} ) ;
@@ -107,7 +111,9 @@ describe('rendering React components at document', () => {
107
111
await act ( ( ) => {
108
112
root = ReactDOMClient . hydrateRoot ( testDocument , < Root /> ) ;
109
113
} ) ;
110
- expect ( testDocument . body . innerHTML ) . toBe ( 'Hello world' ) ;
114
+ expect ( testDocument . body . innerHTML ) . toBe (
115
+ 'Hello world' + '<template id="«R»"></template>' ,
116
+ ) ;
111
117
112
118
const originalDocEl = testDocument . documentElement ;
113
119
const originalHead = testDocument . head ;
@@ -118,8 +124,10 @@ describe('rendering React components at document', () => {
118
124
expect ( testDocument . firstChild ) . toBe ( originalDocEl ) ;
119
125
expect ( testDocument . head ) . toBe ( originalHead ) ;
120
126
expect ( testDocument . body ) . toBe ( originalBody ) ;
121
- expect ( originalBody . firstChild ) . toEqual ( null ) ;
122
- expect ( originalHead . firstChild ) . toEqual ( null ) ;
127
+ expect ( originalBody . innerHTML ) . toBe ( '<template id="«R»"></template>' ) ;
128
+ expect ( originalHead . innerHTML ) . toBe (
129
+ '<link rel="expect" href="#«R»" blocking="render">' ,
130
+ ) ;
123
131
} ) ;
124
132
125
133
it ( 'should not be able to switch root constructors' , async ( ) => {
@@ -157,13 +165,17 @@ describe('rendering React components at document', () => {
157
165
root = ReactDOMClient . hydrateRoot ( testDocument , < Component /> ) ;
158
166
} ) ;
159
167
160
- expect ( testDocument . body . innerHTML ) . toBe ( 'Hello world' ) ;
168
+ expect ( testDocument . body . innerHTML ) . toBe (
169
+ 'Hello world' + '<template id="«R»"></template>' ,
170
+ ) ;
161
171
162
172
await act ( ( ) => {
163
173
root . render ( < Component2 /> ) ;
164
174
} ) ;
165
175
166
- expect ( testDocument . body . innerHTML ) . toBe ( 'Goodbye world' ) ;
176
+ expect ( testDocument . body . innerHTML ) . toBe (
177
+ '<template id="«R»"></template>' + 'Goodbye world' ,
178
+ ) ;
167
179
} ) ;
168
180
169
181
it ( 'should be able to mount into document' , async ( ) => {
@@ -192,7 +204,9 @@ describe('rendering React components at document', () => {
192
204
) ;
193
205
} ) ;
194
206
195
- expect ( testDocument . body . innerHTML ) . toBe ( 'Hello world' ) ;
207
+ expect ( testDocument . body . innerHTML ) . toBe (
208
+ 'Hello world' + '<template id="«R»"></template>' ,
209
+ ) ;
196
210
} ) ;
197
211
198
212
it ( 'cannot render over an existing text child at the root' , async ( ) => {
@@ -325,7 +339,9 @@ describe('rendering React components at document', () => {
325
339
: [ ] ,
326
340
) ;
327
341
expect ( testDocument . body . innerHTML ) . toBe (
328
- favorSafetyOverHydrationPerf ? 'Hello world' : 'Goodbye world' ,
342
+ favorSafetyOverHydrationPerf
343
+ ? 'Hello world'
344
+ : 'Goodbye world<template id="«R»"></template>' ,
329
345
) ;
330
346
} ) ;
331
347
0 commit comments