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
a17a9218
Unverified
Commit
a17a9218
authored
Jul 23, 2018
by
Marcus Efraimsson
Committed by
GitHub
Jul 23, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12692 from dehrax/12224-graph-ctrl
Karma to Jest: graph_ctrl
parents
76bc02b3
47bec0fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
26 deletions
+42
-26
public/app/plugins/panel/graph/specs/graph_ctrl.jest.ts
+42
-26
No files found.
public/app/plugins/panel/graph/specs/graph_ctrl
_specs
.ts
→
public/app/plugins/panel/graph/specs/graph_ctrl
.jest
.ts
View file @
a17a9218
import
{
describe
,
beforeEach
,
it
,
expect
,
angularMocks
}
from
'../../../../../test/lib/common'
;
import
moment
from
'moment'
;
import
{
GraphCtrl
}
from
'../module'
;
import
helpers
from
'../../../../../test/specs/helpers'
;
describe
(
'GraphCtrl'
,
function
()
{
var
ctx
=
new
helpers
.
ControllerTestContext
();
jest
.
mock
(
'../graph'
,
()
=>
({}));
describe
(
'GraphCtrl'
,
()
=>
{
let
injector
=
{
get
:
()
=>
{
return
{
timeRange
:
()
=>
{
return
{
from
:
''
,
to
:
''
,
};
},
};
},
};
let
scope
=
{
$on
:
()
=>
{},
};
GraphCtrl
.
prototype
.
panel
=
{
events
:
{
on
:
()
=>
{},
},
gridPos
:
{
w
:
100
,
},
};
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
angularMocks
.
module
(
'grafana.controllers'
));
beforeEach
(
angularMocks
.
module
(
function
(
$compileProvider
)
{
$compileProvider
.
preAssignBindingsEnabled
(
true
);
})
);
let
ctx
=
<
any
>
{};
beforeEach
(
ctx
.
providePhase
());
beforeEach
(
ctx
.
createPanelController
(
GraphCtrl
));
beforeEach
(()
=>
{
ctx
.
ctrl
=
new
GraphCtrl
(
scope
,
injector
,
{});
ctx
.
ctrl
.
annotationsPromise
=
Promise
.
resolve
({});
ctx
.
ctrl
.
updateTimeRange
();
});
describe
(
'when time series are outside range'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'when time series are outside range'
,
()
=>
{
beforeEach
(
()
=>
{
var
data
=
[
{
target
:
'test.cpu1'
,
...
...
@@ -35,13 +51,13 @@ describe('GraphCtrl', function() {
ctx
.
ctrl
.
onDataReceived
(
data
);
});
it
(
'should set datapointsOutside'
,
function
()
{
expect
(
ctx
.
ctrl
.
dataWarning
.
title
).
to
.
b
e
(
'Data points outside time range'
);
it
(
'should set datapointsOutside'
,
()
=>
{
expect
(
ctx
.
ctrl
.
dataWarning
.
title
).
to
B
e
(
'Data points outside time range'
);
});
});
describe
(
'when time series are inside range'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'when time series are inside range'
,
()
=>
{
beforeEach
(
()
=>
{
var
range
=
{
from
:
moment
()
.
subtract
(
1
,
'days'
)
...
...
@@ -60,19 +76,19 @@ describe('GraphCtrl', function() {
ctx
.
ctrl
.
onDataReceived
(
data
);
});
it
(
'should set datapointsOutside'
,
function
()
{
expect
(
ctx
.
ctrl
.
dataWarning
).
to
.
b
e
(
null
);
it
(
'should set datapointsOutside'
,
()
=>
{
expect
(
ctx
.
ctrl
.
dataWarning
).
to
B
e
(
null
);
});
});
describe
(
'datapointsCount given 2 series'
,
function
()
{
beforeEach
(
function
()
{
describe
(
'datapointsCount given 2 series'
,
()
=>
{
beforeEach
(
()
=>
{
var
data
=
[{
target
:
'test.cpu1'
,
datapoints
:
[]
},
{
target
:
'test.cpu2'
,
datapoints
:
[]
}];
ctx
.
ctrl
.
onDataReceived
(
data
);
});
it
(
'should set datapointsCount warning'
,
function
()
{
expect
(
ctx
.
ctrl
.
dataWarning
.
title
).
to
.
b
e
(
'No data points'
);
it
(
'should set datapointsCount warning'
,
()
=>
{
expect
(
ctx
.
ctrl
.
dataWarning
.
title
).
to
B
e
(
'No data points'
);
});
});
});
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