Skip to content

Commit

Permalink
Merge pull request #758 from hms-dbmi-cellenics/hotfix-experimentsLoa…
Browse files Browse the repository at this point in the history
…ded-reducer

Hotfix experiments loaded reducer
  • Loading branch information
ivababukova authored Jul 5, 2022
2 parents 80e41e8 + ce58e5c commit 1ec9e3c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,18 @@ Object {
}
`;

exports[`experimentsReducer Loads 0 experiments correctly 1`] = `
Object {
"ids": Array [],
"meta": Object {
"activeExperimentId": undefined,
"error": false,
"loading": false,
"saving": false,
},
}
`;

exports[`experimentsReducer Loads an experiment correctly 1`] = `
Object {
"experiment-1": Object {
Expand Down
12 changes: 12 additions & 0 deletions src/__test__/redux/reducers/experimentsReducer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ describe('experimentsReducer', () => {
expect(newState).toMatchSnapshot();
});

it('Loads 0 experiments correctly', () => {
const newState = experimentsReducer(initialState, {
type: EXPERIMENTS_LOADED,
payload: {
experiments: [],
},
});
expect(newState.ids).toEqual([]);
expect(newState.meta.activeExperimentId).toEqual(undefined);
expect(newState).toMatchSnapshot();
});

it('Loading state changes meta state', () => {
const newState = experimentsReducer(initialState, {
type: EXPERIMENTS_LOADING,
Expand Down
2 changes: 1 addition & 1 deletion src/redux/reducers/experiments/experimentsLoaded.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const experimentsLoaded = produce((draft, action) => {

const ids = _.map(experiments, 'id');

draft.meta.activeExperimentId = experiments[0].id;
draft.meta.activeExperimentId = experiments[0]?.id;
draft.meta.loading = false;
draft.ids = ids;

Expand Down

0 comments on commit 1ec9e3c

Please sign in to comment.