UNPKG

@finos/legend-application-marketplace

Version:
56 lines 3.63 kB
import { jsx as _jsx } from "react/jsx-runtime"; /** * Copyright (c) 2020-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { render, waitFor } from '@testing-library/react'; import {} from '@finos/legend-shared'; import { createMock, createSpy } from '@finos/legend-shared/test'; import { ApplicationStore, ApplicationStoreProvider, } from '@finos/legend-application'; import { TEST__BrowserEnvironmentProvider } from '@finos/legend-application/test'; import { LegendMarketplaceBaseStore, } from '../../stores/LegendMarketplaceBaseStore.js'; import { LEGEND_MARKETPLACE_TEST_ID } from '../../__lib__/LegendMarketplaceTesting.js'; import { LegendMarketplacePluginManager } from '../../application/LegendMarketplacePluginManager.js'; import { Core_LegendMarketplaceApplicationPlugin } from '../../application/extensions/Core_LegendMarketplaceApplicationPlugin.js'; import { TEST__getTestLegendMarketplaceApplicationConfig } from '../../application/__test-utils__/LegendMarketplaceApplicationTestUtils.js'; import { LegendMarketplaceFrameworkProvider } from '../../application/LegendMarketplaceFrameworkProvider.js'; import searchResults from './TEST_DATA__SearchResults.json' with { type: 'json' }; import { LegendMarketplaceWebApplicationRouter } from '../../application/LegendMarketplaceWebApplication.js'; export const TEST__provideMockedLegendMarketplaceBaseStore = async (customization) => { const pluginManager = customization?.pluginManager ?? LegendMarketplacePluginManager.create(); pluginManager .usePlugins([ new Core_LegendMarketplaceApplicationPlugin(), ...(customization?.extraPlugins ?? []), ]) .usePresets([...(customization?.extraPresets ?? [])]) .install(); const applicationStore = customization?.applicationStore ?? new ApplicationStore(TEST__getTestLegendMarketplaceApplicationConfig(), pluginManager); const value = customization?.mock ?? new LegendMarketplaceBaseStore(applicationStore); const MOCK__LegendMarketplaceBaseStoreProvider = require('../../application/LegendMarketplaceFrameworkProvider.js'); // eslint-disable-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-require-imports MOCK__LegendMarketplaceBaseStoreProvider.useLegendMarketplaceBaseStore = createMock(); MOCK__LegendMarketplaceBaseStoreProvider.useLegendMarketplaceBaseStore.mockReturnValue(value); return value; }; export const TEST__setUpMarketplace = async (MOCK__store, route) => { createSpy(MOCK__store.marketplaceServerClient, 'semanticSearch').mockResolvedValue(searchResults); const renderResult = render(_jsx(ApplicationStoreProvider, { store: MOCK__store.applicationStore, children: _jsx(TEST__BrowserEnvironmentProvider, { initialEntries: [route ?? '/'], children: _jsx(LegendMarketplaceFrameworkProvider, { children: _jsx(LegendMarketplaceWebApplicationRouter, {}) }) }) })); await waitFor(() => renderResult.getByTestId(LEGEND_MARKETPLACE_TEST_ID.HEADER)); return { renderResult, }; }; //# sourceMappingURL=LegendMarketplaceStoreTestUtils.js.map