From 60063d0fca8da2efaa763aedbb8e286b4c57c4eb Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Fri, 28 May 2021 09:12:08 -0500 Subject: [PATCH] Test unmounting and calling with undefined --- .../components/shared/header_menu_portal.test.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/observability/public/components/shared/header_menu_portal.test.tsx b/x-pack/plugins/observability/public/components/shared/header_menu_portal.test.tsx index 6700e52788a3a..4e9a1ae2c587f 100644 --- a/x-pack/plugins/observability/public/components/shared/header_menu_portal.test.tsx +++ b/x-pack/plugins/observability/public/components/shared/header_menu_portal.test.tsx @@ -10,13 +10,17 @@ import React from 'react'; import HeaderMenuPortal from './header_menu_portal'; describe('HeaderMenuPortal', () => { - describe('render', () => { - it('sets the header action menu', () => { + describe('when unmounted', () => { + it('calls setHeaderActionMenu with undefined', () => { const setHeaderActionMenu = jest.fn(); - render(test); + const { unmount } = render( + test + ); - expect(setHeaderActionMenu).toHaveBeenCalled(); + unmount(); + + expect(setHeaderActionMenu).toHaveBeenCalledWith(undefined); }); }); });