2020-10-24 23:57:45 +05:30
|
|
|
import testAction from 'helpers/vuex_action_helper';
|
2021-01-03 14:25:43 +05:30
|
|
|
import { useLocalStorageSpy } from 'helpers/local_storage_helper';
|
|
|
|
import MockAdapter from 'axios-mock-adapter';
|
|
|
|
import waitForPromises from 'helpers/wait_for_promises';
|
2020-10-24 23:57:45 +05:30
|
|
|
import actions from '~/whats_new/store/actions';
|
|
|
|
import * as types from '~/whats_new/store/mutation_types';
|
2021-01-03 14:25:43 +05:30
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2020-10-24 23:57:45 +05:30
|
|
|
|
|
|
|
describe('whats new actions', () => {
|
|
|
|
describe('openDrawer', () => {
|
2021-01-03 14:25:43 +05:30
|
|
|
useLocalStorageSpy();
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('should commit openDrawer', () => {
|
2021-01-03 14:25:43 +05:30
|
|
|
testAction(actions.openDrawer, 'storage-key', {}, [{ type: types.OPEN_DRAWER }]);
|
|
|
|
|
|
|
|
expect(window.localStorage.setItem).toHaveBeenCalledWith('storage-key', 'false');
|
2020-10-24 23:57:45 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('closeDrawer', () => {
|
|
|
|
it('should commit closeDrawer', () => {
|
|
|
|
testAction(actions.closeDrawer, {}, {}, [{ type: types.CLOSE_DRAWER }]);
|
|
|
|
});
|
|
|
|
});
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
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' }] },
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
2020-10-24 23:57:45 +05:30
|
|
|
});
|