diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2019-02-25 09:39:18 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2019-02-25 09:39:18 +0000 |
commit | 1c30b12b868ffc3d73589d42a811bc47f8f631c9 (patch) | |
tree | 546ceced176dee8c607d32b680e64b0dc8c8f791 /spec/javascripts/lib | |
parent | 1ad18199ce15071bd5b28a1c4fb008f78cfbe384 (diff) | |
parent | ec5bbd27f5b334a6e338574ebafe6b0cd39461bc (diff) | |
download | gitlab-ce-1c30b12b868ffc3d73589d42a811bc47f8f631c9.tar.gz |
Merge branch 'sh-fix-double-xhr-pipelines' into 'master'
Remove duplicate XHR request when requesting new pipeline page
Closes #58095
See merge request gitlab-org/gitlab-ce!25506
Diffstat (limited to 'spec/javascripts/lib')
-rw-r--r-- | spec/javascripts/lib/utils/poll_spec.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/javascripts/lib/utils/poll_spec.js b/spec/javascripts/lib/utils/poll_spec.js index d0da659c3d7..138041a349f 100644 --- a/spec/javascripts/lib/utils/poll_spec.js +++ b/spec/javascripts/lib/utils/poll_spec.js @@ -153,6 +153,36 @@ describe('Poll', () => { }); }); + describe('enable', () => { + it('should enable polling upon a response', done => { + jasmine.clock().install(); + + const Polling = new Poll({ + resource: service, + method: 'fetch', + data: { page: 1 }, + successCallback: () => {}, + }); + + Polling.enable({ + data: { page: 4 }, + response: { status: 200, headers: { 'poll-interval': 1 } }, + }); + + jasmine.clock().tick(1); + jasmine.clock().uninstall(); + + waitForAllCallsToFinish(service, 1, () => { + Polling.stop(); + + expect(service.fetch.calls.count()).toEqual(1); + expect(service.fetch).toHaveBeenCalledWith({ page: 4 }); + expect(Polling.options.data).toEqual({ page: 4 }); + done(); + }); + }); + }); + describe('restart', () => { it('should restart polling when its called', done => { mockServiceCall(service, { status: 200, headers: { 'poll-interval': 1 } }); @@ -171,6 +201,7 @@ describe('Poll', () => { }); spyOn(Polling, 'stop').and.callThrough(); + spyOn(Polling, 'enable').and.callThrough(); spyOn(Polling, 'restart').and.callThrough(); Polling.makeRequest(); @@ -181,6 +212,7 @@ describe('Poll', () => { expect(service.fetch.calls.count()).toEqual(2); expect(service.fetch).toHaveBeenCalledWith({ page: 4 }); expect(Polling.stop).toHaveBeenCalled(); + expect(Polling.enable).toHaveBeenCalled(); expect(Polling.restart).toHaveBeenCalled(); expect(Polling.options.data).toEqual({ page: 4 }); done(); |