diff options
Diffstat (limited to 'spec/frontend/whats_new/store')
-rw-r--r-- | spec/frontend/whats_new/store/actions_spec.js | 21 | ||||
-rw-r--r-- | spec/frontend/whats_new/store/mutations_spec.js | 35 |
2 files changed, 49 insertions, 7 deletions
diff --git a/spec/frontend/whats_new/store/actions_spec.js b/spec/frontend/whats_new/store/actions_spec.js index 95ab667d611..12722b1b3b1 100644 --- a/spec/frontend/whats_new/store/actions_spec.js +++ b/spec/frontend/whats_new/store/actions_spec.js @@ -30,7 +30,9 @@ describe('whats new actions', () => { axiosMock = new MockAdapter(axios); axiosMock .onGet('/-/whats_new') - .replyOnce(200, [{ title: 'Whats New Drawer', url: 'www.url.com' }]); + .replyOnce(200, [{ title: 'Whats New Drawer', url: 'www.url.com' }], { + 'x-next-page': '2', + }); await waitForPromises(); }); @@ -39,10 +41,23 @@ describe('whats new actions', () => { axiosMock.restore(); }); - it('should commit setFeatures', () => { + it('if already fetching, does not fetch', () => { + testAction(actions.fetchItems, {}, { fetching: true }, []); + }); + + it('should commit fetching, setFeatures and setPagination', () => { testAction(actions.fetchItems, {}, {}, [ - { type: types.SET_FEATURES, payload: [{ title: 'Whats New Drawer', url: 'www.url.com' }] }, + { type: types.SET_FETCHING, payload: true }, + { type: types.ADD_FEATURES, payload: [{ title: 'Whats New Drawer', url: 'www.url.com' }] }, + { type: types.SET_PAGE_INFO, payload: { nextPage: 2 } }, + { type: types.SET_FETCHING, payload: false }, ]); }); }); + + describe('setDrawerBodyHeight', () => { + testAction(actions.setDrawerBodyHeight, 42, {}, [ + { type: types.SET_DRAWER_BODY_HEIGHT, payload: 42 }, + ]); + }); }); diff --git a/spec/frontend/whats_new/store/mutations_spec.js b/spec/frontend/whats_new/store/mutations_spec.js index feaa1dd2a3b..4967fb51d2b 100644 --- a/spec/frontend/whats_new/store/mutations_spec.js +++ b/spec/frontend/whats_new/store/mutations_spec.js @@ -23,10 +23,37 @@ describe('whats new mutations', () => { }); }); - describe('setFeatures', () => { - it('sets features to data', () => { - mutations[types.SET_FEATURES](state, 'bells and whistles'); - expect(state.features).toBe('bells and whistles'); + describe('addFeatures', () => { + it('adds features from data', () => { + mutations[types.ADD_FEATURES](state, ['bells and whistles']); + expect(state.features).toEqual(['bells and whistles']); + }); + + it('when there are already items, it adds items', () => { + state.features = ['shiny things']; + mutations[types.ADD_FEATURES](state, ['bells and whistles']); + expect(state.features).toEqual(['shiny things', 'bells and whistles']); + }); + }); + + describe('setPageInfo', () => { + it('sets page info', () => { + mutations[types.SET_PAGE_INFO](state, { nextPage: 8 }); + expect(state.pageInfo).toEqual({ nextPage: 8 }); + }); + }); + + describe('setFetching', () => { + it('sets fetching', () => { + mutations[types.SET_FETCHING](state, true); + expect(state.fetching).toBe(true); + }); + }); + + describe('setDrawerBodyHeight', () => { + it('sets drawerBodyHeight', () => { + mutations[types.SET_DRAWER_BODY_HEIGHT](state, 840); + expect(state.drawerBodyHeight).toBe(840); }); }); }); |