10
10
* See the License for the specific language governing permissions and limitations under the License.
11
11
*/
12
12
13
- import { act } from "@testing-library/react" ;
13
+ import { act , waitFor } from "@testing-library/react" ;
14
14
15
15
import { renderUiShell } from "./renderUiShell" ;
16
16
import {
@@ -126,9 +126,11 @@ describe("renderUiShell", () => {
126
126
} ) ;
127
127
} ) ;
128
128
129
- expect (
130
- rootElement . querySelector ( reactWebComponentElementName ) ! . shadowRoot ,
131
- ) . toHaveTextContent ( appName ) ;
129
+ await waitFor ( ( ) => {
130
+ expect (
131
+ rootElement . querySelector ( reactWebComponentElementName ) ! . shadowRoot ,
132
+ ) . toHaveTextContent ( appName ) ;
133
+ } ) ;
132
134
} ) ;
133
135
134
136
test ( "renders `UiShell` with immediately updated props" , async ( ) => {
@@ -153,9 +155,11 @@ describe("renderUiShell", () => {
153
155
} ) ;
154
156
} ) ;
155
157
156
- expect (
157
- rootElement . querySelector ( reactWebComponentElementName ) ! . shadowRoot ,
158
- ) . toHaveTextContent ( appName ) ;
158
+ await waitFor ( ( ) => {
159
+ expect (
160
+ rootElement . querySelector ( reactWebComponentElementName ) ! . shadowRoot ,
161
+ ) . toHaveTextContent ( appName ) ;
162
+ } ) ;
159
163
} ) ;
160
164
161
165
test ( "renders `<slot>` in the event of an error" , async ( ) => {
@@ -184,14 +188,16 @@ describe("renderUiShell", () => {
184
188
) ;
185
189
} ) ;
186
190
187
- consoleErrorSpy . mockRestore ( ) ;
191
+ await waitFor ( ( ) => {
192
+ expect ( onError ) . toHaveBeenCalledTimes ( 1 ) ;
193
+ expect ( consoleError ) . toHaveBeenCalledTimes ( 1 ) ;
194
+ expect (
195
+ rootElement
196
+ . querySelector ( reactWebComponentElementName ) !
197
+ . shadowRoot ?. querySelector ( "slot" ) ,
198
+ ) . toBeInstanceOf ( HTMLSlotElement ) ;
199
+ } ) ;
188
200
189
- expect ( onError ) . toHaveBeenCalledTimes ( 1 ) ;
190
- expect ( consoleError ) . toHaveBeenCalledTimes ( 1 ) ;
191
- expect (
192
- rootElement
193
- . querySelector ( reactWebComponentElementName ) !
194
- . shadowRoot ?. querySelector ( "slot" ) ,
195
- ) . toBeInstanceOf ( HTMLSlotElement ) ;
201
+ consoleErrorSpy . mockRestore ( ) ;
196
202
} ) ;
197
203
} ) ;
0 commit comments