Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-07-31 10:22:01 +0300
committerPhil Hughes <me@iamphill.com>2018-07-31 10:22:01 +0300
commite61c0407a491b1522843caebd3d8a084229b79b6 (patch)
treee4be37f26257f2e14fafacfc01968d2cbcb9a82c /spec/javascripts
parent2170a7156b31f2da443044dea8ee60f254bb7b77 (diff)
parent49948c1ff614bd6eaa8340860c6863408b67cebc (diff)
Merge branch '49747-update-poll-2xx' into 'master'
Resolve "Update poll.js to keep polling if the status code is 2xx" Closes #49747 See merge request gitlab-org/gitlab-ce!20904
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/lib/utils/poll_spec.js39
1 files changed, 22 insertions, 17 deletions
diff --git a/spec/javascripts/lib/utils/poll_spec.js b/spec/javascripts/lib/utils/poll_spec.js
index 9b8f68f1676..523f4997bc0 100644
--- a/spec/javascripts/lib/utils/poll_spec.js
+++ b/spec/javascripts/lib/utils/poll_spec.js
@@ -1,4 +1,5 @@
import Poll from '~/lib/utils/poll';
+import { successCodes } from '~/lib/utils/http_status';
const waitForAllCallsToFinish = (service, waitForCount, successCallback) => {
const timer = () => {
@@ -91,28 +92,32 @@ describe('Poll', () => {
}).catch(done.fail);
});
- it('starts polling when http status is 200 and interval header is provided', (done) => {
- mockServiceCall(service, { status: 200, headers: { 'poll-interval': 1 } });
+ describe('for 2xx status code', () => {
+ successCodes.forEach(httpCode => {
+ it(`starts polling when http status is ${httpCode} and interval header is provided`, (done) => {
+ mockServiceCall(service, { status: httpCode, headers: { 'poll-interval': 1 } });
- const Polling = new Poll({
- resource: service,
- method: 'fetch',
- data: { page: 1 },
- successCallback: callbacks.success,
- errorCallback: callbacks.error,
- });
+ const Polling = new Poll({
+ resource: service,
+ method: 'fetch',
+ data: { page: 1 },
+ successCallback: callbacks.success,
+ errorCallback: callbacks.error,
+ });
- Polling.makeRequest();
+ Polling.makeRequest();
- waitForAllCallsToFinish(service, 2, () => {
- Polling.stop();
+ waitForAllCallsToFinish(service, 2, () => {
+ Polling.stop();
- expect(service.fetch.calls.count()).toEqual(2);
- expect(service.fetch).toHaveBeenCalledWith({ page: 1 });
- expect(callbacks.success).toHaveBeenCalled();
- expect(callbacks.error).not.toHaveBeenCalled();
+ expect(service.fetch.calls.count()).toEqual(2);
+ expect(service.fetch).toHaveBeenCalledWith({ page: 1 });
+ expect(callbacks.success).toHaveBeenCalled();
+ expect(callbacks.error).not.toHaveBeenCalled();
- done();
+ done();
+ });
+ });
});
});