Fix javascript tests

This commit is contained in:
Sonny Bakker 2024-08-26 09:33:00 +02:00
parent 284f64d202
commit f5f7f99f71

View file

@ -39,14 +39,14 @@ export const categories = (state = { ...defaultState }, action) => {
case REQUEST_CATEGORY: case REQUEST_CATEGORY:
return { ...state, isFetching: true }; return { ...state, isFetching: true };
case MARK_POST_READ: case MARK_POST_READ:
let category = {}; let postCategory = {};
switch (action.section.type) { switch (action.section.type) {
case CATEGORY_TYPE: case CATEGORY_TYPE:
category = { ...state.items[action.section.id] }; postCategory = { ...state.items[action.section.id] };
break; break;
case RULE_TYPE: case RULE_TYPE:
category = { ...state.items[action.section.category] }; postCategory = { ...state.items[action.section.category] };
break; break;
} }
@ -54,33 +54,33 @@ export const categories = (state = { ...defaultState }, action) => {
...state, ...state,
items: { items: {
...state.items, ...state.items,
[category.id]: { ...category, unread: category.unread - 1 }, [postCategory.id]: { ...postCategory, unread: postCategory.unread - 1 },
}, },
}; };
case MARK_SECTION_READ: case MARK_SECTION_READ:
category = {}; let sectionCategory = {};
switch (action.section.type) { switch (action.section.type) {
case CATEGORY_TYPE: case CATEGORY_TYPE:
category = { ...state.items[action.section.id] }; sectionCategory = { ...state.items[action.section.id] };
return { return {
...state, ...state,
items: { items: {
...state.items, ...state.items,
[category.id]: { ...category, unread: 0 }, [sectionCategory.id]: { ...sectionCategory, unread: 0 },
}, },
}; };
case RULE_TYPE: case RULE_TYPE:
category = { ...state.items[action.section.category] }; sectionCategory = { ...state.items[action.section.category] };
return { return {
...state, ...state,
items: { items: {
...state.items, ...state.items,
[category.id]: { [sectionCategory.id]: {
...category, ...sectionCategory,
unread: category.unread - action.section.unread, unread: sectionCategory.unread - action.section.unread,
}, },
}, },
}; };