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
70eb2818
Commit
70eb2818
authored
Apr 03, 2018
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
variables: adds test for variable sorting
ref #11280
parent
4a937661
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
6 deletions
+35
-6
public/app/features/templating/specs/query_variable.jest.ts
+35
-6
No files found.
public/app/features/templating/specs/query_variable.jest.ts
View file @
70eb2818
...
...
@@ -40,11 +40,11 @@ describe('QueryVariable', () => {
});
describe
(
'can convert and sort metric names'
,
()
=>
{
var
variable
=
new
QueryVariable
({},
null
,
null
,
null
,
null
);
variable
.
sort
=
3
;
// Numerical (asc)
const
variable
=
new
QueryVariable
({},
null
,
null
,
null
,
null
);
let
input
;
describe
(
'can sort a mixed array of metric variables'
,
()
=>
{
var
input
=
[
beforeEach
(
()
=>
{
input
=
[
{
text
:
'0'
,
value
:
'0'
},
{
text
:
'1'
,
value
:
'1'
},
{
text
:
null
,
value
:
3
},
...
...
@@ -58,11 +58,18 @@ describe('QueryVariable', () => {
{
text
:
''
,
value
:
undefined
},
{
text
:
undefined
,
value
:
''
},
];
});
describe
(
'can sort a mixed array of metric variables in numeric order'
,
()
=>
{
let
result
;
beforeEach
(()
=>
{
variable
.
sort
=
3
;
// Numerical (asc)
result
=
variable
.
metricNamesToVariableValues
(
input
);
});
var
result
=
variable
.
metricNamesToVariableValues
(
input
);
it
(
'should return in same order'
,
()
=>
{
var
i
=
0
;
expect
(
result
.
length
).
toBe
(
11
);
expect
(
result
[
i
++
].
text
).
toBe
(
''
);
expect
(
result
[
i
++
].
text
).
toBe
(
'0'
);
...
...
@@ -73,5 +80,27 @@ describe('QueryVariable', () => {
expect
(
result
[
i
++
].
text
).
toBe
(
'6'
);
});
});
describe
(
'can sort a mixed array of metric variables in alphabetical order'
,
()
=>
{
let
result
;
beforeEach
(()
=>
{
variable
.
sort
=
5
;
// Alphabetical CI (asc)
result
=
variable
.
metricNamesToVariableValues
(
input
);
});
it
(
'should return in same order'
,
()
=>
{
var
i
=
0
;
console
.
log
(
result
);
expect
(
result
.
length
).
toBe
(
11
);
expect
(
result
[
i
++
].
text
).
toBe
(
''
);
expect
(
result
[
i
++
].
text
).
toBe
(
'0'
);
expect
(
result
[
i
++
].
text
).
toBe
(
'1'
);
expect
(
result
[
i
++
].
text
).
toBe
(
'10'
);
expect
(
result
[
i
++
].
text
).
toBe
(
'3'
);
expect
(
result
[
i
++
].
text
).
toBe
(
'4'
);
expect
(
result
[
i
++
].
text
).
toBe
(
'5'
);
});
});
});
});
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