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
927b39fa
Commit
927b39fa
authored
Feb 16, 2017
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
templating: adds test for sorting template values
parent
3c0f6151
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
5 deletions
+37
-5
public/app/features/templating/query_variable.ts
+1
-2
public/app/features/templating/specs/query_variable_specs.ts
+36
-3
No files found.
public/app/features/templating/query_variable.ts
View file @
927b39fa
...
...
@@ -138,7 +138,6 @@ export class QueryVariable implements Variable {
if
(
this
.
regex
)
{
regex
=
kbn
.
stringToJsRegex
(
this
.
templateSrv
.
replace
(
this
.
regex
,
{},
'regex'
));
}
for
(
i
=
0
;
i
<
metricNames
.
length
;
i
++
)
{
var
item
=
metricNames
[
i
];
var
value
=
item
.
value
||
item
.
text
;
...
...
@@ -181,7 +180,7 @@ export class QueryVariable implements Variable {
}
else
if
(
sortType
===
2
)
{
options
=
_
.
sortBy
(
options
,
function
(
opt
)
{
var
matches
=
opt
.
text
.
match
(
/.*
?(\d
+
)
.*/
);
if
(
!
matches
)
{
if
(
!
matches
||
matches
.
length
<
2
)
{
return
0
;
}
else
{
return
parseInt
(
matches
[
1
],
10
);
...
...
public/app/features/templating/specs/query_variable_specs.ts
View file @
927b39fa
...
...
@@ -2,11 +2,11 @@ import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/co
import
{
QueryVariable
}
from
'../query_variable'
;
describe
(
'QueryVariable'
,
function
()
{
describe
(
'QueryVariable'
,
()
=>
{
describe
(
'when creating from model'
,
function
()
{
describe
(
'when creating from model'
,
()
=>
{
it
(
'should set defaults'
,
function
()
{
it
(
'should set defaults'
,
()
=>
{
var
variable
=
new
QueryVariable
({},
null
,
null
,
null
,
null
);
expect
(
variable
.
datasource
).
to
.
be
(
null
);
expect
(
variable
.
refresh
).
to
.
be
(
0
);
...
...
@@ -42,5 +42,38 @@ describe('QueryVariable', function() {
expect
(
model
.
options
.
length
).
to
.
be
(
0
);
});
});
describe
(
'can convert and sort metric names'
,()
=>
{
var
variable
=
new
QueryVariable
({},
null
,
null
,
null
,
null
);
variable
.
sort
=
51
;
describe
(
'can sort a mixed array of metric variables'
,
()
=>
{
var
input
=
[
{
text
:
'0'
,
value
:
'0'
},
{
text
:
'1'
,
value
:
'1'
},
{
text
:
''
,
value
:
''
},
{
text
:
null
,
value
:
3
},
{
text
:
undefined
,
value
:
4
},
{
text
:
'5'
,
value
:
null
},
{
text
:
'6'
,
value
:
undefined
},
{
text
:
null
,
value
:
'3'
},
{
text
:
undefined
,
value
:
'4'
},
{
text
:
5
,
value
:
null
},
{
text
:
6
,
value
:
undefined
},
];
var
result
=
variable
.
metricNamesToVariableValues
(
input
);
it
(
'should return in same order'
,
()
=>
{
expect
(
result
[
0
].
text
).
to
.
be
(
'0'
);
expect
(
result
[
1
].
text
).
to
.
be
(
'1'
);
expect
(
result
[
2
].
text
).
to
.
be
(
''
);
expect
(
result
[
3
].
text
).
to
.
be
(
'3'
);
expect
(
result
[
4
].
text
).
to
.
be
(
'4'
);
expect
(
result
[
5
].
text
).
to
.
be
(
'5'
);
expect
(
result
[
6
].
text
).
to
.
be
(
'6'
);
});
});
});
});
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