1
1
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
import React from 'react' ;
4
+ import { waitFor } from '@testing-library/react' ;
4
5
5
6
import AppLayout from '../../../lib/components/app-layout' ;
6
7
import SplitPanel from '../../../lib/components/split-panel' ;
@@ -16,14 +17,16 @@ describe('toolbar mode only features', () => {
16
17
expect ( wrapper . findToolbar ( ) ) . toBeFalsy ( ) ;
17
18
} ) ;
18
19
19
- test ( 'renders toggle buttons when drawers are closed' , ( ) => {
20
+ test ( 'renders toggle buttons when drawers are closed' , async ( ) => {
20
21
const { wrapper } = renderComponent (
21
22
< AppLayout navigationOpen = { false } toolsOpen = { false } onNavigationChange = { noop } onToolsChange = { noop } />
22
23
) ;
23
24
expect ( wrapper . findActiveDrawer ( ) ) . toBeNull ( ) ;
24
25
expect ( wrapper . findToolbar ( ) ) . toBeTruthy ( ) ;
25
26
expect ( wrapper . findToolbar ( ) ! . getElement ( ) ) . toContainElement ( wrapper . findNavigationToggle ( ) ! . getElement ( ) ) ;
26
- expect ( wrapper . findToolbar ( ) ! . getElement ( ) ) . toContainElement ( wrapper . findToolsToggle ( ) ! . getElement ( ) ) ;
27
+ await waitFor ( ( ) => {
28
+ expect ( wrapper . findToolbar ( ) ! . getElement ( ) ) . toContainElement ( wrapper . findToolsToggle ( ) ! . getElement ( ) ) ;
29
+ } ) ;
27
30
} ) ;
28
31
29
32
test ( 'renders navigation toggle button for open state' , ( ) => {
@@ -32,15 +35,17 @@ describe('toolbar mode only features', () => {
32
35
expect ( wrapper . findNavigationToggle ( ) ) . toBeTruthy ( ) ;
33
36
} ) ;
34
37
35
- test ( 'renders toolbar with split panel trigger' , ( ) => {
38
+ test ( 'renders toolbar with split panel trigger' , async ( ) => {
36
39
const { wrapper } = renderComponent (
37
40
< AppLayout splitPanel = { < SplitPanel header = "Testing" > Dummy for testing</ SplitPanel > } />
38
41
) ;
39
42
expect ( wrapper . findToolbar ( ) ) . toBeTruthy ( ) ;
40
- expect ( wrapper . findToolbar ( ) ! . getElement ( ) ) . toContainElement ( wrapper . findSplitPanelOpenButton ( ) ! . getElement ( ) ) ;
43
+ await waitFor ( ( ) => {
44
+ expect ( wrapper . findToolbar ( ) ! . getElement ( ) ) . toContainElement ( wrapper . findSplitPanelOpenButton ( ) ! . getElement ( ) ) ;
45
+ } ) ;
41
46
} ) ;
42
47
43
- test ( 'renders toolbar with split panel trigger in active state' , ( ) => {
48
+ test ( 'renders toolbar with split panel trigger in active state' , async ( ) => {
44
49
const { wrapper } = renderComponent (
45
50
< AppLayout
46
51
splitPanelOpen = { true }
@@ -49,7 +54,9 @@ describe('toolbar mode only features', () => {
49
54
/>
50
55
) ;
51
56
expect ( wrapper . findToolbar ( ) ) . toBeTruthy ( ) ;
52
- expect ( wrapper . findToolbar ( ) ! . getElement ( ) ) . toContainElement ( wrapper . findSplitPanelOpenButton ( ) ! . getElement ( ) ) ;
57
+ await waitFor ( ( ) => {
58
+ expect ( wrapper . findToolbar ( ) ! . getElement ( ) ) . toContainElement ( wrapper . findSplitPanelOpenButton ( ) ! . getElement ( ) ) ;
59
+ } ) ;
53
60
expect ( wrapper . findSplitPanelOpenButton ( ) ! . getElement ( ) ) . toHaveAttribute ( 'aria-expanded' , 'true' ) ;
54
61
} ) ;
55
62
0 commit comments