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
2465f533
Commit
2465f533
authored
Jun 14, 2018
by
Tobias Skarhed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Karma to Jest: query_def, index_pattern
parent
a911d36d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
48 deletions
+45
-48
public/app/plugins/datasource/elasticsearch/specs/index_pattern.jest.ts
+11
-12
public/app/plugins/datasource/elasticsearch/specs/query_def.jest.ts
+34
-36
No files found.
public/app/plugins/datasource/elasticsearch/specs/index_pattern
_specs
.ts
→
public/app/plugins/datasource/elasticsearch/specs/index_pattern
.jest
.ts
View file @
2465f533
///<amd-dependency path="test/specs/helpers" name="helpers" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
import
{
describe
,
it
,
expect
}
from
'test/lib/common'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
{
IndexPattern
}
from
'../index_pattern'
;
import
{
IndexPattern
}
from
'../index_pattern'
;
describe
(
'IndexPattern'
,
function
()
{
describe
(
'IndexPattern'
,
()
=>
{
describe
(
'when getting index for today'
,
function
()
{
describe
(
'when getting index for today'
,
()
=>
{
it
(
'should return correct index name'
,
function
()
{
test
(
'should return correct index name'
,
()
=>
{
var
pattern
=
new
IndexPattern
(
'[asd-]YYYY.MM.DD'
,
'Daily'
);
var
pattern
=
new
IndexPattern
(
'[asd-]YYYY.MM.DD'
,
'Daily'
);
var
expected
=
'asd-'
+
moment
.
utc
().
format
(
'YYYY.MM.DD'
);
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
(
'when getting index list for time range'
,
()
=>
{
describe
(
'no interval'
,
function
()
{
describe
(
'no interval'
,
()
=>
{
it
(
'should return correct index'
,
function
()
{
test
(
'should return correct index'
,
()
=>
{
var
pattern
=
new
IndexPattern
(
'my-metrics'
,
null
);
var
pattern
=
new
IndexPattern
(
'my-metrics'
,
null
);
var
from
=
new
Date
(
2015
,
4
,
30
,
1
,
2
,
3
);
var
from
=
new
Date
(
2015
,
4
,
30
,
1
,
2
,
3
);
var
to
=
new
Date
(
2015
,
5
,
1
,
12
,
5
,
6
);
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
()
{
describe
(
'daily'
,
()
=>
{
it
(
'should return correct index list'
,
function
()
{
test
(
'should return correct index list'
,
()
=>
{
var
pattern
=
new
IndexPattern
(
'[asd-]YYYY.MM.DD'
,
'Daily'
);
var
pattern
=
new
IndexPattern
(
'[asd-]YYYY.MM.DD'
,
'Daily'
);
var
from
=
new
Date
(
1432940523000
);
var
from
=
new
Date
(
1432940523000
);
var
to
=
new
Date
(
1433153106000
);
var
to
=
new
Date
(
1433153106000
);
var
expected
=
[
'asd-2015.05.29'
,
'asd-2015.05.30'
,
'asd-2015.05.31'
,
'asd-2015.06.01'
];
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_def
_specs
.ts
→
public/app/plugins/datasource/elasticsearch/specs/query_def
.jest
.ts
View file @
2465f533
import
{
describe
,
it
,
expect
}
from
'test/lib/common'
;
import
*
as
queryDef
from
'../query_def'
;
import
*
as
queryDef
from
'../query_def'
;
describe
(
'ElasticQueryDef'
,
function
()
{
describe
(
'ElasticQueryDef'
,
()
=>
{
describe
(
'getPipelineAggOptions'
,
function
()
{
describe
(
'getPipelineAggOptions'
,
()
=>
{
describe
(
'with zero targets'
,
function
()
{
describe
(
'with zero targets'
,
()
=>
{
var
response
=
queryDef
.
getPipelineAggOptions
([]);
var
response
=
queryDef
.
getPipelineAggOptions
([]);
it
(
'should return zero'
,
function
()
{
test
(
'should return zero'
,
()
=>
{
expect
(
response
.
length
).
to
.
b
e
(
0
);
expect
(
response
.
length
).
to
B
e
(
0
);
});
});
});
});
describe
(
'with count and sum targets'
,
function
()
{
describe
(
'with count and sum targets'
,
()
=>
{
var
targets
=
{
var
targets
=
{
metrics
:
[{
type
:
'count'
,
field
:
'@value'
},
{
type
:
'sum'
,
field
:
'@value'
}],
metrics
:
[{
type
:
'count'
,
field
:
'@value'
},
{
type
:
'sum'
,
field
:
'@value'
}],
};
};
var
response
=
queryDef
.
getPipelineAggOptions
(
targets
);
var
response
=
queryDef
.
getPipelineAggOptions
(
targets
);
it
(
'should return zero'
,
function
()
{
test
(
'should return zero'
,
()
=>
{
expect
(
response
.
length
).
to
.
b
e
(
2
);
expect
(
response
.
length
).
to
B
e
(
2
);
});
});
});
});
describe
(
'with count and moving average targets'
,
function
()
{
describe
(
'with count and moving average targets'
,
()
=>
{
var
targets
=
{
var
targets
=
{
metrics
:
[{
type
:
'count'
,
field
:
'@value'
},
{
type
:
'moving_avg'
,
field
:
'@value'
}],
metrics
:
[{
type
:
'count'
,
field
:
'@value'
},
{
type
:
'moving_avg'
,
field
:
'@value'
}],
};
};
var
response
=
queryDef
.
getPipelineAggOptions
(
targets
);
var
response
=
queryDef
.
getPipelineAggOptions
(
targets
);
it
(
'should return one'
,
function
()
{
test
(
'should return one'
,
()
=>
{
expect
(
response
.
length
).
to
.
b
e
(
1
);
expect
(
response
.
length
).
to
B
e
(
1
);
});
});
});
});
describe
(
'with derivatives targets'
,
function
()
{
describe
(
'with derivatives targets'
,
()
=>
{
var
targets
=
{
var
targets
=
{
metrics
:
[{
type
:
'derivative'
,
field
:
'@value'
}],
metrics
:
[{
type
:
'derivative'
,
field
:
'@value'
}],
};
};
var
response
=
queryDef
.
getPipelineAggOptions
(
targets
);
var
response
=
queryDef
.
getPipelineAggOptions
(
targets
);
it
(
'should return zero'
,
function
()
{
test
(
'should return zero'
,
()
=>
{
expect
(
response
.
length
).
to
.
b
e
(
0
);
expect
(
response
.
length
).
to
B
e
(
0
);
});
});
});
});
});
});
describe
(
'isPipelineMetric'
,
function
()
{
describe
(
'isPipelineMetric'
,
()
=>
{
describe
(
'moving_avg'
,
function
()
{
describe
(
'moving_avg'
,
()
=>
{
var
result
=
queryDef
.
isPipelineAgg
(
'moving_avg'
);
var
result
=
queryDef
.
isPipelineAgg
(
'moving_avg'
);
it
(
'is pipe line metric'
,
function
()
{
test
(
'is pipe line metric'
,
()
=>
{
expect
(
result
).
to
.
b
e
(
true
);
expect
(
result
).
to
B
e
(
true
);
});
});
});
});
describe
(
'count'
,
function
()
{
describe
(
'count'
,
()
=>
{
var
result
=
queryDef
.
isPipelineAgg
(
'count'
);
var
result
=
queryDef
.
isPipelineAgg
(
'count'
);
it
(
'is not pipe line metric'
,
function
()
{
test
(
'is not pipe line metric'
,
()
=>
{
expect
(
result
).
to
.
b
e
(
false
);
expect
(
result
).
to
B
e
(
false
);
});
});
});
});
});
});
describe
(
'pipeline aggs depending on esverison'
,
function
()
{
describe
(
'pipeline aggs depending on esverison'
,
()
=>
{
describe
(
'using esversion undefined'
,
function
()
{
describe
(
'using esversion undefined'
,
()
=>
{
it
(
'should not get pipeline aggs'
,
function
()
{
test
(
'should not get pipeline aggs'
,
()
=>
{
expect
(
queryDef
.
getMetricAggTypes
(
undefined
).
length
).
to
.
b
e
(
9
);
expect
(
queryDef
.
getMetricAggTypes
(
undefined
).
length
).
to
B
e
(
9
);
});
});
});
});
describe
(
'using esversion 1'
,
function
()
{
describe
(
'using esversion 1'
,
()
=>
{
it
(
'should not get pipeline aggs'
,
function
()
{
test
(
'should not get pipeline aggs'
,
()
=>
{
expect
(
queryDef
.
getMetricAggTypes
(
1
).
length
).
to
.
b
e
(
9
);
expect
(
queryDef
.
getMetricAggTypes
(
1
).
length
).
to
B
e
(
9
);
});
});
});
});
describe
(
'using esversion 2'
,
function
()
{
describe
(
'using esversion 2'
,
()
=>
{
it
(
'should get pipeline aggs'
,
function
()
{
test
(
'should get pipeline aggs'
,
()
=>
{
expect
(
queryDef
.
getMetricAggTypes
(
2
).
length
).
to
.
b
e
(
11
);
expect
(
queryDef
.
getMetricAggTypes
(
2
).
length
).
to
B
e
(
11
);
});
});
});
});
describe
(
'using esversion 5'
,
function
()
{
describe
(
'using esversion 5'
,
()
=>
{
it
(
'should get pipeline aggs'
,
function
()
{
test
(
'should get pipeline aggs'
,
()
=>
{
expect
(
queryDef
.
getMetricAggTypes
(
5
).
length
).
to
.
b
e
(
11
);
expect
(
queryDef
.
getMetricAggTypes
(
5
).
length
).
to
B
e
(
11
);
});
});
});
});
});
});
...
...
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