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 = { ...@@ -55,10 +55,23 @@ const update = {
groups: action.groups, groups: action.groups,
}; };
}, },
CLEAR_GROUPS() {
return {
focusedGroupId: null,
groups: [],
};
},
}; };
const actions = util.actionTypes(update); const actions = util.actionTypes(update);
function clearGroups() {
return {
type: actions.CLEAR_GROUPS,
};
}
/** /**
* Set the current focused group. * Set the current focused group.
* *
...@@ -184,6 +197,7 @@ module.exports = { ...@@ -184,6 +197,7 @@ module.exports = {
actions: { actions: {
focusGroup, focusGroup,
loadGroups, loadGroups,
clearGroups,
}, },
selectors: { selectors: {
allGroups, allGroups,
......
...@@ -127,6 +127,25 @@ describe('sidebar.store.modules.groups', () => { ...@@ -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', () => { describe('allGroups', () => {
it('returns all groups', () => { it('returns all groups', () => {
store.loadGroups([publicGroup, privateGroup]); 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