Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BulotF committed Jan 24, 2024
1 parent e17a8e1 commit df9785c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/reducers/errors/errors-visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const actionHandlers = {};
export function addVisualizationError(state, { error }) {
return {
...state,
showErrorVisualizationPopup: error.message,
showErrorVisualizationPopup: error?.message,
};
}

Expand Down
34 changes: 24 additions & 10 deletions src/reducers/errors/errors-visualization.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,37 @@ import {

describe('addVisualizationError', () => {
test('when called directly', () => {
const result = addVisualizationError({
showErrorVisualizationPopup: false,
});
const result = addVisualizationError(
{
showErrorVisualizationPopup: '',
},
{
error: {
message: 'visualisation error message',
},
},
);
expect(result).toEqual({
showErrorVisualizationPopup: true,
showErrorVisualizationPopup: 'visualisation error message',
});
});
[ADD_VISUALIZATION_ERROR].forEach(action => {
test(`when called when we trigger ${action}`, () => {
const result = actionsHandlers(
{
showErrorVisualizationPopup: false,
showErrorVisualizationPopup: '',
},
{
type: action,
payload: {
error: {
message: 'handler visualisation error message',
},
},
},
);
expect(result).toEqual({
showErrorVisualizationPopup: true,
showErrorVisualizationPopup: 'handler visualisation error message',
});
});
});
Expand All @@ -37,24 +49,26 @@ describe('addVisualizationError', () => {
describe('removeVisualizationError', () => {
test('when called directly', () => {
const result = removeVisualizationError({
showErrorVisualizationPopup: true,
showErrorVisualizationPopup:
'il y a quelque chose de pourri au royaume de Danemark',
});
expect(result).toEqual({
showErrorVisualizationPopup: false,
showErrorVisualizationPopup: '',
});
});
[REMOVE_VISUALIZATION_ERROR].forEach(action => {
test(`when called when we trigger ${action}`, () => {
const result = actionsHandlers(
{
showErrorVisualizationPopup: true,
showErrorVisualizationPopup:
'il y a quelque chose de pourri au royaume de Danemark',
},
{
type: action,
},
);
expect(result).toEqual({
showErrorVisualizationPopup: false,
showErrorVisualizationPopup: '',
});
});
});
Expand Down

0 comments on commit df9785c

Please sign in to comment.