diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2019-05-16 13:13:04 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2019-05-16 13:13:04 +0300 |
commit | 9afe8d3bcd1f3f39c8543f675e2522e73dd78b59 (patch) | |
tree | cd5ea7ba54ea8807b87bd9377c85a9e44eb2592e /spec/javascripts | |
parent | 19e0a9a038efdf9a1f5634ae05ada863625f95dd (diff) | |
parent | 40eb7f72b9b3f97c5548129bd1c3bf66fd26434c (diff) |
Merge branch 'diff-whitespace-setting-changes' into 'master'
Fixes issues with show whitespace button in diffs
Closes #42597 and #58852
See merge request gitlab-org/gitlab-ce!28242
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/diffs/store/actions_spec.js | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/spec/javascripts/diffs/store/actions_spec.js b/spec/javascripts/diffs/store/actions_spec.js index c82dcadd2f1..6309a8823d7 100644 --- a/spec/javascripts/diffs/store/actions_spec.js +++ b/spec/javascripts/diffs/store/actions_spec.js @@ -82,7 +82,7 @@ describe('DiffsStoreActions', () => { describe('fetchDiffFiles', () => { it('should fetch diff files', done => { - const endpoint = '/fetch/diff/files'; + const endpoint = '/fetch/diff/files?w=1'; const mock = new MockAdapter(axios); const res = { diff_files: 1, merge_request_diffs: [] }; mock.onGet(endpoint).reply(200, res); @@ -828,6 +828,10 @@ describe('DiffsStoreActions', () => { }); describe('setShowWhitespace', () => { + beforeEach(() => { + spyOn(eventHub, '$emit').and.stub(); + }); + it('commits SET_SHOW_WHITESPACE', done => { testAction( setShowWhitespace, @@ -855,6 +859,30 @@ describe('DiffsStoreActions', () => { expect(window.history.pushState).toHaveBeenCalled(); }); + + it('calls history pushState with merged params', () => { + const originalPushState = window.history; + + originalPushState.pushState({}, '', '?test=1'); + + spyOn(localStorage, 'setItem').and.stub(); + spyOn(window.history, 'pushState').and.stub(); + + setShowWhitespace({ commit() {} }, { showWhitespace: true, pushState: true }); + + expect(window.history.pushState.calls.mostRecent().args[2]).toMatch(/(.*)\?test=1&w=0/); + + originalPushState.pushState({}, '', '?'); + }); + + it('emits eventHub event', () => { + spyOn(localStorage, 'setItem').and.stub(); + spyOn(window.history, 'pushState').and.stub(); + + setShowWhitespace({ commit() {} }, { showWhitespace: true, pushState: true }); + + expect(eventHub.$emit).toHaveBeenCalledWith('refetchDiffData'); + }); }); describe('setRenderIt', () => { |