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
77b7f4b3
Commit
77b7f4b3
authored
Aug 02, 2017
by
Alexander Zobnin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
heatmap: add unit tests for convertToCards()
parent
c7e8b98d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
1 deletions
+43
-1
public/app/plugins/panel/heatmap/specs/heatmap_data_converter_specs.ts
+43
-1
No files found.
public/app/plugins/panel/heatmap/specs/heatmap_data_converter_specs.ts
View file @
77b7f4b3
...
...
@@ -3,7 +3,8 @@
import
_
from
'lodash'
;
import
{
describe
,
beforeEach
,
it
,
sinon
,
expect
,
angularMocks
}
from
'../../../../../test/lib/common'
;
import
TimeSeries
from
'app/core/time_series2'
;
import
{
convertToHeatMap
,
elasticHistogramToHeatmap
,
calculateBucketSize
,
isHeatmapDataEqual
}
from
'../heatmap_data_converter'
;
import
{
convertToHeatMap
,
convertToCards
,
elasticHistogramToHeatmap
,
calculateBucketSize
,
isHeatmapDataEqual
}
from
'../heatmap_data_converter'
;
describe
(
'isHeatmapDataEqual'
,
()
=>
{
let
ctx
:
any
=
{};
...
...
@@ -244,6 +245,47 @@ describe('ES Histogram converter', () => {
});
});
describe
(
'convertToCards'
,
()
=>
{
let
buckets
=
{};
beforeEach
(()
=>
{
buckets
=
{
'1422774000000'
:
{
x
:
1422774000000
,
buckets
:
{
'1'
:
{
y
:
1
,
values
:
[
1
],
count
:
1
,
bounds
:
{}
},
'2'
:
{
y
:
2
,
values
:
[
2
],
count
:
1
,
bounds
:
{}
}
}
},
'1422774060000'
:
{
x
:
1422774060000
,
buckets
:
{
'2'
:
{
y
:
2
,
values
:
[
2
,
3
],
count
:
2
,
bounds
:
{}
}
}
},
};
});
it
(
'should build proper cards data'
,
()
=>
{
let
expectedCards
=
[
{
x
:
1422774000000
,
y
:
1
,
count
:
1
,
values
:
[
1
],
yBounds
:
{}},
{
x
:
1422774000000
,
y
:
2
,
count
:
1
,
values
:
[
2
],
yBounds
:
{}},
{
x
:
1422774060000
,
y
:
2
,
count
:
2
,
values
:
[
2
,
3
],
yBounds
:
{}}
];
let
{
cards
,
cardStats
}
=
convertToCards
(
buckets
);
expect
(
cards
).
to
.
eql
(
expectedCards
);
});
it
(
'should build proper cards stats'
,
()
=>
{
let
expectedStats
=
{
min
:
1
,
max
:
2
};
let
{
cards
,
cardStats
}
=
convertToCards
(
buckets
);
expect
(
cardStats
).
to
.
eql
(
expectedStats
);
});
});
/**
* Compare two numbers with given precision. Suitable for compare float numbers after conversions with precision loss.
* @param a
...
...
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