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
17c03bed
Commit
17c03bed
authored
Aug 11, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some unit tests for RowCtrl
parent
4bfc5355
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
0 deletions
+65
-0
src/test/specs/helpers.js
+2
-0
src/test/specs/row-ctrl-specs.js
+62
-0
src/test/test-main.js
+1
-0
No files found.
src/test/specs/helpers.js
View file @
17c03bed
...
...
@@ -24,7 +24,9 @@ define([
return
inject
(
function
(
$controller
,
$rootScope
,
$q
)
{
self
.
scope
=
$rootScope
.
$new
();
self
.
scope
.
panel
=
{};
self
.
scope
.
row
=
{
panels
:[]
};
self
.
scope
.
filter
=
new
FilterSrvStub
();
$rootScope
.
colors
=
[];
for
(
var
i
=
0
;
i
<
50
;
i
++
)
{
$rootScope
.
colors
.
push
(
'#'
+
i
);
}
...
...
src/test/specs/row-ctrl-specs.js
0 → 100644
View file @
17c03bed
define
([
'./helpers'
,
'controllers/row'
],
function
(
helpers
)
{
'use strict'
;
describe
(
'RowCtrl'
,
function
()
{
var
ctx
=
new
helpers
.
ControllerTestContext
();
beforeEach
(
module
(
'grafana.controllers'
));
beforeEach
(
ctx
.
providePhase
());
beforeEach
(
ctx
.
createControllerPhase
(
'RowCtrl'
));
describe
(
'when getting rowSpan'
,
function
()
{
it
(
'should return sum of panels spans'
,
function
()
{
var
spanLeft
=
ctx
.
scope
.
rowSpan
({
panels
:
[{
span
:
2
},
{
span
:
3
}]
});
expect
(
spanLeft
).
to
.
be
(
5
);
});
});
describe
(
'when adding panel to row with 12 span panel'
,
function
()
{
it
(
'should split span in half and add panel with defaults'
,
function
()
{
ctx
.
scope
.
row
=
{
panels
:
[{
span
:
12
}]
};
ctx
.
scope
.
add_panel_default
(
'graph'
);
expect
(
ctx
.
scope
.
row
.
panels
[
0
].
span
).
to
.
be
(
6
);
expect
(
ctx
.
scope
.
row
.
panels
[
1
].
span
).
to
.
be
(
6
);
expect
(
ctx
.
scope
.
row
.
panels
[
1
].
type
).
to
.
be
(
'graph'
);
});
});
describe
(
'when duplicating panel'
,
function
()
{
it
(
'should try to add it to same row'
,
function
()
{
var
panel
=
{
span
:
4
,
attr
:
'123'
};
ctx
.
scope
.
row
=
{
panels
:
[
panel
]
};
ctx
.
scope
.
duplicatePanel
(
panel
,
ctx
.
scope
.
row
);
expect
(
ctx
.
scope
.
row
.
panels
[
0
].
span
).
to
.
be
(
4
);
expect
(
ctx
.
scope
.
row
.
panels
[
1
].
span
).
to
.
be
(
4
);
expect
(
ctx
.
scope
.
row
.
panels
[
1
].
attr
).
to
.
be
(
'123'
);
});
});
describe
(
'when duplicating panel'
,
function
()
{
it
(
'should add row if there is no space left'
,
function
()
{
var
panel
=
{
span
:
12
,
attr
:
'123'
};
ctx
.
scope
.
row
=
{
panels
:
[
panel
]
};
ctx
.
scope
.
dashboard
=
{
rows
:
[
ctx
.
scope
.
row
]
};
ctx
.
scope
.
duplicatePanel
(
panel
,
ctx
.
scope
.
row
);
expect
(
ctx
.
scope
.
row
.
panels
[
0
].
span
).
to
.
be
(
12
);
expect
(
ctx
.
scope
.
row
.
panels
.
length
).
to
.
be
(
1
);
expect
(
ctx
.
scope
.
dashboard
.
rows
[
1
].
panels
[
0
].
attr
).
to
.
be
(
'123'
);
});
});
});
});
src/test/test-main.js
View file @
17c03bed
...
...
@@ -117,6 +117,7 @@ require([
'specs/lexer-specs'
,
'specs/parser-specs'
,
'specs/gfunc-specs'
,
'specs/row-ctrl-specs'
,
'specs/graphiteTargetCtrl-specs'
,
'specs/influxdb-datasource-specs'
,
'specs/graph-ctrl-specs'
,
...
...
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