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
055f21f1
Commit
055f21f1
authored
Oct 05, 2017
by
Alexander Zobnin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
graphite-tags: add tests
parent
63d51d0d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
0 deletions
+109
-0
public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts
+109
-0
No files found.
public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts
View file @
055f21f1
...
@@ -210,4 +210,113 @@ describe('GraphiteQueryCtrl', function() {
...
@@ -210,4 +210,113 @@ describe('GraphiteQueryCtrl', function() {
});
});
});
});
describe
(
'when adding seriesByTag function'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
ctrl
.
target
.
target
=
''
;
ctx
.
ctrl
.
datasource
.
metricFindQuery
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([{
expandable
:
false
}]));
ctx
.
ctrl
.
parseTarget
();
ctx
.
ctrl
.
addFunction
(
gfunc
.
getFuncDef
(
'seriesByTag'
));
});
it
(
'should update functions'
,
function
()
{
expect
(
ctx
.
ctrl
.
getSeriesByTagFuncIndex
()).
to
.
be
(
0
);
});
it
(
'should update seriesByTagUsed flag'
,
function
()
{
expect
(
ctx
.
ctrl
.
seriesByTagUsed
).
to
.
be
(
true
);
});
it
(
'should update target'
,
function
()
{
expect
(
ctx
.
ctrl
.
target
.
target
).
to
.
be
(
'seriesByTag()'
);
});
it
(
'should call refresh'
,
function
()
{
expect
(
ctx
.
panelCtrl
.
refresh
.
called
).
to
.
be
(
true
);
});
});
describe
(
'when parsing seriesByTag function'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
ctrl
.
target
.
target
=
"seriesByTag('tag1=value1', 'tag2!=~value2')"
;
ctx
.
ctrl
.
datasource
.
metricFindQuery
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([{
expandable
:
false
}]));
ctx
.
ctrl
.
parseTarget
();
});
it
(
'should add tags'
,
function
()
{
const
expected
=
[
{
key
:
'tag1'
,
operator
:
'='
,
value
:
'value1'
},
{
key
:
'tag2'
,
operator
:
'!=~'
,
value
:
'value2'
}
];
expect
(
ctx
.
ctrl
.
tags
).
to
.
eql
(
expected
);
});
it
(
'should add plus button'
,
function
()
{
expect
(
ctx
.
ctrl
.
addTagSegments
.
length
).
to
.
be
(
1
);
});
});
describe
(
'when tag added'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
ctrl
.
target
.
target
=
"seriesByTag()"
;
ctx
.
ctrl
.
datasource
.
metricFindQuery
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([{
expandable
:
false
}]));
ctx
.
ctrl
.
parseTarget
();
ctx
.
ctrl
.
addNewTag
({
value
:
'tag1'
});
});
it
(
'should update tags with default value'
,
function
()
{
const
expected
=
[
{
key
:
'tag1'
,
operator
:
'='
,
value
:
'select tag value'
}
];
expect
(
ctx
.
ctrl
.
tags
).
to
.
eql
(
expected
);
});
it
(
'should update target'
,
function
()
{
const
expected
=
"seriesByTag('tag1=select tag value')"
;
expect
(
ctx
.
ctrl
.
target
.
target
).
to
.
eql
(
expected
);
});
});
describe
(
'when tag changed'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
ctrl
.
target
.
target
=
"seriesByTag('tag1=value1', 'tag2!=~value2')"
;
ctx
.
ctrl
.
datasource
.
metricFindQuery
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([{
expandable
:
false
}]));
ctx
.
ctrl
.
parseTarget
();
ctx
.
ctrl
.
tagChanged
({
key
:
'tag1'
,
operator
:
'='
,
value
:
'new_value'
},
0
);
});
it
(
'should update tags'
,
function
()
{
const
expected
=
[
{
key
:
'tag1'
,
operator
:
'='
,
value
:
'new_value'
},
{
key
:
'tag2'
,
operator
:
'!=~'
,
value
:
'value2'
}
];
expect
(
ctx
.
ctrl
.
tags
).
to
.
eql
(
expected
);
});
it
(
'should update target'
,
function
()
{
const
expected
=
"seriesByTag('tag1=new_value', 'tag2!=~value2')"
;
expect
(
ctx
.
ctrl
.
target
.
target
).
to
.
eql
(
expected
);
});
});
describe
(
'when tag removed'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
ctrl
.
target
.
target
=
"seriesByTag('tag1=value1', 'tag2!=~value2')"
;
ctx
.
ctrl
.
datasource
.
metricFindQuery
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([{
expandable
:
false
}]));
ctx
.
ctrl
.
parseTarget
();
ctx
.
ctrl
.
removeTag
(
0
);
});
it
(
'should update tags'
,
function
()
{
const
expected
=
[
{
key
:
'tag2'
,
operator
:
'!=~'
,
value
:
'value2'
}
];
expect
(
ctx
.
ctrl
.
tags
).
to
.
eql
(
expected
);
});
it
(
'should update target'
,
function
()
{
const
expected
=
"seriesByTag('tag2!=~value2')"
;
expect
(
ctx
.
ctrl
.
target
.
target
).
to
.
eql
(
expected
);
});
});
});
});
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