summaryrefslogtreecommitdiff
path: root/spec/frontend/frequent_items/store/mutations_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/frequent_items/store/mutations_spec.js')
-rw-r--r--spec/frontend/frequent_items/store/mutations_spec.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/frontend/frequent_items/store/mutations_spec.js b/spec/frontend/frequent_items/store/mutations_spec.js
index e593c9fae58..1e1878c3377 100644
--- a/spec/frontend/frequent_items/store/mutations_spec.js
+++ b/spec/frontend/frequent_items/store/mutations_spec.js
@@ -44,6 +44,18 @@ describe('Frequent Items dropdown mutations', () => {
});
});
+ describe('TOGGLE_ITEMS_LIST_EDITABILITY', () => {
+ it('should toggle items list editablity', () => {
+ mutations[types.TOGGLE_ITEMS_LIST_EDITABILITY](stateCopy);
+
+ expect(stateCopy.isItemsListEditable).toEqual(true);
+
+ mutations[types.TOGGLE_ITEMS_LIST_EDITABILITY](stateCopy);
+
+ expect(stateCopy.isItemsListEditable).toEqual(false);
+ });
+ });
+
describe('REQUEST_FREQUENT_ITEMS', () => {
it('should set view states when requesting frequent items', () => {
mutations[types.REQUEST_FREQUENT_ITEMS](stateCopy);
@@ -114,4 +126,27 @@ describe('Frequent Items dropdown mutations', () => {
expect(stateCopy.isFetchFailed).toEqual(true);
});
});
+
+ describe('RECEIVE_REMOVE_FREQUENT_ITEM_SUCCESS', () => {
+ it('should remove item with provided itemId from the items', () => {
+ stateCopy.isItemRemovalFailed = true;
+ stateCopy.items = mockFrequentProjects;
+
+ mutations[types.RECEIVE_REMOVE_FREQUENT_ITEM_SUCCESS](stateCopy, mockFrequentProjects[0].id);
+
+ expect(stateCopy.items).toHaveLength(mockFrequentProjects.length - 1);
+ expect(stateCopy.items).toEqual([...mockFrequentProjects.slice(1)]);
+ expect(stateCopy.isItemRemovalFailed).toBe(false);
+ });
+ });
+
+ describe('RECEIVE_REMOVE_FREQUENT_ITEM_ERROR', () => {
+ it('should remove item with provided itemId from the items', () => {
+ stateCopy.isItemRemovalFailed = false;
+
+ mutations[types.RECEIVE_REMOVE_FREQUENT_ITEM_ERROR](stateCopy);
+
+ expect(stateCopy.isItemRemovalFailed).toBe(true);
+ });
+ });
});