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
7e434fc0
Commit
7e434fc0
authored
Sep 28, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: moved graphite specs into plugins directory
parent
cb7424ce
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
219 additions
and
218 deletions
+219
-218
karma.conf.js
+1
-0
public/app/plugins/datasource/graphite/add_graphite_func.js
+0
-0
public/app/plugins/datasource/graphite/datasource.js
+3
-3
public/app/plugins/datasource/graphite/func_editor.js
+0
-0
public/app/plugins/datasource/graphite/query_ctrl.js
+0
-0
public/app/plugins/datasource/graphite/specs/datasource_specs.ts
+85
-87
public/app/plugins/datasource/graphite/specs/gfunc_specs.ts
+123
-126
public/app/plugins/datasource/graphite/specs/query_ctrl_specs.ts
+0
-0
public/test/lib/common.ts
+6
-1
public/test/test-main.js
+1
-1
No files found.
karma.conf.js
View file @
7e434fc0
...
...
@@ -25,6 +25,7 @@ module.exports = function(config) {
browsers
:
[
'PhantomJS'
],
captureTimeout
:
60000
,
singleRun
:
true
,
autoWatchBatchDelay
:
1000
,
});
...
...
public/app/plugins/datasource/graphite/add
GraphiteF
unc.js
→
public/app/plugins/datasource/graphite/add
_graphite_f
unc.js
View file @
7e434fc0
File moved
public/app/plugins/datasource/graphite/datasource.js
View file @
7e434fc0
...
...
@@ -5,9 +5,9 @@ define([
'config'
,
'app/core/utils/datemath'
,
'./directives'
,
'./query
C
trl'
,
'./func
E
ditor'
,
'./add
GraphiteF
unc'
,
'./query
_c
trl'
,
'./func
_e
ditor'
,
'./add
_graphite_f
unc'
,
],
function
(
angular
,
_
,
$
,
config
,
dateMath
)
{
'use strict'
;
...
...
public/app/plugins/datasource/graphite/func
E
ditor.js
→
public/app/plugins/datasource/graphite/func
_e
ditor.js
View file @
7e434fc0
File moved
public/app/plugins/datasource/graphite/query
C
trl.js
→
public/app/plugins/datasource/graphite/query
_c
trl.js
View file @
7e434fc0
File moved
public/
test/specs/graphiteDatasource-specs.j
s
→
public/
app/plugins/datasource/graphite/specs/datasource_specs.t
s
View file @
7e434fc0
define
([
'./helpers'
,
'app/plugins/datasource/graphite/datasource'
],
function
(
helpers
)
{
'use strict'
;
///<amd-dependency path="app/plugins/datasource/graphite/datasource" />
///<amd-dependency path="test/specs/helpers" name="helpers" />
describe
(
'graphiteDatasource'
,
function
()
{
var
ctx
=
new
helpers
.
ServiceTestContext
()
;
import
{
describe
,
beforeEach
,
it
,
sinon
,
expect
,
angularMocks
}
from
'test/lib/common'
;
declare
var
helpers
:
any
;
beforeEach
(
module
(
'grafana.services'
));
beforeEach
(
ctx
.
providePhase
([
'backendSrv'
])
);
describe
(
'graphiteDatasource'
,
function
()
{
var
ctx
=
new
helpers
.
ServiceTestContext
(
);
beforeEach
(
ctx
.
createService
(
'GraphiteDatasource'
));
beforeEach
(
function
()
{
ctx
.
ds
=
new
ctx
.
service
({
url
:
[
''
]
});
});
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
ctx
.
providePhase
([
'backendSrv'
]));
describe
(
'When querying influxdb with one target using query editor target spec'
,
function
()
{
var
query
=
{
rangeRaw
:
{
from
:
'now-1h'
,
to
:
'now'
},
targets
:
[{
target
:
'prod1.count'
},
{
target
:
'prod2.count'
}],
maxDataPoints
:
500
,
};
beforeEach
(
ctx
.
createService
(
'GraphiteDatasource'
));
beforeEach
(
function
()
{
ctx
.
ds
=
new
ctx
.
service
({
url
:
[
''
]
});
});
var
results
;
var
requestOptions
;
describe
(
'When querying influxdb with one target using query editor target spec'
,
function
()
{
var
query
=
{
rangeRaw
:
{
from
:
'now-1h'
,
to
:
'now'
},
targets
:
[{
target
:
'prod1.count'
},
{
target
:
'prod2.count'
}],
maxDataPoints
:
500
,
};
beforeEach
(
function
()
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
requestOptions
=
options
;
return
ctx
.
$q
.
when
({
data
:
[{
target
:
'prod1.count'
,
datapoints
:
[[
10
,
1
],
[
12
,
1
]]
}]});
};
var
results
;
var
requestOptions
;
ctx
.
ds
.
query
(
query
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
();
});
beforeEach
(
function
()
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
options
)
{
requestOptions
=
options
;
return
ctx
.
$q
.
when
({
data
:
[{
target
:
'prod1.count'
,
datapoints
:
[[
10
,
1
],
[
12
,
1
]]
}]});
};
it
(
'should generate the correct query'
,
function
()
{
expect
(
requestOptions
.
url
).
to
.
be
(
'/render'
);
});
ctx
.
ds
.
query
(
query
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$rootScope
.
$apply
(
);
});
it
(
'should query correctly'
,
function
()
{
var
params
=
requestOptions
.
data
.
split
(
'&'
);
expect
(
params
).
to
.
contain
(
'target=prod1.count'
);
expect
(
params
).
to
.
contain
(
'target=prod2.count'
);
expect
(
params
).
to
.
contain
(
'from=-1h'
);
expect
(
params
).
to
.
contain
(
'until=now'
);
});
it
(
'should generate the correct query'
,
function
()
{
expect
(
requestOptions
.
url
).
to
.
be
(
'/render'
);
});
it
(
'should exclude undefined params'
,
function
()
{
var
params
=
requestOptions
.
data
.
split
(
'&'
);
expect
(
params
).
to
.
not
.
contain
(
'cacheTimeout=undefined'
);
});
it
(
'should query correctly'
,
function
()
{
var
params
=
requestOptions
.
data
.
split
(
'&'
);
expect
(
params
).
to
.
contain
(
'target=prod1.count'
);
expect
(
params
).
to
.
contain
(
'target=prod2.count'
);
expect
(
params
).
to
.
contain
(
'from=-1h'
);
expect
(
params
).
to
.
contain
(
'until=now'
);
});
it
(
'should return series list
'
,
function
()
{
expect
(
results
.
data
.
length
).
to
.
be
(
1
);
expect
(
results
.
data
[
0
].
target
).
to
.
be
(
'prod1.count
'
);
});
it
(
'should exclude undefined params
'
,
function
()
{
var
params
=
requestOptions
.
data
.
split
(
'&'
);
expect
(
params
).
to
.
not
.
contain
(
'cacheTimeout=undefined
'
);
});
it
(
'should convert to millisecond resolution'
,
function
()
{
expect
(
results
.
data
[
0
].
datapoints
[
0
][
0
]).
to
.
be
(
10
);
});
it
(
'should return series list'
,
function
()
{
expect
(
results
.
data
.
length
).
to
.
be
(
1
);
expect
(
results
.
data
[
0
].
target
).
to
.
be
(
'prod1.count'
);
});
it
(
'should convert to millisecond resolution'
,
function
()
{
expect
(
results
.
data
[
0
].
datapoints
[
0
][
0
]).
to
.
be
(
10
);
});
describe
(
'building graphite params'
,
function
()
{
});
it
(
'should uri escape targets'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
'prod1.{test,test2}'
},
{
target
:
'prod2.count'
}]
});
expect
(
results
).
to
.
contain
(
'target=prod1.%7Btest%2Ctest2%7D'
);
});
describe
(
'building graphite params'
,
function
()
{
it
(
'should replace target placeholder'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
'series1'
},
{
target
:
'series2'
},
{
target
:
'asPercent(#A,#B)'
}]
});
expect
(
results
[
2
]).
to
.
be
(
'target=asPercent(series1%2Cseries2)'
);
it
(
'should uri escape targets'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
'prod1.{test,test2}'
},
{
target
:
'prod2.count'
}]
});
expect
(
results
).
to
.
contain
(
'target=prod1.%7Btest%2Ctest2%7D'
);
});
it
(
'should replace target placeholder for hidden series'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
'series1'
,
hide
:
true
},
{
target
:
'sumSeries(#A)'
,
hide
:
true
},
{
target
:
'asPercent(#A,#B)'
}]
});
expect
(
results
[
0
]).
to
.
be
(
'target='
+
encodeURIComponent
(
'asPercent(series1,sumSeries(series1))'
));
it
(
'should replace target placeholder'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
'series1'
},
{
target
:
'series2'
},
{
target
:
'asPercent(#A,#B)'
}]
});
expect
(
results
[
2
]).
to
.
be
(
'target=asPercent(series1%2Cseries2)'
);
});
it
(
'should replace target placeholder when nesting query references'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
'series1'
},
{
target
:
'sumSeries(#A)'
},
{
target
:
'asPercent(#A,#B)'
}]
});
expect
(
results
[
2
]).
to
.
be
(
'target='
+
encodeURIComponent
(
"asPercent(series1,sumSeries(series1))"
));
it
(
'should replace target placeholder for hidden series'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
'series1'
,
hide
:
true
},
{
target
:
'sumSeries(#A)'
,
hide
:
true
},
{
target
:
'asPercent(#A,#B)'
}]
});
expect
(
results
[
0
]).
to
.
be
(
'target='
+
encodeURIComponent
(
'asPercent(series1,sumSeries(series1))'
));
});
it
(
'should fix wrong minute interval parameters'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
"summarize(prod.25m.count, '25m', 'sum')"
}]
});
expect
(
results
[
0
]).
to
.
be
(
'target='
+
encodeURIComponent
(
"summarize(prod.25m.count, '25min', 'sum')"
));
it
(
'should replace target placeholder when nesting query references'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
'series1'
},
{
target
:
'sumSeries(#A)'
},
{
target
:
'asPercent(#A,#B)'
}]
});
expect
(
results
[
2
]).
to
.
be
(
'target='
+
encodeURIComponent
(
"asPercent(series1,sumSeries(series1))"
));
});
it
(
'should fix wrong month interval parameters'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
"summarize(prod.5M.count, '5M', 'sum')"
}]
});
expect
(
results
[
0
]).
to
.
be
(
'target='
+
encodeURIComponent
(
"summarize(prod.5M.count, '5mon', 'sum')"
));
it
(
'should fix wrong minute interval parameters'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
"summarize(prod.25m.count, '25m', 'sum')"
}]
});
expect
(
results
[
0
]).
to
.
be
(
'target='
+
encodeURIComponent
(
"summarize(prod.25m.count, '25min', 'sum')"
));
});
it
(
'should ignore empty targets'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
'series1'
},
{
target
:
''
}]
});
expect
(
results
.
length
).
to
.
be
(
2
);
it
(
'should fix wrong month interval parameters'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
"summarize(prod.5M.count, '5M', 'sum')"
}]
});
expect
(
results
[
0
]).
to
.
be
(
'target='
+
encodeURIComponent
(
"summarize(prod.5M.count, '5mon', 'sum')"
));
});
it
(
'should ignore empty targets'
,
function
()
{
var
results
=
ctx
.
ds
.
buildGraphiteParams
({
targets
:
[{
target
:
'series1'
},
{
target
:
''
}]
});
expect
(
results
.
length
).
to
.
be
(
2
);
});
});
...
...
public/
test/specs/gfunc-specs.j
s
→
public/
app/plugins/datasource/graphite/specs/gfunc_specs.t
s
View file @
7e434fc0
define
([
'app/plugins/datasource/graphite/gfunc'
],
function
(
gfunc
)
{
'use strict'
;
describe
(
'when creating func instance from func names'
,
function
()
{
it
(
'should return func instance'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'sumSeries'
);
expect
(
func
).
to
.
be
.
ok
();
expect
(
func
.
def
.
name
).
to
.
equal
(
'sumSeries'
);
expect
(
func
.
def
.
params
.
length
).
to
.
equal
(
5
);
expect
(
func
.
def
.
defaultParams
.
length
).
to
.
equal
(
1
);
});
it
(
'should return func instance with shortName'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'sum'
);
expect
(
func
).
to
.
be
.
ok
();
});
it
(
'should return func instance from funcDef'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'sum'
);
var
func2
=
gfunc
.
createFuncInstance
(
func
.
def
);
expect
(
func2
).
to
.
be
.
ok
();
});
it
(
'func instance should have text representation'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'groupByNode'
);
func
.
params
[
0
]
=
5
;
func
.
params
[
1
]
=
'avg'
;
func
.
updateText
();
expect
(
func
.
text
).
to
.
equal
(
"groupByNode(5, avg)"
);
});
});
describe
(
'when rendering func instance'
,
function
()
{
it
(
'should handle single metric param'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'sumSeries'
);
expect
(
func
.
render
(
'hello.metric'
)).
to
.
equal
(
"sumSeries(hello.metric)"
);
});
it
(
'should include default params if options enable it'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'scaleToSeconds'
,
{
withDefaultParams
:
true
});
expect
(
func
.
render
(
'hello'
)).
to
.
equal
(
"scaleToSeconds(hello, 1)"
);
});
it
(
'should handle int or interval params with number'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'movingMedian'
);
func
.
params
[
0
]
=
'5'
;
expect
(
func
.
render
(
'hello'
)).
to
.
equal
(
"movingMedian(hello, 5)"
);
});
it
(
'should handle int or interval params with interval string'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'movingMedian'
);
func
.
params
[
0
]
=
'5min'
;
expect
(
func
.
render
(
'hello'
)).
to
.
equal
(
"movingMedian(hello, '5min')"
);
});
it
(
'should handle metric param and int param and string param'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'groupByNode'
);
func
.
params
[
0
]
=
5
;
func
.
params
[
1
]
=
'avg'
;
expect
(
func
.
render
(
'hello.metric'
)).
to
.
equal
(
"groupByNode(hello.metric, 5, 'avg')"
);
});
it
(
'should handle function with no metric param'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'randomWalk'
);
func
.
params
[
0
]
=
'test'
;
expect
(
func
.
render
(
undefined
)).
to
.
equal
(
"randomWalk('test')"
);
});
it
(
'should handle function multiple series params'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'asPercent'
);
func
.
params
[
0
]
=
'#B'
;
expect
(
func
.
render
(
'#A'
)).
to
.
equal
(
"asPercent(#A, #B)"
);
});
});
describe
(
'when requesting function categories'
,
function
()
{
it
(
'should return function categories'
,
function
()
{
var
catIndex
=
gfunc
.
getCategories
();
expect
(
catIndex
.
Special
.
length
).
to
.
be
.
greaterThan
(
8
);
});
});
describe
(
'when updating func param'
,
function
()
{
it
(
'should update param value and update text representation'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'summarize'
,
{
withDefaultParams
:
true
});
func
.
updateParam
(
'1h'
,
0
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'1h'
);
expect
(
func
.
text
).
to
.
be
(
'summarize(1h, sum, false)'
);
});
it
(
'should parse numbers as float'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'scale'
);
func
.
updateParam
(
'0.001'
,
0
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'0.001'
);
});
});
describe
(
'when updating func param with optional second parameter'
,
function
()
{
it
(
'should update value and text'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'aliasByNode'
);
func
.
updateParam
(
'1'
,
0
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'1'
);
});
it
(
'should slit text and put value in second param'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'aliasByNode'
);
func
.
updateParam
(
'4,-5'
,
0
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'4'
);
expect
(
func
.
params
[
1
]).
to
.
be
(
'-5'
);
expect
(
func
.
text
).
to
.
be
(
'aliasByNode(4, -5)'
);
});
it
(
'should remove second param when empty string is set'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'aliasByNode'
);
func
.
updateParam
(
'4,-5'
,
0
);
func
.
updateParam
(
''
,
1
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'4'
);
expect
(
func
.
params
[
1
]).
to
.
be
(
undefined
);
expect
(
func
.
text
).
to
.
be
(
'aliasByNode(4)'
);
});
///<amd-dependency path="app/plugins/datasource/graphite/gfunc" name="gfunc" />
import
{
describe
,
beforeEach
,
it
,
sinon
,
expect
}
from
'test/lib/common'
;
declare
var
gfunc
:
any
;
describe
(
'when creating func instance from func names'
,
function
()
{
it
(
'should return func instance'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'sumSeries'
);
expect
(
func
).
to
.
be
.
ok
();
expect
(
func
.
def
.
name
).
to
.
equal
(
'sumSeries'
);
expect
(
func
.
def
.
params
.
length
).
to
.
equal
(
5
);
expect
(
func
.
def
.
defaultParams
.
length
).
to
.
equal
(
1
);
});
it
(
'should return func instance with shortName'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'sum'
);
expect
(
func
).
to
.
be
.
ok
();
});
it
(
'should return func instance from funcDef'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'sum'
);
var
func2
=
gfunc
.
createFuncInstance
(
func
.
def
);
expect
(
func2
).
to
.
be
.
ok
();
});
it
(
'func instance should have text representation'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'groupByNode'
);
func
.
params
[
0
]
=
5
;
func
.
params
[
1
]
=
'avg'
;
func
.
updateText
();
expect
(
func
.
text
).
to
.
equal
(
"groupByNode(5, avg)"
);
});
});
describe
(
'when rendering func instance'
,
function
()
{
it
(
'should handle single metric param'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'sumSeries'
);
expect
(
func
.
render
(
'hello.metric'
)).
to
.
equal
(
"sumSeries(hello.metric)"
);
});
it
(
'should include default params if options enable it'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'scaleToSeconds'
,
{
withDefaultParams
:
true
});
expect
(
func
.
render
(
'hello'
)).
to
.
equal
(
"scaleToSeconds(hello, 1)"
);
});
it
(
'should handle int or interval params with number'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'movingMedian'
);
func
.
params
[
0
]
=
'5'
;
expect
(
func
.
render
(
'hello'
)).
to
.
equal
(
"movingMedian(hello, 5)"
);
});
it
(
'should handle int or interval params with interval string'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'movingMedian'
);
func
.
params
[
0
]
=
'5min'
;
expect
(
func
.
render
(
'hello'
)).
to
.
equal
(
"movingMedian(hello, '5min')"
);
});
it
(
'should handle metric param and int param and string param'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'groupByNode'
);
func
.
params
[
0
]
=
5
;
func
.
params
[
1
]
=
'avg'
;
expect
(
func
.
render
(
'hello.metric'
)).
to
.
equal
(
"groupByNode(hello.metric, 5, 'avg')"
);
});
it
(
'should handle function with no metric param'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'randomWalk'
);
func
.
params
[
0
]
=
'test'
;
expect
(
func
.
render
(
undefined
)).
to
.
equal
(
"randomWalk('test')"
);
});
it
(
'should handle function multiple series params'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'asPercent'
);
func
.
params
[
0
]
=
'#B'
;
expect
(
func
.
render
(
'#A'
)).
to
.
equal
(
"asPercent(#A, #B)"
);
});
});
describe
(
'when requesting function categories'
,
function
()
{
it
(
'should return function categories'
,
function
()
{
var
catIndex
=
gfunc
.
getCategories
();
expect
(
catIndex
.
Special
.
length
).
to
.
be
.
greaterThan
(
8
);
});
});
describe
(
'when updating func param'
,
function
()
{
it
(
'should update param value and update text representation'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'summarize'
,
{
withDefaultParams
:
true
});
func
.
updateParam
(
'1h'
,
0
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'1h'
);
expect
(
func
.
text
).
to
.
be
(
'summarize(1h, sum, false)'
);
});
it
(
'should parse numbers as float'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'scale'
);
func
.
updateParam
(
'0.001'
,
0
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'0.001'
);
});
});
describe
(
'when updating func param with optional second parameter'
,
function
()
{
it
(
'should update value and text'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'aliasByNode'
);
func
.
updateParam
(
'1'
,
0
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'1'
);
});
it
(
'should slit text and put value in second param'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'aliasByNode'
);
func
.
updateParam
(
'4,-5'
,
0
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'4'
);
expect
(
func
.
params
[
1
]).
to
.
be
(
'-5'
);
expect
(
func
.
text
).
to
.
be
(
'aliasByNode(4, -5)'
);
});
it
(
'should remove second param when empty string is set'
,
function
()
{
var
func
=
gfunc
.
createFuncInstance
(
'aliasByNode'
);
func
.
updateParam
(
'4,-5'
,
0
);
func
.
updateParam
(
''
,
1
);
expect
(
func
.
params
[
0
]).
to
.
be
(
'4'
);
expect
(
func
.
params
[
1
]).
to
.
be
(
undefined
);
expect
(
func
.
text
).
to
.
be
(
'aliasByNode(4)'
);
});
});
public/
test/specs/graphiteTargetCtrl-specs.j
s
→
public/
app/plugins/datasource/graphite/specs/query_ctrl_specs.t
s
View file @
7e434fc0
This diff is collapsed.
Click to expand it.
public/test/lib/common.ts
View file @
7e434fc0
...
...
@@ -7,10 +7,15 @@ var it = _global.it;
var
sinon
=
_global
.
sinon
;
var
expect
=
_global
.
expect
;
var
angularMocks
=
{
module
:
_global
.
module
,
};
export
{
beforeEach
,
describe
,
it
,
sinon
,
expect
expect
,
angularMocks
,
}
public/test/test-main.js
View file @
7e434fc0
...
...
@@ -113,7 +113,7 @@ require([
var
specs
=
[];
for
(
var
file
in
window
.
__karma__
.
files
)
{
if
(
/
base
\/
test
\/
specs.*/
.
test
(
file
))
{
if
(
/specs.*/
.
test
(
file
))
{
file
=
file2moduleName
(
file
);
specs
.
push
(
file
);
}
...
...
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