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
436f6bda
Commit
436f6bda
authored
Aug 13, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed unit tests for dashboardViewStateSrv
parent
4d1102db
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
31 deletions
+48
-31
src/test/specs/dashboardSrv-specs.js
+4
-30
src/test/specs/dashboardViewStateSrv-specs.js
+37
-0
src/test/specs/helpers.js
+6
-1
src/test/test-main.js
+1
-0
No files found.
src/test/specs/dashboardSrv-specs.js
View file @
436f6bda
...
...
@@ -54,6 +54,10 @@ define([
expect
(
model
.
title
).
to
.
be
(
'No Title'
);
});
it
(
'should have panel id'
,
function
()
{
expect
(
graph
.
id
).
to
.
be
(
1
);
});
it
(
'should move time and filtering list'
,
function
()
{
expect
(
model
.
time
.
from
).
to
.
be
(
'now-1d'
);
expect
(
model
.
templating
.
list
[
0
]).
to
.
be
(
1
);
...
...
@@ -78,34 +82,4 @@ define([
});
describe
(
'when updating view state'
,
function
()
{
var
viewState
,
location
;
beforeEach
(
module
(
'grafana.services'
));
beforeEach
(
inject
(
function
(
dashboardSrv
,
$location
)
{
viewState
=
dashboardSrv
.
createViewState
();
location
=
$location
;
}));
describe
(
'to fullscreen true and edit true'
,
function
()
{
it
(
'should update querystring and view state'
,
function
()
{
var
updateState
=
{
fullscreen
:
true
,
edit
:
true
,
panelId
:
1
};
viewState
.
update
(
updateState
);
expect
(
location
.
search
()).
to
.
eql
(
updateState
);
expect
(
viewState
).
to
.
eql
(
updateState
);
});
});
describe
(
'to fullscreen false'
,
function
()
{
it
(
'should remove params from query string'
,
function
()
{
viewState
.
update
({
fullscreen
:
true
,
panelId
:
1
,
edit
:
true
});
viewState
.
update
({
fullscreen
:
false
});
expect
(
location
.
search
()).
to
.
eql
({});
expect
(
viewState
).
to
.
eql
({});
});
});
});
});
src/test/specs/dashboardViewStateSrv-specs.js
0 → 100644
View file @
436f6bda
define
([
'services/dashboard/dashboardViewStateSrv'
],
function
()
{
'use strict'
;
describe
(
'when updating view state'
,
function
()
{
var
viewState
,
location
;
beforeEach
(
module
(
'grafana.services'
));
beforeEach
(
inject
(
function
(
dashboardViewStateSrv
,
$location
,
$rootScope
)
{
$rootScope
.
onAppEvent
=
function
(){};
viewState
=
dashboardViewStateSrv
.
create
(
$rootScope
);
location
=
$location
;
}));
describe
(
'to fullscreen true and edit true'
,
function
()
{
it
(
'should update querystring and view state'
,
function
()
{
var
updateState
=
{
fullscreen
:
true
,
edit
:
true
,
panelId
:
1
};
viewState
.
update
(
updateState
);
expect
(
location
.
search
()).
to
.
eql
(
updateState
);
expect
(
viewState
.
fullscreen
).
to
.
be
(
true
);
});
});
describe
(
'to fullscreen false'
,
function
()
{
it
(
'should remove params from query string'
,
function
()
{
viewState
.
update
({
fullscreen
:
true
,
panelId
:
1
,
edit
:
true
});
viewState
.
update
({
fullscreen
:
false
});
expect
(
location
.
search
()).
to
.
eql
({});
expect
(
viewState
.
fullscreen
).
to
.
be
(
false
);
});
});
});
});
src/test/specs/helpers.js
View file @
436f6bda
...
...
@@ -26,7 +26,7 @@ define([
self
.
scope
.
panel
=
{};
self
.
scope
.
row
=
{
panels
:[]
};
self
.
scope
.
filter
=
new
FilterSrvStub
();
self
.
scope
.
dashboardViewState
=
{
update
:
function
()
{}
}
;
self
.
scope
.
dashboardViewState
=
new
DashboardViewStateStub
()
;
$rootScope
.
colors
=
[];
for
(
var
i
=
0
;
i
<
50
;
i
++
)
{
$rootScope
.
colors
.
push
(
'#'
+
i
);
}
...
...
@@ -55,6 +55,11 @@ define([
};
}
function
DashboardViewStateStub
()
{
this
.
registerPanel
=
function
()
{
};
}
function
FilterSrvStub
()
{
this
.
time
=
{
from
:
'now-1h'
,
to
:
'now'
};
this
.
timeRange
=
function
(
parse
)
{
...
...
src/test/test-main.js
View file @
436f6bda
...
...
@@ -124,6 +124,7 @@ require([
'specs/filterSrv-specs'
,
'specs/kbn-format-specs'
,
'specs/dashboardSrv-specs'
,
'specs/dashboardViewStateSrv-specs'
,
'specs/influxSeries-specs'
],
function
()
{
window
.
__karma__
.
start
();
...
...
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