summaryrefslogtreecommitdiff
path: root/spec/frontend/whats_new/store/actions_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/whats_new/store/actions_spec.js')
-rw-r--r--spec/frontend/whats_new/store/actions_spec.js33
1 files changed, 32 insertions, 1 deletions
diff --git a/spec/frontend/whats_new/store/actions_spec.js b/spec/frontend/whats_new/store/actions_spec.js
index d95453c9175..95ab667d611 100644
--- a/spec/frontend/whats_new/store/actions_spec.js
+++ b/spec/frontend/whats_new/store/actions_spec.js
@@ -1,11 +1,19 @@
import testAction from 'helpers/vuex_action_helper';
+import { useLocalStorageSpy } from 'helpers/local_storage_helper';
+import MockAdapter from 'axios-mock-adapter';
+import waitForPromises from 'helpers/wait_for_promises';
import actions from '~/whats_new/store/actions';
import * as types from '~/whats_new/store/mutation_types';
+import axios from '~/lib/utils/axios_utils';
describe('whats new actions', () => {
describe('openDrawer', () => {
+ useLocalStorageSpy();
+
it('should commit openDrawer', () => {
- testAction(actions.openDrawer, {}, {}, [{ type: types.OPEN_DRAWER }]);
+ testAction(actions.openDrawer, 'storage-key', {}, [{ type: types.OPEN_DRAWER }]);
+
+ expect(window.localStorage.setItem).toHaveBeenCalledWith('storage-key', 'false');
});
});
@@ -14,4 +22,27 @@ describe('whats new actions', () => {
testAction(actions.closeDrawer, {}, {}, [{ type: types.CLOSE_DRAWER }]);
});
});
+
+ describe('fetchItems', () => {
+ let axiosMock;
+
+ beforeEach(async () => {
+ axiosMock = new MockAdapter(axios);
+ axiosMock
+ .onGet('/-/whats_new')
+ .replyOnce(200, [{ title: 'Whats New Drawer', url: 'www.url.com' }]);
+
+ await waitForPromises();
+ });
+
+ afterEach(() => {
+ axiosMock.restore();
+ });
+
+ it('should commit setFeatures', () => {
+ testAction(actions.fetchItems, {}, {}, [
+ { type: types.SET_FEATURES, payload: [{ title: 'Whats New Drawer', url: 'www.url.com' }] },
+ ]);
+ });
+ });
});