Skip to content

Commit 95f329b

Browse files
authored
chore: Test that unmountContent is called when app layout is unmounted (#3040)
1 parent ea46162 commit 95f329b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/app-layout/__tests__/runtime-drawers.test.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,23 @@ describeEachAppLayout(({ theme, size }) => {
623623
expect(unmountContent).toHaveBeenCalledTimes(1);
624624
});
625625

626+
test('calls unmountContent when the whole app layout unmounts', async () => {
627+
const mountContent = jest.fn();
628+
const unmountContent = jest.fn();
629+
awsuiPlugins.appLayout.registerDrawer({
630+
...drawerDefaults,
631+
mountContent,
632+
unmountContent,
633+
});
634+
const { wrapper, rerender } = await renderComponent(<AppLayout />);
635+
expect(mountContent).toHaveBeenCalledTimes(0);
636+
wrapper.findDrawerTriggerById(drawerDefaults.id)!.click();
637+
expect(mountContent).toHaveBeenCalledTimes(1);
638+
expect(unmountContent).toHaveBeenCalledTimes(0);
639+
rerender(<></>);
640+
expect(unmountContent).toHaveBeenCalledTimes(1);
641+
});
642+
626643
// skip these tests on mobile mode, because triggers will overflow
627644
(size === 'desktop' ? describe : describe.skip)('ordering', () => {
628645
test('renders multiple drawers in alphabetical order by default', async () => {

0 commit comments

Comments
 (0)