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
fc06f8bf
Commit
fc06f8bf
authored
Jul 26, 2018
by
Tobias Skarhed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass more tests
parent
88e91b3f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
20 deletions
+15
-20
public/app/plugins/panel/singlestat/module.ts
+1
-0
public/app/plugins/panel/singlestat/specs/singlestat.jest.ts
+14
-20
No files found.
public/app/plugins/panel/singlestat/module.ts
View file @
fc06f8bf
...
...
@@ -310,6 +310,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
data
.
valueRounded
=
data
.
value
;
data
.
valueFormatted
=
formatFunc
(
data
.
value
,
this
.
dashboard
.
isTimezoneUtc
());
}
else
{
console
.
log
(
lastPoint
,
lastValue
);
data
.
value
=
this
.
series
[
0
].
stats
[
this
.
panel
.
valueName
];
data
.
flotpairs
=
this
.
series
[
0
].
flotpairs
;
...
...
public/app/plugins/panel/singlestat/specs/singlestat.jest.ts
View file @
fc06f8bf
...
...
@@ -7,7 +7,7 @@ import moment from 'moment';
describe
(
'SingleStatCtrl'
,
function
()
{
let
ctx
=
<
any
>
{};
let
epoch
=
1505826363746
;
let
clock
;
Date
.
now
=
()
=>
epoch
;
let
$scope
=
{
$on
:
()
=>
{},
...
...
@@ -24,7 +24,7 @@ describe('SingleStatCtrl', function() {
},
};
SingleStatCtrl
.
prototype
.
dashboard
=
{
isTimezoneUtc
:
()
=>
{}
,
isTimezoneUtc
:
jest
.
fn
(()
=>
true
)
,
};
function
singleStatScenario
(
desc
,
func
)
{
...
...
@@ -89,29 +89,30 @@ describe('SingleStatCtrl', function() {
ctx
.
data
=
[{
target
:
'test.cpu1'
,
datapoints
:
[[
10
,
12
],
[
20
,
1505634997920
]]
}];
ctx
.
ctrl
.
panel
.
valueName
=
'last_time'
;
ctx
.
ctrl
.
panel
.
format
=
'dateTimeAsIso'
;
ctx
.
ctrl
.
dashboard
.
isTimezoneUtc
=
()
=>
false
;
});
it
(
'Should use time instead of value'
,
function
()
{
console
.
log
(
ctx
.
data
.
value
);
expect
(
ctx
.
data
.
value
).
toBe
(
1505634997920
);
expect
(
ctx
.
data
.
valueRounded
).
toBe
(
1505634997920
);
});
it
(
'should set formatted value'
,
function
()
{
expect
(
ctx
.
data
.
valueFormatted
).
toBe
(
moment
(
1505634997920
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
);
expect
(
ctx
.
data
.
valueFormatted
).
toBe
(
'2017-09-17 09:56:37'
);
});
});
singleStatScenario
(
'showing last iso time instead of value (in UTC)'
,
function
(
ctx
)
{
ctx
.
setup
(
function
()
{
ctx
.
data
=
[{
target
:
'test.cpu1'
,
datapoints
:
[[
10
,
12
],
[
20
,
150563499792
0
]]
}];
ctx
.
data
=
[{
target
:
'test.cpu1'
,
datapoints
:
[[
10
,
12
],
[
20
,
500
0
]]
}];
ctx
.
ctrl
.
panel
.
valueName
=
'last_time'
;
ctx
.
ctrl
.
panel
.
format
=
'dateTimeAsIso'
;
// ctx.setIsUtc(true);
ctx
.
ctrl
.
dashboard
.
isTimezoneUtc
=
()
=>
true
;
});
it
(
'should set
formatted
value'
,
function
()
{
expect
(
ctx
.
data
.
valueFormatted
).
toBe
(
moment
.
utc
(
1505634997920
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
);
it
(
'should set value'
,
function
()
{
expect
(
ctx
.
data
.
valueFormatted
).
toBe
(
'1970-01-01 00:00:05'
);
});
});
...
...
@@ -120,6 +121,7 @@ describe('SingleStatCtrl', function() {
ctx
.
data
=
[{
target
:
'test.cpu1'
,
datapoints
:
[[
10
,
12
],
[
20
,
1505634997920
]]
}];
ctx
.
ctrl
.
panel
.
valueName
=
'last_time'
;
ctx
.
ctrl
.
panel
.
format
=
'dateTimeAsUS'
;
ctx
.
ctrl
.
dashboard
.
isTimezoneUtc
=
()
=>
false
;
});
it
(
'Should use time instead of value'
,
function
()
{
...
...
@@ -134,21 +136,22 @@ describe('SingleStatCtrl', function() {
singleStatScenario
(
'showing last us time instead of value (in UTC)'
,
function
(
ctx
)
{
ctx
.
setup
(
function
()
{
ctx
.
data
=
[{
target
:
'test.cpu1'
,
datapoints
:
[[
10
,
12
],
[
20
,
150563499792
0
]]
}];
ctx
.
data
=
[{
target
:
'test.cpu1'
,
datapoints
:
[[
10
,
12
],
[
20
,
500
0
]]
}];
ctx
.
ctrl
.
panel
.
valueName
=
'last_time'
;
ctx
.
ctrl
.
panel
.
format
=
'dateTimeAsUS'
;
// ctx.setIsUtc(true);
ctx
.
ctrl
.
dashboard
.
isTimezoneUtc
=
()
=>
true
;
});
it
(
'should set formatted value'
,
function
()
{
expect
(
ctx
.
data
.
valueFormatted
).
toBe
(
moment
.
utc
(
1505634997920
).
format
(
'MM/DD/YYYY h:mm:ss a'
)
);
expect
(
ctx
.
data
.
valueFormatted
).
toBe
(
'01/01/1970 12:00:05 am'
);
});
});
singleStatScenario
(
'showing last time from now instead of value'
,
function
(
ctx
)
{
beforeEach
(()
=>
{
// clock = sinon.useFakeTimers(epoch);
jest
.
useFakeTimers
();
//
jest.useFakeTimers();
});
ctx
.
setup
(
function
()
{
...
...
@@ -167,16 +170,11 @@ describe('SingleStatCtrl', function() {
});
afterEach
(()
=>
{
jest
.
clearAllTimers
();
//
jest.clearAllTimers();
});
});
singleStatScenario
(
'showing last time from now instead of value (in UTC)'
,
function
(
ctx
)
{
beforeEach
(()
=>
{
// clock = sinon.useFakeTimers(epoch);
jest
.
useFakeTimers
();
});
ctx
.
setup
(
function
()
{
ctx
.
data
=
[{
target
:
'test.cpu1'
,
datapoints
:
[[
10
,
12
],
[
20
,
1505634997920
]]
}];
ctx
.
ctrl
.
panel
.
valueName
=
'last_time'
;
...
...
@@ -187,10 +185,6 @@ describe('SingleStatCtrl', function() {
it
(
'should set formatted value'
,
function
()
{
expect
(
ctx
.
data
.
valueFormatted
).
toBe
(
'2 days ago'
);
});
afterEach
(()
=>
{
jest
.
clearAllTimers
();
});
});
singleStatScenario
(
'MainValue should use same number for decimals as displayed when checking thresholds'
,
function
(
...
...
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