diff --git a/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_breadcrumbs.test.tsx b/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_breadcrumbs.test.tsx index c166057df0304..8407fd8764196 100644 --- a/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_breadcrumbs.test.tsx +++ b/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_breadcrumbs.test.tsx @@ -5,8 +5,8 @@ * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; -import React, { ReactNode } from 'react'; +import { renderHook } from '@testing-library/react'; +import React from 'react'; import { MemoryRouter } from 'react-router-dom'; import { CoreStart } from '@kbn/core/public'; import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public'; @@ -28,7 +28,7 @@ const kibanaServices = { } as unknown as Partial; const KibanaContext = createKibanaReactContext(kibanaServices); -function Wrapper({ children }: { children?: ReactNode }) { +function Wrapper({ children }: React.PropsWithChildren) { return ( {children} @@ -38,18 +38,20 @@ function Wrapper({ children }: { children?: ReactNode }) { describe('useBreadcrumbs', () => { afterEach(() => { - setBreadcrumbs.mockClear(); - setTitle.mockClear(); + jest.clearAllMocks(); }); describe('when setBreadcrumbs and setTitle are not defined', () => { it('does not set breadcrumbs or the title', () => { renderHook(() => useBreadcrumbs([]), { - wrapper: ({ children }: React.PropsWithChildren<{}>) => ( + wrapper: ({ children }: React.PropsWithChildren) => ( + { + ...kibanaServices, + chrome: { ...kibanaServices.chrome, docTitle: {}, setBreadcrumbs: null }, + } as unknown as Partial } > {children} diff --git a/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_breadcrumbs.ts b/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_breadcrumbs.ts index 5c9c0d3981bb0..81ee8857e03f4 100644 --- a/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_breadcrumbs.ts +++ b/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_breadcrumbs.ts @@ -97,7 +97,7 @@ export const useBreadcrumbs = ( const setBreadcrumbs = useMemo(() => { if (!serverless?.setBreadcrumbs) { return (breadcrumbs: ChromeBreadcrumb[]) => - chromeSetBreadcrumbs( + chromeSetBreadcrumbs?.( breadcrumbs, !classicOnly ? { diff --git a/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_link_props.test.tsx b/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_link_props.test.tsx index 69ad845939e49..4c6a4f4a06ff0 100644 --- a/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_link_props.test.tsx +++ b/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_link_props.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { renderHook } from '@testing-library/react-hooks'; +import { renderHook } from '@testing-library/react'; import { createMemoryHistory } from 'history'; import React, { PropsWithChildren } from 'react'; import { Router } from '@kbn/shared-ux-router';