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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
1654c6fc
Commit
1654c6fc
authored
Jun 04, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Geo Nodes Details Section Mixin
parent
295ef550
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
ee/app/assets/javascripts/geo_nodes/mixins/details_section_mixin.js
...ets/javascripts/geo_nodes/mixins/details_section_mixin.js
+22
-0
spec/javascripts/geo_nodes/mixins/details_section_mixin_spec.js
...avascripts/geo_nodes/mixins/details_section_mixin_spec.js
+57
-0
No files found.
ee/app/assets/javascripts/geo_nodes/mixins/details_section_mixin.js
0 → 100644
View file @
1654c6fc
import
{
s__
,
sprintf
}
from
'
~/locale
'
;
import
timeAgoMixin
from
'
~/vue_shared/mixins/timeago
'
;
import
{
STATUS_DELAY_THRESHOLD_MS
}
from
'
../constants
'
;
export
default
{
mixins
:
[
timeAgoMixin
],
computed
:
{
statusInfoStale
()
{
const
elapsedMilliseconds
=
Math
.
abs
(
this
.
nodeDetails
.
statusCheckTimestamp
-
Date
.
now
());
return
elapsedMilliseconds
>
STATUS_DELAY_THRESHOLD_MS
;
},
statusInfoStaleMessage
()
{
return
sprintf
(
s__
(
'
GeoNodes|Data is out of date from %{timeago}
'
),
{
timeago
:
this
.
timeFormated
(
this
.
nodeDetails
.
statusCheckTimestamp
,
),
});
},
},
};
spec/javascripts/geo_nodes/mixins/details_section_mixin_spec.js
0 → 100644
View file @
1654c6fc
import
Vue
from
'
vue
'
;
import
DetailsSectionMixin
from
'
ee/geo_nodes/mixins/details_section_mixin
'
;
import
{
STATUS_DELAY_THRESHOLD_MS
}
from
'
ee/geo_nodes/constants
'
;
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
mockNodeDetails
}
from
'
../mock_data
'
;
const
createComponent
=
(
nodeDetails
=
mockNodeDetails
)
=>
{
const
Component
=
Vue
.
extend
({
template
:
'
<div></div>
'
,
mixins
:
[
DetailsSectionMixin
],
data
()
{
return
{
nodeDetails
};
},
});
return
mountComponent
(
Component
);
};
describe
(
'
DetailsSectionMixin
'
,
()
=>
{
let
vm
;
afterEach
(()
=>
{
vm
.
$destroy
();
});
describe
(
'
computed
'
,
()
=>
{
describe
(
'
statusInfoStale
'
,
()
=>
{
it
(
'
returns true when `nodeDetails.statusCheckTimestamp` is past the value of STATUS_DELAY_THRESHOLD_MS
'
,
()
=>
{
// Move statusCheckTimestamp to 2 minutes in the past
const
statusCheckTimestamp
=
new
Date
(
Date
.
now
()
-
STATUS_DELAY_THRESHOLD_MS
*
2
).
getTime
();
vm
=
createComponent
(
Object
.
assign
({},
mockNodeDetails
,
{
statusCheckTimestamp
}));
expect
(
vm
.
statusInfoStale
).
toBe
(
true
);
});
it
(
'
returns false when `nodeDetails.statusCheckTimestamp` is under the value of STATUS_DELAY_THRESHOLD_MS
'
,
()
=>
{
// Move statusCheckTimestamp to 30 seconds in the past
const
statusCheckTimestamp
=
new
Date
(
Date
.
now
()
-
STATUS_DELAY_THRESHOLD_MS
/
2
).
getTime
();
vm
=
createComponent
(
Object
.
assign
({},
mockNodeDetails
,
{
statusCheckTimestamp
}));
expect
(
vm
.
statusInfoStale
).
toBe
(
false
);
});
});
describe
(
'
statusInfoStaleMessage
'
,
()
=>
{
it
(
'
returns stale information message containing the duration elapsed
'
,
()
=>
{
// Move statusCheckTimestamp to 1 minute in the past
const
statusCheckTimestamp
=
new
Date
(
Date
.
now
()
-
STATUS_DELAY_THRESHOLD_MS
).
getTime
();
vm
=
createComponent
(
Object
.
assign
({},
mockNodeDetails
,
{
statusCheckTimestamp
}));
expect
(
vm
.
statusInfoStaleMessage
).
toBe
(
'
Data is out of date from about a minute ago
'
);
});
});
});
});
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