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
Léo-Paul Géneau
gitlab-ce
Commits
f3ae99fa
Commit
f3ae99fa
authored
Oct 31, 2017
by
Simon Knox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove global export from SmartInterval
parent
1d298e49
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
138 additions
and
136 deletions
+138
-136
app/assets/javascripts/smart_interval.js
app/assets/javascripts/smart_interval.js
+1
-2
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
...javascripts/vue_merge_request_widget/mr_widget_options.js
+3
-2
spec/javascripts/smart_interval_spec.js
spec/javascripts/smart_interval_spec.js
+123
-125
spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
+11
-7
No files found.
app/assets/javascripts/smart_interval.js
View file @
f3ae99fa
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
* and controllable by a public API.
* and controllable by a public API.
*/
*/
class
SmartInterval
{
export
default
class
SmartInterval
{
/**
/**
* @param { function } opts.callback Function to be called on each iteration (required)
* @param { function } opts.callback Function to be called on each iteration (required)
* @param { milliseconds } opts.startingInterval `currentInterval` is set to this initially
* @param { milliseconds } opts.startingInterval `currentInterval` is set to this initially
...
@@ -168,4 +168,3 @@ class SmartInterval {
...
@@ -168,4 +168,3 @@ class SmartInterval {
}
}
}
}
window
.
gl
.
SmartInterval
=
SmartInterval
;
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
View file @
f3ae99fa
import
SmartInterval
from
'
~/smart_interval
'
;
import
Flash
from
'
../flash
'
;
import
Flash
from
'
../flash
'
;
import
{
import
{
WidgetHeader
,
WidgetHeader
,
...
@@ -97,7 +98,7 @@ export default {
...
@@ -97,7 +98,7 @@ export default {
});
});
},
},
initPolling
()
{
initPolling
()
{
this
.
pollingInterval
=
new
gl
.
SmartInterval
({
this
.
pollingInterval
=
new
SmartInterval
({
callback
:
this
.
checkStatus
,
callback
:
this
.
checkStatus
,
startingInterval
:
10000
,
startingInterval
:
10000
,
maxInterval
:
30000
,
maxInterval
:
30000
,
...
@@ -106,7 +107,7 @@ export default {
...
@@ -106,7 +107,7 @@ export default {
});
});
},
},
initDeploymentsPolling
()
{
initDeploymentsPolling
()
{
this
.
deploymentsInterval
=
new
gl
.
SmartInterval
({
this
.
deploymentsInterval
=
new
SmartInterval
({
callback
:
this
.
fetchDeployments
,
callback
:
this
.
fetchDeployments
,
startingInterval
:
30000
,
startingInterval
:
30000
,
maxInterval
:
120000
,
maxInterval
:
120000
,
...
...
spec/javascripts/smart_interval_spec.js
View file @
f3ae99fa
This diff is collapsed.
Click to expand it.
spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
View file @
f3ae99fa
...
@@ -121,24 +121,28 @@ describe('mrWidgetOptions', () => {
...
@@ -121,24 +121,28 @@ describe('mrWidgetOptions', () => {
describe
(
'
initPolling
'
,
()
=>
{
describe
(
'
initPolling
'
,
()
=>
{
it
(
'
should call SmartInterval
'
,
()
=>
{
it
(
'
should call SmartInterval
'
,
()
=>
{
spyOn
(
gl
,
'
SmartInterval
'
).
and
.
returnValue
({
spyOn
(
vm
,
'
checkStatus
'
).
and
.
returnValue
(
Promise
.
resolve
());
resume
()
{},
jasmine
.
clock
().
install
();
stopTimer
()
{},
});
vm
.
initPolling
();
vm
.
initPolling
();
expect
(
vm
.
checkStatus
).
not
.
toHaveBeenCalled
();
jasmine
.
clock
().
tick
(
10000
);
expect
(
vm
.
pollingInterval
).
toBeDefined
();
expect
(
vm
.
pollingInterval
).
toBeDefined
();
expect
(
gl
.
SmartInterval
).
toHaveBeenCalled
();
expect
(
vm
.
checkStatus
).
toHaveBeenCalled
();
jasmine
.
clock
().
uninstall
();
});
});
});
});
describe
(
'
initDeploymentsPolling
'
,
()
=>
{
describe
(
'
initDeploymentsPolling
'
,
()
=>
{
it
(
'
should call SmartInterval
'
,
()
=>
{
it
(
'
should call SmartInterval
'
,
()
=>
{
spyOn
(
gl
,
'
SmartInterval
'
);
spyOn
(
vm
,
'
fetchDeployments
'
).
and
.
returnValue
(
Promise
.
resolve
()
);
vm
.
initDeploymentsPolling
();
vm
.
initDeploymentsPolling
();
expect
(
vm
.
deploymentsInterval
).
toBeDefined
();
expect
(
vm
.
deploymentsInterval
).
toBeDefined
();
expect
(
gl
.
SmartInterval
).
toHaveBeenCalled
();
expect
(
vm
.
fetchDeployments
).
toHaveBeenCalled
();
});
});
});
});
...
...
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