Unverified Commit d86d2ba1 authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #1111 from hypothesis/add-clear-groups

Add abililty to clear groups in store
parents 2ddb5369 ecb43f74
......@@ -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