From 22a9001e693e9774449920073aaa1d5983690847 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Thu, 13 Jan 2022 09:42:11 +0100 Subject: [PATCH] Mock API, not module. Signed-off-by: Eric Peterson --- .../SearchModal/SearchModal.test.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/plugins/search/src/components/SearchModal/SearchModal.test.tsx b/plugins/search/src/components/SearchModal/SearchModal.test.tsx index d3209f9a9b..b59be710de 100644 --- a/plugins/search/src/components/SearchModal/SearchModal.test.tsx +++ b/plugins/search/src/components/SearchModal/SearchModal.test.tsx @@ -24,16 +24,10 @@ import { rootRouteRef } from '../../plugin'; import { searchApiRef } from '../../apis'; import { SearchModal } from './SearchModal'; - -jest.mock('../SearchContext', () => ({ - ...jest.requireActual('../SearchContext'), - useSearch: jest.fn().mockReturnValue({ - result: {}, - }), -})); +import { SearchContextProvider } from '../SearchContext'; describe('SearchModal', () => { - const query = jest.fn().mockResolvedValue({}); + const query = jest.fn().mockResolvedValue({ results: [] }); const apiRegistry = TestApiRegistry.from( [configApiRef, new ConfigReader({ app: { title: 'Mock app' } })], @@ -45,7 +39,9 @@ describe('SearchModal', () => { it('Should render the Modal correctly', async () => { await renderInTestApp( - + + + , { mountedRoutes: { @@ -60,7 +56,9 @@ describe('SearchModal', () => { it('Calls toggleModal handler', async () => { await renderInTestApp( - + + + , { mountedRoutes: {