Skip to content

Commit

Permalink
tests pass
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Pickering <[email protected]>
  • Loading branch information
alexvpickering committed Dec 3, 2024
1 parent 76f182e commit 3598f1b
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 45 deletions.
5 changes: 5 additions & 0 deletions __mocks__/@hms-dbmi/viv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
ZarrPixelSource: jest.fn(() => ({
// Define any methods used in your tests, if necessary.
})),
};
5 changes: 5 additions & 0 deletions __mocks__/@zarrita/storage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
ZipFileStore: jest.fn(() => ({
// Define any methods used in your tests, if necessary.
})),
};
5 changes: 5 additions & 0 deletions __mocks__/zarrita.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
root: jest.fn(() => ({
// Define any methods used in your tests, if necessary.
})),
};
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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$': '<rootDir>/__mocks__/@zarrita/storage.js',
'^zarrita$': '<rootDir>/__mocks__/zarrita.js',
'^@hms-dbmi/viv$': '<rootDir>/__mocks__/@hms-dbmi/viv.js',
},
moduleFileExtensions: [
'web.js',
Expand Down
3 changes: 2 additions & 1 deletion src/__test__/components/MosaicCloseButton.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);

Expand Down
7 changes: 0 additions & 7 deletions src/__test__/components/data-exploration/indexPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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');
});
});
4 changes: 1 addition & 3 deletions src/components/data-exploration/DynamicESMWrappers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

0 comments on commit 3598f1b

Please sign in to comment.