Unverified Commit 656b4014 authored by Joram Wilander's avatar Joram Wilander Committed by GitHub
Browse files

Do not clobber reactions when dispatching RECEIVED_POST that has no reactions metadata (#774)

parent c174af2f
......@@ -606,7 +606,7 @@ export function reactions(state = {}, action) {
}
function storeReactionsForPost(state, post) {
if (!post.metadata) {
if (!post.metadata || !post.metadata.reactions) {
return state;
}
......
......@@ -614,7 +614,7 @@ describe('Reducers.posts', () => {
type: actionType,
data: {
id: 'post',
metadata: {},
metadata: {reactions: []},
},
};
......@@ -626,6 +626,23 @@ describe('Reducers.posts', () => {
});
});
it('should not clobber reactions when metadata empty', () => {
const state = deepFreeze({post: {name: 'smiley', post_id: 'post'}});
const action = {
type: actionType,
data: {
id: 'post',
metadata: {},
},
};
const nextState = reactionsReducer(state, action);
assert.deepEqual(nextState, {
post: {name: 'smiley', post_id: 'post'},
});
});
it('should save reactions', () => {
const state = deepFreeze({});
const action = {
......@@ -685,7 +702,7 @@ describe('Reducers.posts', () => {
posts: {
post: {
id: 'post',
metadata: {},
metadata: {reactions: []},
},
},
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment