summaryrefslogtreecommitdiff
path: root/spec/javascripts
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2019-05-10 19:06:37 +0100
committerPhil Hughes <me@iamphill.com>2019-05-10 19:06:37 +0100
commit40eb7f72b9b3f97c5548129bd1c3bf66fd26434c (patch)
tree11c7a42ebd847196a006a207a4100429097d0c3f /spec/javascripts
parent712dccd4c0f37b9fce12f5a945a551f8dca07cc4 (diff)
downloadgitlab-ce-40eb7f72b9b3f97c5548129bd1c3bf66fd26434c.tar.gz
Fixes issues with show whitespace button in diffs
Correctly updates the URL without overwriting parameters Reloads the diff file content without reloading the page Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/58852, https://gitlab.com/gitlab-org/gitlab-ce/issues/42597
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/diffs/store/actions_spec.js30
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', () => {