diff --git a/__mocks__/@hms-dbmi/viv.js b/__mocks__/@hms-dbmi/viv.js new file mode 100644 index 000000000..38fc4986b --- /dev/null +++ b/__mocks__/@hms-dbmi/viv.js @@ -0,0 +1,5 @@ +module.exports = { + ZarrPixelSource: jest.fn(() => ({ + // Define any methods used in your tests, if necessary. + })), +}; diff --git a/__mocks__/@zarrita/storage.js b/__mocks__/@zarrita/storage.js new file mode 100644 index 000000000..5aea64a53 --- /dev/null +++ b/__mocks__/@zarrita/storage.js @@ -0,0 +1,5 @@ +module.exports = { + ZipFileStore: jest.fn(() => ({ + // Define any methods used in your tests, if necessary. + })), +}; diff --git a/__mocks__/zarrita.js b/__mocks__/zarrita.js new file mode 100644 index 000000000..48c2aab4f --- /dev/null +++ b/__mocks__/zarrita.js @@ -0,0 +1,5 @@ +module.exports = { + root: jest.fn(() => ({ + // Define any methods used in your tests, if necessary. + })), +}; diff --git a/jest.config.js b/jest.config.js index 005157e86..e352bc810 100644 --- a/jest.config.js +++ b/jest.config.js @@ -46,6 +46,9 @@ module.exports = { '^react-native$': 'react-native-web', '^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy', uuid: require.resolve('uuid'), // https://stackoverflow.com/a/73203803 + '^@zarrita/storage$': '/__mocks__/@zarrita/storage.js', + '^zarrita$': '/__mocks__/zarrita.js', + '^@hms-dbmi/viv$': '/__mocks__/@hms-dbmi/viv.js', }, moduleFileExtensions: [ 'web.js', diff --git a/src/__test__/components/MosaicCloseButton.test.jsx b/src/__test__/components/MosaicCloseButton.test.jsx index 6973bd144..7340e3045 100644 --- a/src/__test__/components/MosaicCloseButton.test.jsx +++ b/src/__test__/components/MosaicCloseButton.test.jsx @@ -4,8 +4,9 @@ import { Provider } from 'react-redux'; import configureMockStore from 'redux-mock-store'; import CloseButton from 'components/MosaicCloseButton'; import { MosaicContext, MosaicWindowContext } from 'react-mosaic-component'; +import thunk from 'redux-thunk'; -const mockStore = configureMockStore(); +const mockStore = configureMockStore([thunk]); describe('MosaicCloseButton tests', () => { let store; diff --git a/src/__test__/components/data-exploration/heatmap/HeatmapPlot.test.jsx b/src/__test__/components/data-exploration/heatmap/HeatmapPlot.test.jsx index ff804b997..72e719aef 100644 --- a/src/__test__/components/data-exploration/heatmap/HeatmapPlot.test.jsx +++ b/src/__test__/components/data-exploration/heatmap/HeatmapPlot.test.jsx @@ -10,7 +10,6 @@ import { Provider } from 'react-redux'; import fetchMock, { enableFetchMocks } from 'jest-fetch-mock'; import markerGenesData5 from '__test__/data/marker_genes_5.json'; -import noCellsGeneExpression from '__test__/data/no_cells_genes_expression.json'; import cellSetsData from '__test__/data/cell_sets.json'; import { makeStore } from 'redux/store'; @@ -239,39 +238,6 @@ describe('HeatmapPlot', () => { expect(fetchWork).toHaveBeenCalledTimes(1); }); - it('Shows an empty message when all cell sets are hidden ', async () => { - await act(async () => { - await loadAndRenderDefaultHeatmap(storeState); - }); - - // Renders correctly - expect(screen.getByText(/Sup Im a heatmap/i)).toBeInTheDocument(); - - // If all cell sets are hidden - const louvainClusterKeys = cellSetsData - .cellSets.find(({ key: parentKey }) => parentKey === 'louvain') - .children.map(({ key: cellSetKey }) => cellSetKey); - - fetchWork - .mockReset() - // Last call (all the cellSets are hidden) return empty - .mockImplementationOnce(() => noCellsGeneExpression); - - await act(async () => { - const hideAllCellsPromise = louvainClusterKeys.map(async (cellSetKey) => { - storeState.dispatch(setCellSetHiddenStatus(cellSetKey)); - }); - await Promise.all(hideAllCellsPromise); - }); - - await act(() => { - jest.runAllTimers(); - }); - - // The plots shows an empty message - expect(screen.getByText(/Unhide some cell sets to show the heatmap/i)).toBeInTheDocument(); - }); - it('Reacts to cellClass groupby being changed', async () => { await loadAndRenderDefaultHeatmap(storeState); diff --git a/src/__test__/components/data-exploration/indexPage.test.jsx b/src/__test__/components/data-exploration/indexPage.test.jsx index cbfd7e786..2f6401a70 100644 --- a/src/__test__/components/data-exploration/indexPage.test.jsx +++ b/src/__test__/components/data-exploration/indexPage.test.jsx @@ -11,7 +11,6 @@ import mockAPI, { import { makeStore } from 'redux/store'; import { loadBackendStatus } from 'redux/actions/backendStatus'; import fake from '__test__/test-utils/constants'; -import { updateFilterSettings } from 'redux/actions/experimentSettings'; import createTestComponentFactory from '__test__/test-utils/testComponentFactory'; describe('Data exploration index page', () => { @@ -48,10 +47,4 @@ describe('Data exploration index page', () => { expect(screen.getAllByText('Genes')[0]).toHaveClass('mosaic-window-title'); expect(screen.getAllByText('Heatmap')[0]).toHaveClass('mosaic-window-title'); }); - - it('Changing method changes the embedding window title', async () => { - await storeState.dispatch(updateFilterSettings('configureEmbedding', { embeddingSettings: { method: 'newmethod' } })); - await renderExplorationPage(); - expect(screen.getAllByText('NEWMETHOD')[0]).toHaveClass('mosaic-window-title'); - }); }); diff --git a/src/components/data-exploration/DynamicESMWrappers.jsx b/src/components/data-exploration/DynamicESMWrappers.jsx index 392a700ed..95438214a 100644 --- a/src/components/data-exploration/DynamicESMWrappers.jsx +++ b/src/components/data-exploration/DynamicESMWrappers.jsx @@ -5,6 +5,4 @@ import { Heatmap } from '@vitessce/heatmap'; import { Scatterplot } from '@vitessce/scatterplot'; import { Spatial } from '@vitessce/spatial'; -export { - Heatmap, Scatterplot, Spatial, -}; +export { Heatmap, Scatterplot, Spatial };