diff options
author | Phil Hughes <me@iamphill.com> | 2019-03-11 13:09:36 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-03-11 13:09:36 +0000 |
commit | c36095b2e363b7a2d2c704a917bedf2337631a66 (patch) | |
tree | 507eef2f111846ef3ac4d489dbfe9f9f5c700be3 /spec/javascripts | |
parent | 97357c5bb6594be793c1af332bed8f942f2d72d2 (diff) | |
download | gitlab-ce-c36095b2e363b7a2d2c704a917bedf2337631a66.tar.gz |
Fix expand all button not working
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/51737
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/diffs/components/diff_file_spec.js | 25 | ||||
-rw-r--r-- | spec/javascripts/diffs/store/actions_spec.js | 14 | ||||
-rw-r--r-- | spec/javascripts/diffs/store/mutations_spec.js | 18 |
3 files changed, 55 insertions, 2 deletions
diff --git a/spec/javascripts/diffs/components/diff_file_spec.js b/spec/javascripts/diffs/components/diff_file_spec.js index ba04c8c4a4c..d9b298e84da 100644 --- a/spec/javascripts/diffs/components/diff_file_spec.js +++ b/spec/javascripts/diffs/components/diff_file_spec.js @@ -109,6 +109,31 @@ describe('DiffFile', () => { done(); }); }); + + it('should update store state', done => { + spyOn(vm.$store, 'dispatch'); + + vm.isCollapsed = true; + + vm.$nextTick(() => { + expect(vm.$store.dispatch).toHaveBeenCalledWith('diffs/setFileCollapsed', { + filePath: vm.file.file_path, + collapsed: true, + }); + + done(); + }); + }); + + it('updates local state when changing file state', done => { + vm.file.viewer.collapsed = true; + + vm.$nextTick(() => { + expect(vm.isCollapsed).toBe(true); + + done(); + }); + }); }); }); diff --git a/spec/javascripts/diffs/store/actions_spec.js b/spec/javascripts/diffs/store/actions_spec.js index 070bfb2ccd0..6c637097893 100644 --- a/spec/javascripts/diffs/store/actions_spec.js +++ b/spec/javascripts/diffs/store/actions_spec.js @@ -35,6 +35,7 @@ import actions, { receiveFullDiffError, fetchFullDiff, toggleFullDiff, + setFileCollapsed, } from '~/diffs/store/actions'; import eventHub from '~/notes/event_hub'; import * as types from '~/diffs/store/mutation_types'; @@ -977,4 +978,17 @@ describe('DiffsStoreActions', () => { ); }); }); + + describe('setFileCollapsed', () => { + it('commits SET_FILE_COLLAPSED', done => { + testAction( + setFileCollapsed, + { filePath: 'test', collapsed: true }, + null, + [{ type: types.SET_FILE_COLLAPSED, payload: { filePath: 'test', collapsed: true } }], + [], + done, + ); + }); + }); }); diff --git a/spec/javascripts/diffs/store/mutations_spec.js b/spec/javascripts/diffs/store/mutations_spec.js index 270e7d75666..5556a994a14 100644 --- a/spec/javascripts/diffs/store/mutations_spec.js +++ b/spec/javascripts/diffs/store/mutations_spec.js @@ -58,13 +58,15 @@ describe('DiffsStoreMutations', () => { describe('EXPAND_ALL_FILES', () => { it('should change the collapsed prop from diffFiles', () => { const diffFile = { - collapsed: true, + viewer: { + collapsed: true, + }, }; const state = { expandAllFiles: true, diffFiles: [diffFile] }; mutations[types.EXPAND_ALL_FILES](state); - expect(state.diffFiles[0].collapsed).toEqual(false); + expect(state.diffFiles[0].viewer.collapsed).toEqual(false); }); }); @@ -742,4 +744,16 @@ describe('DiffsStoreMutations', () => { expect(state.diffFiles[0].isShowingFullFile).toBe(true); }); }); + + describe('SET_FILE_COLLAPSED', () => { + it('sets collapsed', () => { + const state = { + diffFiles: [{ file_path: 'test', viewer: { collapsed: false } }], + }; + + mutations[types.SET_FILE_COLLAPSED](state, { filePath: 'test', collapsed: true }); + + expect(state.diffFiles[0].viewer.collapsed).toBe(true); + }); + }); }); |