Commit ecb43f74 authored by Hannah Stepanek's avatar Hannah Stepanek

Add abililty to clear groups in store

This is needed to be able to clear the group state when logging
out and logging in.
parent 2ddb5369
......@@ -55,10 +55,23 @@ const update = {
groups: action.groups,
};
},
CLEAR_GROUPS() {
return {
focusedGroupId: null,
groups: [],
};
},
};
const actions = util.actionTypes(update);
function clearGroups() {
return {
type: actions.CLEAR_GROUPS,
};
}
/**
* Set the current focused group.
*
......@@ -184,6 +197,7 @@ module.exports = {
actions: {
focusGroup,
loadGroups,
clearGroups,
},
selectors: {
allGroups,
......
......@@ -127,6 +127,25 @@ describe('sidebar.store.modules.groups', () => {
});
});
describe('clearGroups', () => {
it('clears the list of groups', () => {
store.loadGroups([publicGroup]);
store.clearGroups();
assert.equal(store.getState().groups.length, 0);
});
it('clears the focused group id', () => {
store.loadGroups([publicGroup]);
store.focusGroup(publicGroup.id);
store.clearGroups();
assert.equal(store.getState().focusedGroupId, null);
});
});
describe('allGroups', () => {
it('returns all groups', () => {
store.loadGroups([publicGroup, privateGroup]);
......
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