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
56628996
Unverified
Commit
56628996
authored
Jun 14, 2018
by
Marcus Efraimsson
Committed by
GitHub
Jun 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12280 from dehrax/12224-elastic-response
karma to jest: 6 test files
parents
01074911
dbbd6b9b
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
240 additions
and
248 deletions
+240
-248
public/app/features/alerting/specs/threshold_mapper.jest.ts
+13
-13
public/app/plugins/datasource/elasticsearch/specs/elastic_response.jest.ts
+105
-106
public/app/plugins/datasource/elasticsearch/specs/index_pattern.jest.ts
+11
-12
public/app/plugins/datasource/elasticsearch/specs/query_builder.jest.ts
+57
-58
public/app/plugins/datasource/elasticsearch/specs/query_def.jest.ts
+34
-36
public/app/plugins/datasource/influxdb/specs/query_builder.jest.ts
+0
-1
public/app/plugins/panel/graph/specs/threshold_manager.jest.ts
+20
-22
No files found.
public/app/features/alerting/specs/threshold_mapper
_specs
.ts
→
public/app/features/alerting/specs/threshold_mapper
.jest
.ts
View file @
56628996
...
...
@@ -18,9 +18,9 @@ describe('ThresholdMapper', () => {
};
var
updated
=
ThresholdMapper
.
alertToGraphThresholds
(
panel
);
expect
(
updated
).
to
.
b
e
(
true
);
expect
(
panel
.
thresholds
[
0
].
op
).
to
.
b
e
(
'gt'
);
expect
(
panel
.
thresholds
[
0
].
value
).
to
.
b
e
(
100
);
expect
(
updated
).
to
B
e
(
true
);
expect
(
panel
.
thresholds
[
0
].
op
).
to
B
e
(
'gt'
);
expect
(
panel
.
thresholds
[
0
].
value
).
to
B
e
(
100
);
});
});
...
...
@@ -39,12 +39,12 @@ describe('ThresholdMapper', () => {
};
var
updated
=
ThresholdMapper
.
alertToGraphThresholds
(
panel
);
expect
(
updated
).
to
.
b
e
(
true
);
expect
(
panel
.
thresholds
[
0
].
op
).
to
.
b
e
(
'lt'
);
expect
(
panel
.
thresholds
[
0
].
value
).
to
.
b
e
(
100
);
expect
(
updated
).
to
B
e
(
true
);
expect
(
panel
.
thresholds
[
0
].
op
).
to
B
e
(
'lt'
);
expect
(
panel
.
thresholds
[
0
].
value
).
to
B
e
(
100
);
expect
(
panel
.
thresholds
[
1
].
op
).
to
.
b
e
(
'gt'
);
expect
(
panel
.
thresholds
[
1
].
value
).
to
.
b
e
(
200
);
expect
(
panel
.
thresholds
[
1
].
op
).
to
B
e
(
'gt'
);
expect
(
panel
.
thresholds
[
1
].
value
).
to
B
e
(
200
);
});
});
...
...
@@ -63,12 +63,12 @@ describe('ThresholdMapper', () => {
};
var
updated
=
ThresholdMapper
.
alertToGraphThresholds
(
panel
);
expect
(
updated
).
to
.
b
e
(
true
);
expect
(
panel
.
thresholds
[
0
].
op
).
to
.
b
e
(
'gt'
);
expect
(
panel
.
thresholds
[
0
].
value
).
to
.
b
e
(
100
);
expect
(
updated
).
to
B
e
(
true
);
expect
(
panel
.
thresholds
[
0
].
op
).
to
B
e
(
'gt'
);
expect
(
panel
.
thresholds
[
0
].
value
).
to
B
e
(
100
);
expect
(
panel
.
thresholds
[
1
].
op
).
to
.
b
e
(
'lt'
);
expect
(
panel
.
thresholds
[
1
].
value
).
to
.
b
e
(
200
);
expect
(
panel
.
thresholds
[
1
].
op
).
to
B
e
(
'lt'
);
expect
(
panel
.
thresholds
[
1
].
value
).
to
B
e
(
200
);
});
});
});
public/app/plugins/datasource/elasticsearch/specs/elastic_response
_specs
.ts
→
public/app/plugins/datasource/elasticsearch/specs/elastic_response
.jest
.ts
View file @
56628996
import
{
describe
,
beforeEach
,
it
,
expect
}
from
'test/lib/common'
;
import
{
ElasticResponse
}
from
'../elastic_response'
;
describe
(
'ElasticResponse'
,
function
()
{
describe
(
'ElasticResponse'
,
()
=>
{
var
targets
;
var
response
;
var
result
;
describe
(
'simple query and count'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'simple query and count'
,
()
=>
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -39,19 +38,19 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 1 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
1
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'Count'
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
.
b
e
(
10
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
1
]).
to
.
b
e
(
1000
);
it
(
'should return 1 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
1
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'Count'
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
B
e
(
10
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
1
]).
to
B
e
(
1000
);
});
});
describe
(
'simple query count & avg aggregation'
,
function
()
{
describe
(
'simple query count & avg aggregation'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -85,22 +84,22 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 2 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
.
b
e
(
10
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
1
]).
to
.
b
e
(
1000
);
it
(
'should return 2 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
B
e
(
10
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
1
]).
to
B
e
(
1000
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'Average value'
);
expect
(
result
.
data
[
1
].
datapoints
[
0
][
0
]).
to
.
b
e
(
88
);
expect
(
result
.
data
[
1
].
datapoints
[
1
][
0
]).
to
.
b
e
(
99
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'Average value'
);
expect
(
result
.
data
[
1
].
datapoints
[
0
][
0
]).
to
B
e
(
88
);
expect
(
result
.
data
[
1
].
datapoints
[
1
][
0
]).
to
B
e
(
99
);
});
});
describe
(
'single group by query one metric'
,
function
()
{
describe
(
'single group by query one metric'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -141,18 +140,18 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 2 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'server1'
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'server2'
);
it
(
'should return 2 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'server1'
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'server2'
);
});
});
describe
(
'single group by query two metrics'
,
function
()
{
describe
(
'single group by query two metrics'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -199,20 +198,20 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 2 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
4
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'server1 Count'
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'server1 Average @value'
);
expect
(
result
.
data
[
2
].
target
).
to
.
b
e
(
'server2 Count'
);
expect
(
result
.
data
[
3
].
target
).
to
.
b
e
(
'server2 Average @value'
);
it
(
'should return 2 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
4
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'server1 Count'
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'server1 Average @value'
);
expect
(
result
.
data
[
2
].
target
).
to
B
e
(
'server2 Count'
);
expect
(
result
.
data
[
3
].
target
).
to
B
e
(
'server2 Average @value'
);
});
});
describe
(
'with percentiles '
,
function
()
{
describe
(
'with percentiles '
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -246,21 +245,21 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 2 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'p75'
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'p90'
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
.
b
e
(
3.3
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
1
]).
to
.
b
e
(
1000
);
expect
(
result
.
data
[
1
].
datapoints
[
1
][
0
]).
to
.
b
e
(
4.5
);
it
(
'should return 2 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'p75'
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'p90'
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
B
e
(
3.3
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
1
]).
to
B
e
(
1000
);
expect
(
result
.
data
[
1
].
datapoints
[
1
][
0
]).
to
B
e
(
4.5
);
});
});
describe
(
'with extended_stats'
,
function
()
{
describe
(
'with extended_stats'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -322,21 +321,21 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 4 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
4
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
1
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'server1 Max'
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'server1 Std Dev Upper'
);
it
(
'should return 4 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
4
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
1
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'server1 Max'
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'server1 Std Dev Upper'
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
.
b
e
(
10.2
);
expect
(
result
.
data
[
1
].
datapoints
[
0
][
0
]).
to
.
b
e
(
3
);
expect
(
result
.
data
[
0
].
datapoints
[
0
][
0
]).
to
B
e
(
10.2
);
expect
(
result
.
data
[
1
].
datapoints
[
0
][
0
]).
to
B
e
(
3
);
});
});
describe
(
'single group by with alias pattern'
,
function
()
{
describe
(
'single group by with alias pattern'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -385,19 +384,19 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 2 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
3
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'server1 Count and {{not_exist}} server1'
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'server2 Count and {{not_exist}} server2'
);
expect
(
result
.
data
[
2
].
target
).
to
.
b
e
(
'0 Count and {{not_exist}} 0'
);
it
(
'should return 2 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
3
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'server1 Count and {{not_exist}} server1'
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'server2 Count and {{not_exist}} server2'
);
expect
(
result
.
data
[
2
].
target
).
to
B
e
(
'0 Count and {{not_exist}} 0'
);
});
});
describe
(
'histogram response'
,
function
()
{
describe
(
'histogram response'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -420,16 +419,16 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return table with byte and count'
,
function
()
{
expect
(
result
.
data
[
0
].
rows
.
length
).
to
.
b
e
(
3
);
expect
(
result
.
data
[
0
].
columns
).
to
.
eq
l
([{
text
:
'bytes'
,
filterable
:
true
},
{
text
:
'Count'
}]);
it
(
'should return table with byte and count'
,
()
=>
{
expect
(
result
.
data
[
0
].
rows
.
length
).
to
B
e
(
3
);
expect
(
result
.
data
[
0
].
columns
).
to
Equa
l
([{
text
:
'bytes'
,
filterable
:
true
},
{
text
:
'Count'
}]);
});
});
describe
(
'with two filters agg'
,
function
()
{
describe
(
'with two filters agg'
,
()
=>
{
var
result
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -472,16 +471,16 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return 2 series'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
.
b
e
(
'@metric:cpu'
);
expect
(
result
.
data
[
1
].
target
).
to
.
b
e
(
'@metric:logins.count'
);
it
(
'should return 2 series'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
target
).
to
B
e
(
'@metric:cpu'
);
expect
(
result
.
data
[
1
].
target
).
to
B
e
(
'@metric:logins.count'
);
});
});
describe
(
'with dropfirst and last aggregation'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'with dropfirst and last aggregation'
,
()
=>
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -528,14 +527,14 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should remove first and last value'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
1
);
it
(
'should remove first and last value'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
1
);
});
});
describe
(
'No group by time'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'No group by time'
,
()
=>
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -570,21 +569,21 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return table'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
1
);
expect
(
result
.
data
[
0
].
type
).
to
.
b
e
(
'table'
);
expect
(
result
.
data
[
0
].
rows
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
rows
[
0
][
0
]).
to
.
b
e
(
'server-1'
);
expect
(
result
.
data
[
0
].
rows
[
0
][
1
]).
to
.
b
e
(
1000
);
expect
(
result
.
data
[
0
].
rows
[
0
][
2
]).
to
.
b
e
(
369
);
it
(
'should return table'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
1
);
expect
(
result
.
data
[
0
].
type
).
to
B
e
(
'table'
);
expect
(
result
.
data
[
0
].
rows
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
rows
[
0
][
0
]).
to
B
e
(
'server-1'
);
expect
(
result
.
data
[
0
].
rows
[
0
][
1
]).
to
B
e
(
1000
);
expect
(
result
.
data
[
0
].
rows
[
0
][
2
]).
to
B
e
(
369
);
expect
(
result
.
data
[
0
].
rows
[
1
][
0
]).
to
.
b
e
(
'server-2'
);
expect
(
result
.
data
[
0
].
rows
[
1
][
1
]).
to
.
b
e
(
2000
);
expect
(
result
.
data
[
0
].
rows
[
1
][
0
]).
to
B
e
(
'server-2'
);
expect
(
result
.
data
[
0
].
rows
[
1
][
1
]).
to
B
e
(
2000
);
});
});
describe
(
'Multiple metrics of same type'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'Multiple metrics of same type'
,
()
=>
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -615,15 +614,15 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should include field in metric name'
,
function
()
{
expect
(
result
.
data
[
0
].
type
).
to
.
b
e
(
'table'
);
expect
(
result
.
data
[
0
].
rows
[
0
][
1
]).
to
.
b
e
(
1000
);
expect
(
result
.
data
[
0
].
rows
[
0
][
2
]).
to
.
b
e
(
3000
);
it
(
'should include field in metric name'
,
()
=>
{
expect
(
result
.
data
[
0
].
type
).
to
B
e
(
'table'
);
expect
(
result
.
data
[
0
].
rows
[
0
][
1
]).
to
B
e
(
1000
);
expect
(
result
.
data
[
0
].
rows
[
0
][
2
]).
to
B
e
(
3000
);
});
});
describe
(
'Raw documents query'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'Raw documents query'
,
()
=>
{
beforeEach
(
()
=>
{
targets
=
[
{
refId
:
'A'
,
...
...
@@ -657,13 +656,13 @@ describe('ElasticResponse', function() {
result
=
new
ElasticResponse
(
targets
,
response
).
getTimeSeries
();
});
it
(
'should return docs'
,
function
()
{
expect
(
result
.
data
.
length
).
to
.
b
e
(
1
);
expect
(
result
.
data
[
0
].
type
).
to
.
b
e
(
'docs'
);
expect
(
result
.
data
[
0
].
total
).
to
.
b
e
(
100
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
.
b
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
[
0
].
sourceProp
).
to
.
b
e
(
'asd'
);
expect
(
result
.
data
[
0
].
datapoints
[
0
].
fieldProp
).
to
.
b
e
(
'field'
);
it
(
'should return docs'
,
()
=>
{
expect
(
result
.
data
.
length
).
to
B
e
(
1
);
expect
(
result
.
data
[
0
].
type
).
to
B
e
(
'docs'
);
expect
(
result
.
data
[
0
].
total
).
to
B
e
(
100
);
expect
(
result
.
data
[
0
].
datapoints
.
length
).
to
B
e
(
2
);
expect
(
result
.
data
[
0
].
datapoints
[
0
].
sourceProp
).
to
B
e
(
'asd'
);
expect
(
result
.
data
[
0
].
datapoints
[
0
].
fieldProp
).
to
B
e
(
'field'
);
});
});
});
public/app/plugins/datasource/elasticsearch/specs/index_pattern
_specs
.ts
→
public/app/plugins/datasource/elasticsearch/specs/index_pattern
.jest
.ts
View file @
56628996
///<amd-dependency path="test/specs/helpers" name="helpers" />
import
{
describe
,
it
,
expect
}
from
'test/lib/common'
;
import
moment
from
'moment'
;
import
{
IndexPattern
}
from
'../index_pattern'
;
describe
(
'IndexPattern'
,
function
()
{
describe
(
'when getting index for today'
,
function
()
{
it
(
'should return correct index name'
,
function
()
{
describe
(
'IndexPattern'
,
()
=>
{
describe
(
'when getting index for today'
,
()
=>
{
test
(
'should return correct index name'
,
()
=>
{
var
pattern
=
new
IndexPattern
(
'[asd-]YYYY.MM.DD'
,
'Daily'
);
var
expected
=
'asd-'
+
moment
.
utc
().
format
(
'YYYY.MM.DD'
);
expect
(
pattern
.
getIndexForToday
()).
to
.
b
e
(
expected
);
expect
(
pattern
.
getIndexForToday
()).
to
B
e
(
expected
);
});
});
describe
(
'when getting index list for time range'
,
function
()
{
describe
(
'no interval'
,
function
()
{
it
(
'should return correct index'
,
function
()
{
describe
(
'when getting index list for time range'
,
()
=>
{
describe
(
'no interval'
,
()
=>
{
test
(
'should return correct index'
,
()
=>
{
var
pattern
=
new
IndexPattern
(
'my-metrics'
,
null
);
var
from
=
new
Date
(
2015
,
4
,
30
,
1
,
2
,
3
);
var
to
=
new
Date
(
2015
,
5
,
1
,
12
,
5
,
6
);
expect
(
pattern
.
getIndexList
(
from
,
to
)).
to
.
eq
l
(
'my-metrics'
);
expect
(
pattern
.
getIndexList
(
from
,
to
)).
to
Equa
l
(
'my-metrics'
);
});
});
describe
(
'daily'
,
function
()
{
it
(
'should return correct index list'
,
function
()
{
describe
(
'daily'
,
()
=>
{
test
(
'should return correct index list'
,
()
=>
{
var
pattern
=
new
IndexPattern
(
'[asd-]YYYY.MM.DD'
,
'Daily'
);
var
from
=
new
Date
(
1432940523000
);
var
to
=
new
Date
(
1433153106000
);
var
expected
=
[
'asd-2015.05.29'
,
'asd-2015.05.30'
,
'asd-2015.05.31'
,
'asd-2015.06.01'
];
expect
(
pattern
.
getIndexList
(
from
,
to
)).
to
.
eq
l
(
expected
);
expect
(
pattern
.
getIndexList
(
from
,
to
)).
to
Equa
l
(
expected
);
});
});
});
...
...
public/app/plugins/datasource/elasticsearch/specs/query_builder
_specs
.ts
→
public/app/plugins/datasource/elasticsearch/specs/query_builder
.jest
.ts
View file @
56628996
import
{
describe
,
beforeEach
,
it
,
expect
}
from
'test/lib/common'
;
import
{
ElasticQueryBuilder
}
from
'../query_builder'
;
describe
(
'ElasticQueryBuilder'
,
function
()
{
describe
(
'ElasticQueryBuilder'
,
()
=>
{
var
builder
;
beforeEach
(
function
()
{
beforeEach
(
()
=>
{
builder
=
new
ElasticQueryBuilder
({
timeField
:
'@timestamp'
});
});
it
(
'with defaults'
,
function
()
{
it
(
'with defaults'
,
()
=>
{
var
query
=
builder
.
build
({
metrics
:
[{
type
:
'Count'
,
id
:
'0'
}],
timeField
:
'@timestamp'
,
bucketAggs
:
[{
type
:
'date_histogram'
,
field
:
'@timestamp'
,
id
:
'1'
}],
});
expect
(
query
.
query
.
bool
.
filter
[
0
].
range
[
'@timestamp'
].
gte
).
to
.
b
e
(
'$timeFrom'
);
expect
(
query
.
aggs
[
'1'
].
date_histogram
.
extended_bounds
.
min
).
to
.
b
e
(
'$timeFrom'
);
expect
(
query
.
query
.
bool
.
filter
[
0
].
range
[
'@timestamp'
].
gte
).
to
B
e
(
'$timeFrom'
);
expect
(
query
.
aggs
[
'1'
].
date_histogram
.
extended_bounds
.
min
).
to
B
e
(
'$timeFrom'
);
});
it
(
'with defaults on es5.x'
,
function
()
{
it
(
'with defaults on es5.x'
,
()
=>
{
var
builder_5x
=
new
ElasticQueryBuilder
({
timeField
:
'@timestamp'
,
esVersion
:
5
,
...
...
@@ -31,11 +30,11 @@ describe('ElasticQueryBuilder', function() {
bucketAggs
:
[{
type
:
'date_histogram'
,
field
:
'@timestamp'
,
id
:
'1'
}],
});
expect
(
query
.
query
.
bool
.
filter
[
0
].
range
[
'@timestamp'
].
gte
).
to
.
b
e
(
'$timeFrom'
);
expect
(
query
.
aggs
[
'1'
].
date_histogram
.
extended_bounds
.
min
).
to
.
b
e
(
'$timeFrom'
);
expect
(
query
.
query
.
bool
.
filter
[
0
].
range
[
'@timestamp'
].
gte
).
to
B
e
(
'$timeFrom'
);
expect
(
query
.
aggs
[
'1'
].
date_histogram
.
extended_bounds
.
min
).
to
B
e
(
'$timeFrom'
);
});
it
(
'with multiple bucket aggs'
,
function
()
{
it
(
'with multiple bucket aggs'
,
()
=>
{
var
query
=
builder
.
build
({
metrics
:
[{
type
:
'count'
,
id
:
'1'
}],
timeField
:
'@timestamp'
,
...
...
@@ -45,11 +44,11 @@ describe('ElasticQueryBuilder', function() {
],
});
expect
(
query
.
aggs
[
'2'
].
terms
.
field
).
to
.
b
e
(
'@host'
);
expect
(
query
.
aggs
[
'2'
].
aggs
[
'3'
].
date_histogram
.
field
).
to
.
b
e
(
'@timestamp'
);
expect
(
query
.
aggs
[
'2'
].
terms
.
field
).
to
B
e
(
'@host'
);
expect
(
query
.
aggs
[
'2'
].
aggs
[
'3'
].
date_histogram
.
field
).
to
B
e
(
'@timestamp'
);
});
it
(
'with select field'
,
function
()
{
it
(
'with select field'
,
()
=>
{
var
query
=
builder
.
build
(
{
metrics
:
[{
type
:
'avg'
,
field
:
'@value'
,
id
:
'1'
}],
...
...
@@ -60,10 +59,10 @@ describe('ElasticQueryBuilder', function() {
);
var
aggs
=
query
.
aggs
[
'2'
].
aggs
;
expect
(
aggs
[
'1'
].
avg
.
field
).
to
.
b
e
(
'@value'
);
expect
(
aggs
[
'1'
].
avg
.
field
).
to
B
e
(
'@value'
);
});
it
(
'with term agg and order by metric agg'
,
function
()
{
it
(
'with term agg and order by metric agg'
,
()
=>
{
var
query
=
builder
.
build
(
{
metrics
:
[{
type
:
'count'
,
id
:
'1'
},
{
type
:
'avg'
,
field
:
'@value'
,
id
:
'5'
}],
...
...
@@ -84,11 +83,11 @@ describe('ElasticQueryBuilder', function() {
var
firstLevel
=
query
.
aggs
[
'2'
];
var
secondLevel
=
firstLevel
.
aggs
[
'3'
];
expect
(
firstLevel
.
aggs
[
'5'
].
avg
.
field
).
to
.
b
e
(
'@value'
);
expect
(
secondLevel
.
aggs
[
'5'
].
avg
.
field
).
to
.
b
e
(
'@value'
);
expect
(
firstLevel
.
aggs
[
'5'
].
avg
.
field
).
to
B
e
(
'@value'
);
expect
(
secondLevel
.
aggs
[
'5'
].
avg
.
field
).
to
B
e
(
'@value'
);
});
it
(
'with metric percentiles'
,
function
()
{
it
(
'with metric percentiles'
,
()
=>
{
var
query
=
builder
.
build
(
{
metrics
:
[
...
...
@@ -109,11 +108,11 @@ describe('ElasticQueryBuilder', function() {
var
firstLevel
=
query
.
aggs
[
'3'
];
expect
(
firstLevel
.
aggs
[
'1'
].
percentiles
.
field
).
to
.
b
e
(
'@load_time'
);
expect
(
firstLevel
.
aggs
[
'1'
].
percentiles
.
percents
).
to
.
eq
l
([
1
,
2
,
3
,
4
]);
expect
(
firstLevel
.
aggs
[
'1'
].
percentiles
.
field
).
to
B
e
(
'@load_time'
);
expect
(
firstLevel
.
aggs
[
'1'
].
percentiles
.
percents
).
to
Equa
l
([
1
,
2
,
3
,
4
]);
});
it
(
'with filters aggs'
,
function
()
{
it
(
'with filters aggs'
,
()
=>
{
var
query
=
builder
.
build
({
metrics
:
[{
type
:
'count'
,
id
:
'1'
}],
timeField
:
'@timestamp'
,
...
...
@@ -129,12 +128,12 @@ describe('ElasticQueryBuilder', function() {
],
});
expect
(
query
.
aggs
[
'2'
].
filters
.
filters
[
'@metric:cpu'
].
query_string
.
query
).
to
.
b
e
(
'@metric:cpu'
);
expect
(
query
.
aggs
[
'2'
].
filters
.
filters
[
'@metric:logins.count'
].
query_string
.
query
).
to
.
b
e
(
'@metric:logins.count'
);
expect
(
query
.
aggs
[
'2'
].
aggs
[
'4'
].
date_histogram
.
field
).
to
.
b
e
(
'@timestamp'
);
expect
(
query
.
aggs
[
'2'
].
filters
.
filters
[
'@metric:cpu'
].
query_string
.
query
).
to
B
e
(
'@metric:cpu'
);
expect
(
query
.
aggs
[
'2'
].
filters
.
filters
[
'@metric:logins.count'
].
query_string
.
query
).
to
B
e
(
'@metric:logins.count'
);
expect
(
query
.
aggs
[
'2'
].
aggs
[
'4'
].
date_histogram
.
field
).
to
B
e
(
'@timestamp'
);
});
it
(
'with filters aggs on es5.x'
,
function
()
{
it
(
'with filters aggs on es5.x'
,
()
=>
{
var
builder_5x
=
new
ElasticQueryBuilder
({
timeField
:
'@timestamp'
,
esVersion
:
5
,
...
...
@@ -154,31 +153,31 @@ describe('ElasticQueryBuilder', function() {
],
});
expect
(
query
.
aggs
[
'2'
].
filters
.
filters
[
'@metric:cpu'
].
query_string
.
query
).
to
.
b
e
(
'@metric:cpu'
);
expect
(
query
.
aggs
[
'2'
].
filters
.
filters
[
'@metric:logins.count'
].
query_string
.
query
).
to
.
b
e
(
'@metric:logins.count'
);
expect
(
query
.
aggs
[
'2'
].
aggs
[
'4'
].
date_histogram
.
field
).
to
.
b
e
(
'@timestamp'
);
expect
(
query
.
aggs
[
'2'
].
filters
.
filters
[
'@metric:cpu'
].
query_string
.
query
).
to
B
e
(
'@metric:cpu'
);
expect
(
query
.
aggs
[
'2'
].
filters
.
filters
[
'@metric:logins.count'
].
query_string
.
query
).
to
B
e
(
'@metric:logins.count'
);
expect
(
query
.
aggs
[
'2'
].
aggs
[
'4'
].
date_histogram
.
field
).
to
B
e
(
'@timestamp'
);
});
it
(
'with raw_document metric'
,
function
()
{
it
(
'with raw_document metric'
,
()
=>
{
var
query
=
builder
.
build
({
metrics
:
[{
type
:
'raw_document'
,
id
:
'1'
,
settings
:
{}
}],
timeField
:
'@timestamp'
,
bucketAggs
:
[],
});
expect
(
query
.
size
).
to
.
b
e
(
500
);
expect
(
query
.
size
).
to
B
e
(
500
);
});
it
(
'with raw_document metric size set'
,
function
()
{
it
(
'with raw_document metric size set'
,
()
=>
{
var
query
=
builder
.
build
({
metrics
:
[{
type
:
'raw_document'
,
id
:
'1'
,
settings
:
{
size
:
1337
}
}],
timeField
:
'@timestamp'
,
bucketAggs
:
[],
});
expect
(
query
.
size
).
to
.
b
e
(
1337
);
expect
(
query
.
size
).
to
B
e
(
1337
);
});
it
(
'with moving average'
,
function
()
{
it
(
'with moving average'
,
()
=>
{
var
query
=
builder
.
build
({
metrics
:
[
{
...
...
@@ -198,12 +197,12 @@ describe('ElasticQueryBuilder', function() {
var
firstLevel
=
query
.
aggs
[
'3'
];
expect
(
firstLevel
.
aggs
[
'2'
]).
not
.
to
.
b
e
(
undefined
);
expect
(
firstLevel
.
aggs
[
'2'
].
moving_avg
).
not
.
to
.
b
e
(
undefined
);
expect
(
firstLevel
.
aggs
[
'2'
].
moving_avg
.
buckets_path
).
to
.
b
e
(
'3'
);
expect
(
firstLevel
.
aggs
[
'2'
]).
not
.
to
B
e
(
undefined
);
expect
(
firstLevel
.
aggs
[
'2'
].
moving_avg
).
not
.
to
B
e
(
undefined
);
expect
(
firstLevel
.
aggs
[
'2'
].
moving_avg
.
buckets_path
).
to
B
e
(
'3'
);
});
it
(
'with broken moving average'
,
function
()
{
it
(
'with broken moving average'
,
()
=>
{
var
query
=
builder
.
build
({
metrics
:
[
{
...
...
@@ -227,13 +226,13 @@ describe('ElasticQueryBuilder', function() {
var
firstLevel
=
query
.
aggs
[
'3'
];
expect
(
firstLevel
.
aggs
[
'2'
]).
not
.
to
.
b
e
(
undefined
);
expect
(
firstLevel
.
aggs
[
'2'
].
moving_avg
).
not
.
to
.
b
e
(
undefined
);
expect
(
firstLevel
.
aggs
[
'2'
].
moving_avg
.
buckets_path
).
to
.
b
e
(
'3'
);
expect
(
firstLevel
.
aggs
[
'4'
]).
to
.
b
e
(
undefined
);
expect
(
firstLevel
.
aggs
[
'2'
]).
not
.
to
B
e
(
undefined
);
expect
(
firstLevel
.
aggs
[
'2'
].
moving_avg
).
not
.
to
B
e
(
undefined
);
expect
(
firstLevel
.
aggs
[
'2'
].
moving_avg
.
buckets_path
).
to
B
e
(
'3'
);
expect
(
firstLevel
.
aggs
[
'4'
]).
to
B
e
(
undefined
);
});
it
(
'with derivative'
,
function
()
{
it
(
'with derivative'
,
()
=>
{
var
query
=
builder
.
build
({
metrics
:
[
{
...
...
@@ -252,12 +251,12 @@ describe('ElasticQueryBuilder', function() {
var
firstLevel
=
query
.
aggs
[
'3'
];
expect
(
firstLevel
.
aggs
[
'2'
]).
not
.
to
.
b
e
(
undefined
);
expect
(
firstLevel
.
aggs
[
'2'
].
derivative
).
not
.
to
.
b
e
(
undefined
);
expect
(
firstLevel
.
aggs
[
'2'
].
derivative
.
buckets_path
).
to
.
b
e
(
'3'
);
expect
(
firstLevel
.
aggs
[
'2'
]).
not
.
to
B
e
(
undefined
);
expect
(
firstLevel
.
aggs
[
'2'
].
derivative
).
not
.
to
B
e
(
undefined
);
expect
(
firstLevel
.
aggs
[
'2'
].
derivative
.
buckets_path
).
to
B
e
(
'3'
);
});
it
(
'with histogram'
,
function
()
{
it
(
'with histogram'
,
()
=>
{
var
query
=
builder
.
build
({
metrics
:
[{
id
:
'1'
,
type
:
'count'
}],
bucketAggs
:
[
...
...
@@ -271,13 +270,13 @@ describe('ElasticQueryBuilder', function() {
});
var
firstLevel
=
query
.
aggs
[
'3'
];
expect
(
firstLevel
.
histogram
.
field
).
to
.
b
e
(
'bytes'
);
expect
(
firstLevel
.
histogram
.
interval
).
to
.
b
e
(
10
);
expect
(
firstLevel
.
histogram
.
min_doc_count
).
to
.
b
e
(
2
);
expect
(
firstLevel
.
histogram
.
missing
).
to
.
b
e
(
5
);
expect
(
firstLevel
.
histogram
.
field
).
to
B
e
(
'bytes'
);
expect
(
firstLevel
.
histogram
.
interval
).
to
B
e
(
10
);
expect
(
firstLevel
.
histogram
.
min_doc_count
).
to
B
e
(
2
);
expect
(
firstLevel
.
histogram
.
missing
).
to
B
e
(
5
);
});
it
(
'with adhoc filters'
,
function
()
{
it
(
'with adhoc filters'
,
()
=>
{
var
query
=
builder
.
build
(
{
metrics
:
[{
type
:
'Count'
,
id
:
'0'
}],
...
...
@@ -295,12 +294,12 @@ describe('ElasticQueryBuilder', function() {
]
);
expect
(
query
.
query
.
bool
.
must
[
0
].
match_phrase
[
'key1'
].
query
).
to
.
b
e
(
'value1'
);
expect
(
query
.
query
.
bool
.
must
[
1
].
match_phrase
[
'key2'
].
query
).
to
.
b
e
(
'value2'
);
expect
(
query
.
query
.
bool
.
must_not
[
0
].
match_phrase
[
'key2'
].
query
).
to
.
b
e
(
'value2'
);
expect
(
query
.
query
.
bool
.
filter
[
2
].
range
[
'key3'
].
lt
).
to
.
b
e
(
'value3'
);
expect
(
query
.
query
.
bool
.
filter
[
3
].
range
[
'key4'
].
gt
).
to
.
b
e
(
'value4'
);
expect
(
query
.
query
.
bool
.
filter
[
4
].
regexp
[
'key5'
]).
to
.
b
e
(
'value5'
);
expect
(
query
.
query
.
bool
.
filter
[
5
].
bool
.
must_not
.
regexp
[
'key6'
]).
to
.
b
e
(
'value6'
);
expect
(
query
.
query
.
bool
.
must
[
0
].
match_phrase
[
'key1'
].
query
).
to
B
e
(
'value1'
);
expect
(
query
.
query
.
bool
.
must
[
1
].
match_phrase
[
'key2'
].
query
).
to
B
e
(
'value2'
);
expect
(
query
.
query
.
bool
.
must_not
[
0
].
match_phrase
[
'key2'
].
query
).
to
B
e
(
'value2'
);
expect
(
query
.
query
.
bool
.
filter
[
2
].
range
[
'key3'
].
lt
).
to
B
e
(
'value3'
);
expect
(
query
.
query
.
bool
.
filter
[
3
].
range
[
'key4'
].
gt
).
to
B
e
(
'value4'
);
expect
(
query
.
query
.
bool
.
filter
[
4
].
regexp
[
'key5'
]).
to
B
e
(
'value5'
);
expect
(
query
.
query
.
bool
.
filter
[
5
].
bool
.
must_not
.
regexp
[
'key6'
]).
to
B
e
(
'value6'
);
});
});
public/app/plugins/datasource/elasticsearch/specs/query_def
_specs
.ts
→
public/app/plugins/datasource/elasticsearch/specs/query_def
.jest
.ts
View file @
56628996
import
{
describe
,
it
,
expect
}
from
'test/lib/common'
;
import
*
as
queryDef
from
'../query_def'
;
describe
(
'ElasticQueryDef'
,
function
()
{
describe
(
'getPipelineAggOptions'
,
function
()
{
describe
(
'with zero targets'
,
function
()
{
describe
(
'ElasticQueryDef'
,
()
=>
{
describe
(
'getPipelineAggOptions'
,
()
=>
{
describe
(
'with zero targets'
,
()
=>
{
var
response
=
queryDef
.
getPipelineAggOptions
([]);
it
(
'should return zero'
,
function
()
{
expect
(
response
.
length
).
to
.
b
e
(
0
);
test
(
'should return zero'
,
()
=>
{
expect
(
response
.
length
).
to
B
e
(
0
);
});
});
describe
(
'with count and sum targets'
,
function
()
{
describe
(
'with count and sum targets'
,
()
=>
{
var
targets
=
{
metrics
:
[{
type
:
'count'
,
field
:
'@value'
},
{
type
:
'sum'
,
field
:
'@value'
}],
};
var
response
=
queryDef
.
getPipelineAggOptions
(
targets
);
it
(
'should return zero'
,
function
()
{
expect
(
response
.
length
).
to
.
b
e
(
2
);
test
(
'should return zero'
,
()
=>
{
expect
(
response
.
length
).
to
B
e
(
2
);
});
});
describe
(
'with count and moving average targets'
,
function
()
{
describe
(
'with count and moving average targets'
,
()
=>
{
var
targets
=
{
metrics
:
[{
type
:
'count'
,
field
:
'@value'
},
{
type
:
'moving_avg'
,
field
:
'@value'
}],
};
var
response
=
queryDef
.
getPipelineAggOptions
(
targets
);
it
(
'should return one'
,
function
()
{
expect
(
response
.
length
).
to
.
b
e
(
1
);
test
(
'should return one'
,
()
=>
{
expect
(
response
.
length
).
to
B
e
(
1
);
});
});
describe
(
'with derivatives targets'
,
function
()
{
describe
(
'with derivatives targets'
,
()
=>
{
var
targets
=
{
metrics
:
[{
type
:
'derivative'
,
field
:
'@value'
}],
};
var
response
=
queryDef
.
getPipelineAggOptions
(
targets
);
it
(
'should return zero'
,
function
()
{
expect
(
response
.
length
).
to
.
b
e
(
0
);
test
(
'should return zero'
,
()
=>
{
expect
(
response
.
length
).
to
B
e
(
0
);
});
});
});
describe
(
'isPipelineMetric'
,
function
()
{
describe
(
'moving_avg'
,
function
()
{
describe
(
'isPipelineMetric'
,
()
=>
{
describe
(
'moving_avg'
,
()
=>
{
var
result
=
queryDef
.
isPipelineAgg
(
'moving_avg'
);
it
(
'is pipe line metric'
,
function
()
{
expect
(
result
).
to
.
b
e
(
true
);
test
(
'is pipe line metric'
,
()
=>
{
expect
(
result
).
to
B
e
(
true
);
});
});
describe
(
'count'
,
function
()
{
describe
(
'count'
,
()
=>
{
var
result
=
queryDef
.
isPipelineAgg
(
'count'
);
it
(
'is not pipe line metric'
,
function
()
{
expect
(
result
).
to
.
b
e
(
false
);
test
(
'is not pipe line metric'
,
()
=>
{
expect
(
result
).
to
B
e
(
false
);
});
});
});
describe
(
'pipeline aggs depending on esverison'
,
function
()
{
describe
(
'using esversion undefined'
,
function
()
{
it
(
'should not get pipeline aggs'
,
function
()
{
expect
(
queryDef
.
getMetricAggTypes
(
undefined
).
length
).
to
.
b
e
(
9
);
describe
(
'pipeline aggs depending on esverison'
,
()
=>
{
describe
(
'using esversion undefined'
,
()
=>
{
test
(
'should not get pipeline aggs'
,
()
=>
{
expect
(
queryDef
.
getMetricAggTypes
(
undefined
).
length
).
to
B
e
(
9
);
});
});
describe
(
'using esversion 1'
,
function
()
{
it
(
'should not get pipeline aggs'
,
function
()
{
expect
(
queryDef
.
getMetricAggTypes
(
1
).
length
).
to
.
b
e
(
9
);
describe
(
'using esversion 1'
,
()
=>
{
test
(
'should not get pipeline aggs'
,
()
=>
{
expect
(
queryDef
.
getMetricAggTypes
(
1
).
length
).
to
B
e
(
9
);
});
});
describe
(
'using esversion 2'
,
function
()
{
it
(
'should get pipeline aggs'
,
function
()
{
expect
(
queryDef
.
getMetricAggTypes
(
2
).
length
).
to
.
b
e
(
11
);
describe
(
'using esversion 2'
,
()
=>
{
test
(
'should get pipeline aggs'
,
()
=>
{
expect
(
queryDef
.
getMetricAggTypes
(
2
).
length
).
to
B
e
(
11
);
});
});
describe
(
'using esversion 5'
,
function
()
{
it
(
'should get pipeline aggs'
,
function
()
{
expect
(
queryDef
.
getMetricAggTypes
(
5
).
length
).
to
.
b
e
(
11
);
describe
(
'using esversion 5'
,
()
=>
{
test
(
'should get pipeline aggs'
,
()
=>
{
expect
(
queryDef
.
getMetricAggTypes
(
5
).
length
).
to
B
e
(
11
);
});
});
});
...
...
public/app/plugins/datasource/influxdb/specs/query_builder.jest.ts
View file @
56628996
import
{
describe
,
it
,
expect
}
from
'test/lib/common'
;
import
{
InfluxQueryBuilder
}
from
'../query_builder'
;
describe
(
'InfluxQueryBuilder'
,
function
()
{
...
...
public/app/plugins/panel/graph/specs/threshold_manager
_specs
.ts
→
public/app/plugins/panel/graph/specs/threshold_manager
.jest
.ts
View file @
56628996
import
{
describe
,
it
,
expect
}
from
'../../../../../test/lib/common'
;
import
angular
from
'angular'
;
import
TimeSeries
from
'app/core/time_series2'
;
import
{
ThresholdManager
}
from
'../threshold_manager'
;
...
...
@@ -38,16 +36,16 @@ describe('ThresholdManager', function() {
it
(
'should add fill for threshold with fill: true'
,
function
()
{
var
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
markings
[
0
].
yaxis
.
from
).
to
.
b
e
(
300
);
expect
(
markings
[
0
].
yaxis
.
to
).
to
.
b
e
(
Infinity
);
expect
(
markings
[
0
].
color
).
to
.
b
e
(
'rgba(234, 112, 112, 0.12)'
);
expect
(
markings
[
0
].
yaxis
.
from
).
to
B
e
(
300
);
expect
(
markings
[
0
].
yaxis
.
to
).
to
B
e
(
Infinity
);
expect
(
markings
[
0
].
color
).
to
B
e
(
'rgba(234, 112, 112, 0.12)'
);
});
it
(
'should add line'
,
function
()
{
var
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
markings
[
1
].
yaxis
.
from
).
to
.
b
e
(
300
);
expect
(
markings
[
1
].
yaxis
.
to
).
to
.
b
e
(
300
);
expect
(
markings
[
1
].
color
).
to
.
b
e
(
'rgba(237, 46, 24, 0.60)'
);
expect
(
markings
[
1
].
yaxis
.
from
).
to
B
e
(
300
);
expect
(
markings
[
1
].
yaxis
.
to
).
to
B
e
(
300
);
expect
(
markings
[
1
].
color
).
to
B
e
(
'rgba(237, 46, 24, 0.60)'
);
});
});
...
...
@@ -59,14 +57,14 @@ describe('ThresholdManager', function() {
it
(
'should add fill for first thresholds to next threshold'
,
function
()
{
var
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
markings
[
0
].
yaxis
.
from
).
to
.
b
e
(
200
);
expect
(
markings
[
0
].
yaxis
.
to
).
to
.
b
e
(
300
);
expect
(
markings
[
0
].
yaxis
.
from
).
to
B
e
(
200
);
expect
(
markings
[
0
].
yaxis
.
to
).
to
B
e
(
300
);
});
it
(
'should add fill for last thresholds to infinity'
,
function
()
{
var
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
markings
[
1
].
yaxis
.
from
).
to
.
b
e
(
300
);
expect
(
markings
[
1
].
yaxis
.
to
).
to
.
b
e
(
Infinity
);
expect
(
markings
[
1
].
yaxis
.
from
).
to
B
e
(
300
);
expect
(
markings
[
1
].
yaxis
.
to
).
to
B
e
(
Infinity
);
});
});
...
...
@@ -78,14 +76,14 @@ describe('ThresholdManager', function() {
it
(
'should add fill for first thresholds to next threshold'
,
function
()
{
var
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
markings
[
0
].
yaxis
.
from
).
to
.
b
e
(
300
);
expect
(
markings
[
0
].
yaxis
.
to
).
to
.
b
e
(
200
);
expect
(
markings
[
0
].
yaxis
.
from
).
to
B
e
(
300
);
expect
(
markings
[
0
].
yaxis
.
to
).
to
B
e
(
200
);
});
it
(
'should add fill for last thresholds to itself'
,
function
()
{
var
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
markings
[
1
].
yaxis
.
from
).
to
.
b
e
(
200
);
expect
(
markings
[
1
].
yaxis
.
to
).
to
.
b
e
(
200
);
expect
(
markings
[
1
].
yaxis
.
from
).
to
B
e
(
200
);
expect
(
markings
[
1
].
yaxis
.
to
).
to
B
e
(
200
);
});
});
...
...
@@ -97,14 +95,14 @@ describe('ThresholdManager', function() {
it
(
'should add fill for first thresholds to next threshold'
,
function
()
{
var
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
markings
[
0
].
yaxis
.
from
).
to
.
b
e
(
300
);
expect
(
markings
[
0
].
yaxis
.
to
).
to
.
b
e
(
Infinity
);
expect
(
markings
[
0
].
yaxis
.
from
).
to
B
e
(
300
);
expect
(
markings
[
0
].
yaxis
.
to
).
to
B
e
(
Infinity
);
});
it
(
'should add fill for last thresholds to itself'
,
function
()
{
var
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
markings
[
1
].
yaxis
.
from
).
to
.
b
e
(
200
);
expect
(
markings
[
1
].
yaxis
.
to
).
to
.
b
e
(
-
Infinity
);
expect
(
markings
[
1
].
yaxis
.
from
).
to
B
e
(
200
);
expect
(
markings
[
1
].
yaxis
.
to
).
to
B
e
(
-
Infinity
);
});
});
...
...
@@ -130,12 +128,12 @@ describe('ThresholdManager', function() {
it
(
'should add first threshold for left axis'
,
function
()
{
var
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
markings
[
0
].
yaxis
.
from
).
to
.
b
e
(
100
);
expect
(
markings
[
0
].
yaxis
.
from
).
to
B
e
(
100
);
});
it
(
'should add second threshold for right axis'
,
function
()
{
var
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
markings
[
1
].
y2axis
.
from
).
to
.
b
e
(
200
);
expect
(
markings
[
1
].
y2axis
.
from
).
to
B
e
(
200
);
});
});
});
...
...
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