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
6bf2cb91
Commit
6bf2cb91
authored
Oct 24, 2018
by
Winnie Hellmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add validation for date strings passed to GlCountdown
parent
6e680647
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
app/assets/javascripts/vue_shared/components/gl_countdown.vue
...assets/javascripts/vue_shared/components/gl_countdown.vue
+7
-4
spec/javascripts/vue_shared/components/gl_countdown_spec.js
spec/javascripts/vue_shared/components/gl_countdown_spec.js
+16
-2
No files found.
app/assets/javascripts/vue_shared/components/gl_countdown.vue
View file @
6bf2cb91
...
...
@@ -6,9 +6,12 @@ import { calculateRemainingMilliseconds, formatTime } from '~/lib/utils/datetime
*/
export
default
{
props
:
{
endDate
:
{
endDate
String
:
{
type
:
String
,
required
:
true
,
validator
(
value
)
{
return
!
Number
.
isNaN
(
new
Date
(
value
).
getTime
());
},
},
},
...
...
@@ -21,7 +24,7 @@ export default {
mounted
()
{
const
updateRemainingTime
=
()
=>
{
const
remainingMilliseconds
=
calculateRemainingMilliseconds
(
this
.
endDate
);
const
remainingMilliseconds
=
calculateRemainingMilliseconds
(
this
.
endDate
String
);
this
.
remainingTime
=
formatTime
(
remainingMilliseconds
);
};
...
...
@@ -38,8 +41,8 @@ export default {
<
template
>
<time
v-gl-tooltip
:datetime=
"endDate"
:title=
"endDate"
:datetime=
"endDate
String
"
:title=
"endDate
String
"
>
{{
remainingTime
}}
</time>
...
...
spec/javascripts/vue_shared/components/gl_countdown_spec.js
View file @
6bf2cb91
...
...
@@ -20,7 +20,7 @@ describe('GlCountdown', () => {
describe
(
'
when there is time remaining
'
,
()
=>
{
beforeEach
(
done
=>
{
vm
=
mountComponent
(
Component
,
{
endDate
:
'
2000-01-01T01:02:03Z
'
,
endDate
String
:
'
2000-01-01T01:02:03Z
'
,
});
Vue
.
nextTick
()
...
...
@@ -48,7 +48,7 @@ describe('GlCountdown', () => {
describe
(
'
when there is no time remaining
'
,
()
=>
{
beforeEach
(
done
=>
{
vm
=
mountComponent
(
Component
,
{
endDate
:
'
1900-01-01T00:00:00Z
'
,
endDate
String
:
'
1900-01-01T00:00:00Z
'
,
});
Vue
.
nextTick
()
...
...
@@ -60,4 +60,18 @@ describe('GlCountdown', () => {
expect
(
vm
.
$el
).
toContainText
(
'
00:00:00
'
);
});
});
describe
(
'
when an invalid date is passed
'
,
()
=>
{
it
(
'
throws a validation error
'
,
()
=>
{
spyOn
(
Vue
.
config
,
'
warnHandler
'
).
and
.
stub
();
vm
=
mountComponent
(
Component
,
{
endDateString
:
'
this is invalid
'
,
});
expect
(
Vue
.
config
.
warnHandler
).
toHaveBeenCalledTimes
(
1
);
const
[
errorMessage
]
=
Vue
.
config
.
warnHandler
.
calls
.
argsFor
(
0
);
expect
(
errorMessage
).
toMatch
(
/^Invalid prop: .* "endDateString"/
);
});
});
});
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