Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
5ad38ee9
Commit
5ad38ee9
authored
Sep 17, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(timepicker2): fixed timesrv specs
parent
4c795914
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
13 deletions
+14
-13
public/app/features/dashboard/timeSrv.js
+4
-4
public/test/specs/timeSrv-specs.js
+10
-9
No files found.
public/app/features/dashboard/timeSrv.js
View file @
5ad38ee9
...
...
@@ -30,10 +30,10 @@ define([
this
.
_parseTime
=
function
()
{
// when absolute time is saved in json it is turned to a string
if
(
_
.
isString
(
this
.
time
.
from
)
&&
this
.
time
.
from
.
indexOf
(
'Z'
)
>=
0
)
{
this
.
time
.
from
=
new
Date
(
this
.
time
.
from
);
this
.
time
.
from
=
moment
(
this
.
time
.
from
);
}
if
(
_
.
isString
(
this
.
time
.
to
)
&&
this
.
time
.
to
.
indexOf
(
'Z'
)
>=
0
)
{
this
.
time
.
to
=
new
Date
(
this
.
time
.
to
);
this
.
time
.
to
=
moment
(
this
.
time
.
to
);
}
};
...
...
@@ -113,8 +113,8 @@ define([
range
=
this
.
timeRange
();
}
if
(
_
.
isDate
(
range
.
from
))
{
range
.
from
=
range
.
from
.
getTime
();
}
if
(
_
.
isDate
(
range
.
to
))
{
range
.
to
=
range
.
to
.
getTime
();
}
if
(
moment
.
isMoment
(
range
.
from
))
{
range
.
from
=
range
.
from
.
valueOf
();
}
if
(
moment
.
isMoment
(
range
.
to
))
{
range
.
to
=
range
.
to
.
valueOf
();
}
return
range
;
};
...
...
public/test/specs/timeSrv-specs.js
View file @
5ad38ee9
...
...
@@ -2,9 +2,10 @@ define([
'../mocks/dashboard-mock'
,
'./helpers'
,
'lodash'
,
'moment'
,
'app/services/timer'
,
'app/features/dashboard/timeSrv'
],
function
(
dashboardMock
,
helpers
,
_
)
{
],
function
(
dashboardMock
,
helpers
,
_
,
moment
)
{
'use strict'
;
describe
(
'timeSrv'
,
function
()
{
...
...
@@ -31,8 +32,8 @@ define([
it
(
'should return parsed when parse is true'
,
function
()
{
ctx
.
service
.
setTime
({
from
:
'now'
,
to
:
'now-1h'
});
var
time
=
ctx
.
service
.
timeRange
(
true
);
expect
(
_
.
isDate
(
time
.
from
)).
to
.
be
(
true
);
expect
(
_
.
isDate
(
time
.
to
)).
to
.
be
(
true
);
expect
(
moment
.
isMoment
(
time
.
from
)).
to
.
be
(
true
);
expect
(
moment
.
isMoment
(
time
.
to
)).
to
.
be
(
true
);
});
});
...
...
@@ -51,8 +52,8 @@ define([
ctx
.
$routeParams
.
to
=
'20140520T031022'
;
ctx
.
service
.
init
(
_dashboard
);
var
time
=
ctx
.
service
.
timeRange
(
true
);
expect
(
time
.
from
.
getTime
()).
to
.
equal
(
new
Date
(
"2014-04-10T05:20:10Z"
).
getTime
());
expect
(
time
.
to
.
getTime
()).
to
.
equal
(
new
Date
(
"2014-05-20T03:10:22Z"
).
getTime
());
expect
(
time
.
from
.
valueOf
()).
to
.
equal
(
new
Date
(
"2014-04-10T05:20:10Z"
).
getTime
());
expect
(
time
.
to
.
valueOf
()).
to
.
equal
(
new
Date
(
"2014-05-20T03:10:22Z"
).
getTime
());
});
it
(
'should handle formated dates without time'
,
function
()
{
...
...
@@ -60,8 +61,8 @@ define([
ctx
.
$routeParams
.
to
=
'20140520'
;
ctx
.
service
.
init
(
_dashboard
);
var
time
=
ctx
.
service
.
timeRange
(
true
);
expect
(
time
.
from
.
getTime
()).
to
.
equal
(
new
Date
(
"2014-04-10T00:00:00Z"
).
getTime
());
expect
(
time
.
to
.
getTime
()).
to
.
equal
(
new
Date
(
"2014-05-20T00:00:00Z"
).
getTime
());
expect
(
time
.
from
.
valueOf
()).
to
.
equal
(
new
Date
(
"2014-04-10T00:00:00Z"
).
getTime
());
expect
(
time
.
to
.
valueOf
()).
to
.
equal
(
new
Date
(
"2014-05-20T00:00:00Z"
).
getTime
());
});
it
(
'should handle epochs'
,
function
()
{
...
...
@@ -69,8 +70,8 @@ define([
ctx
.
$routeParams
.
to
=
'1410337665699'
;
ctx
.
service
.
init
(
_dashboard
);
var
time
=
ctx
.
service
.
timeRange
(
true
);
expect
(
time
.
from
.
getTime
()).
to
.
equal
(
1410337646373
);
expect
(
time
.
to
.
getTime
()).
to
.
equal
(
1410337665699
);
expect
(
time
.
from
.
valueOf
()).
to
.
equal
(
1410337646373
);
expect
(
time
.
to
.
valueOf
()).
to
.
equal
(
1410337665699
);
});
});
...
...
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