Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
58f2db49
Commit
58f2db49
authored
Mar 20, 2017
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed code style as to not to disable any eslint rules
parent
20cbfb48
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
spec/javascripts/lib/utils/common_utils_spec.js
spec/javascripts/lib/utils/common_utils_spec.js
+13
-14
No files found.
spec/javascripts/lib/utils/common_utils_spec.js
View file @
58f2db49
/* eslint-disable arrow-body-style*/
require
(
'
~/lib/utils/common_utils
'
);
require
(
'
~/lib/utils/common_utils
'
);
(()
=>
{
(()
=>
{
...
@@ -168,13 +167,13 @@ require('~/lib/utils/common_utils');
...
@@ -168,13 +167,13 @@ require('~/lib/utils/common_utils');
describe
(
'
gl.utils.backOff
'
,
()
=>
{
describe
(
'
gl.utils.backOff
'
,
()
=>
{
it
(
'
solves the promise from the callback
'
,
(
done
)
=>
{
it
(
'
solves the promise from the callback
'
,
(
done
)
=>
{
const
expectedResponseValue
=
'
Success!
'
;
const
expectedResponseValue
=
'
Success!
'
;
gl
.
utils
.
backOff
((
next
,
stop
)
=>
{
gl
.
utils
.
backOff
((
next
,
stop
)
=>
(
return
new
Promise
((
resolve
)
=>
{
new
Promise
((
resolve
)
=>
{
resolve
(
expectedResponseValue
);
resolve
(
expectedResponseValue
);
}).
then
((
resp
)
=>
{
}).
then
((
resp
)
=>
{
stop
(
resp
);
stop
(
resp
);
})
;
})
}
).
then
((
respBackoff
)
=>
{
)
).
then
((
respBackoff
)
=>
{
expect
(
respBackoff
).
toBe
(
expectedResponseValue
);
expect
(
respBackoff
).
toBe
(
expectedResponseValue
);
done
();
done
();
});
});
...
@@ -183,7 +182,7 @@ require('~/lib/utils/common_utils');
...
@@ -183,7 +182,7 @@ require('~/lib/utils/common_utils');
it
(
'
catches the rejected promise from the callback
'
,
(
done
)
=>
{
it
(
'
catches the rejected promise from the callback
'
,
(
done
)
=>
{
const
errorMessage
=
'
Mistakes were made!
'
;
const
errorMessage
=
'
Mistakes were made!
'
;
gl
.
utils
.
backOff
((
next
,
stop
)
=>
{
gl
.
utils
.
backOff
((
next
,
stop
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
new
Promise
((
resolve
,
reject
)
=>
{
reject
(
new
Error
(
errorMessage
));
reject
(
new
Error
(
errorMessage
));
}).
then
((
resp
)
=>
{
}).
then
((
resp
)
=>
{
stop
(
resp
);
stop
(
resp
);
...
@@ -198,8 +197,8 @@ require('~/lib/utils/common_utils');
...
@@ -198,8 +197,8 @@ require('~/lib/utils/common_utils');
it
(
'
solves the promise correctly after retrying a third time
'
,
(
done
)
=>
{
it
(
'
solves the promise correctly after retrying a third time
'
,
(
done
)
=>
{
let
numberOfCalls
=
1
;
let
numberOfCalls
=
1
;
const
expectedResponseValue
=
'
Success!
'
;
const
expectedResponseValue
=
'
Success!
'
;
gl
.
utils
.
backOff
((
next
,
stop
)
=>
{
gl
.
utils
.
backOff
((
next
,
stop
)
=>
(
return
new
Promise
((
resolve
)
=>
{
new
Promise
((
resolve
)
=>
{
resolve
(
expectedResponseValue
);
resolve
(
expectedResponseValue
);
}).
then
((
resp
)
=>
{
}).
then
((
resp
)
=>
{
if
(
numberOfCalls
<
3
)
{
if
(
numberOfCalls
<
3
)
{
...
@@ -208,8 +207,8 @@ require('~/lib/utils/common_utils');
...
@@ -208,8 +207,8 @@ require('~/lib/utils/common_utils');
}
else
{
}
else
{
stop
(
resp
);
stop
(
resp
);
}
}
})
;
})
}
).
then
((
respBackoff
)
=>
{
)
).
then
((
respBackoff
)
=>
{
expect
(
respBackoff
).
toBe
(
expectedResponseValue
);
expect
(
respBackoff
).
toBe
(
expectedResponseValue
);
expect
(
numberOfCalls
).
toBe
(
3
);
expect
(
numberOfCalls
).
toBe
(
3
);
done
();
done
();
...
@@ -218,13 +217,13 @@ require('~/lib/utils/common_utils');
...
@@ -218,13 +217,13 @@ require('~/lib/utils/common_utils');
it
(
'
rejects the backOff promise after timing out
'
,
(
done
)
=>
{
it
(
'
rejects the backOff promise after timing out
'
,
(
done
)
=>
{
const
expectedResponseValue
=
'
Success!
'
;
const
expectedResponseValue
=
'
Success!
'
;
gl
.
utils
.
backOff
(
(
next
)
=>
{
gl
.
utils
.
backOff
(
next
=>
(
return
new
Promise
((
resolve
)
=>
{
new
Promise
((
resolve
)
=>
{
resolve
(
expectedResponseValue
);
resolve
(
expectedResponseValue
);
}).
then
(()
=>
{
}).
then
(()
=>
{
setTimeout
(
next
(),
5000
);
// it will time out
setTimeout
(
next
(),
5000
);
// it will time out
})
;
})
}
,
3000
).
catch
((
errBackoffResp
)
=>
{
)
,
3000
).
catch
((
errBackoffResp
)
=>
{
expect
(
errBackoffResp
instanceof
Error
).
toBe
(
true
);
expect
(
errBackoffResp
instanceof
Error
).
toBe
(
true
);
expect
(
errBackoffResp
.
message
).
toBe
(
'
BACKOFF_TIMEOUT
'
);
expect
(
errBackoffResp
.
message
).
toBe
(
'
BACKOFF_TIMEOUT
'
);
done
();
done
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment