Skip to content

Commit c5855a1

Browse files
committed
fix: toolbar test
1 parent b7ffeda commit c5855a1

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/app-layout/__tests__/toolbar.test.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
import React from 'react';
4+
import { waitFor } from '@testing-library/react';
45

56
import AppLayout from '../../../lib/components/app-layout';
67
import SplitPanel from '../../../lib/components/split-panel';
@@ -16,14 +17,16 @@ describe('toolbar mode only features', () => {
1617
expect(wrapper.findToolbar()).toBeFalsy();
1718
});
1819

19-
test('renders toggle buttons when drawers are closed', () => {
20+
test('renders toggle buttons when drawers are closed', async () => {
2021
const { wrapper } = renderComponent(
2122
<AppLayout navigationOpen={false} toolsOpen={false} onNavigationChange={noop} onToolsChange={noop} />
2223
);
2324
expect(wrapper.findActiveDrawer()).toBeNull();
2425
expect(wrapper.findToolbar()).toBeTruthy();
2526
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+
});
2730
});
2831

2932
test('renders navigation toggle button for open state', () => {
@@ -32,15 +35,17 @@ describe('toolbar mode only features', () => {
3235
expect(wrapper.findNavigationToggle()).toBeTruthy();
3336
});
3437

35-
test('renders toolbar with split panel trigger', () => {
38+
test('renders toolbar with split panel trigger', async () => {
3639
const { wrapper } = renderComponent(
3740
<AppLayout splitPanel={<SplitPanel header="Testing">Dummy for testing</SplitPanel>} />
3841
);
3942
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+
});
4146
});
4247

43-
test('renders toolbar with split panel trigger in active state', () => {
48+
test('renders toolbar with split panel trigger in active state', async () => {
4449
const { wrapper } = renderComponent(
4550
<AppLayout
4651
splitPanelOpen={true}
@@ -49,7 +54,9 @@ describe('toolbar mode only features', () => {
4954
/>
5055
);
5156
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+
});
5360
expect(wrapper.findSplitPanelOpenButton()!.getElement()).toHaveAttribute('aria-expanded', 'true');
5461
});
5562

0 commit comments

Comments
 (0)