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
4403d919
Commit
4403d919
authored
Dec 04, 2017
by
Alexander Zobnin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move DashboardImportCtrl tests to jest
parent
44ea0ff7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
26 deletions
+23
-26
public/app/features/dashboard/specs/dashboard_import_ctrl.jest.ts
+23
-26
No files found.
public/app/features/dashboard/specs/dashboard_import_ctrl.ts
→
public/app/features/dashboard/specs/dashboard_import_ctrl.
jest.
ts
View file @
4403d919
import
{
describe
,
beforeEach
,
it
,
sinon
,
expect
,
angularMocks
}
from
'test/lib/common'
;
import
{
DashboardImportCtrl
}
from
'../dashboard_import_ctrl'
;
import
config
from
'
app
/core/config'
;
import
config
from
'
../../..
/core/config'
;
describe
(
'DashboardImportCtrl'
,
function
()
{
var
ctx
:
any
=
{};
var
backendSrv
=
{
search
:
sinon
.
stub
().
returns
(
Promise
.
resolve
([])),
get
:
sinon
.
stub
()
};
beforeEach
(
angularMocks
.
module
(
'grafana.core'
));
let
navModelSrv
;
let
backendSrv
;
beforeEach
(
angularMocks
.
inject
((
$rootScope
,
$controller
,
$q
)
=>
{
ctx
.
$q
=
$q
;
ctx
.
scope
=
$rootScope
.
$new
();
ctx
.
ctrl
=
$controller
(
DashboardImportCtrl
,
{
$scope
:
ctx
.
scope
,
backendSrv
:
backendSrv
,
});
}));
beforeEach
(()
=>
{
navModelSrv
=
{
getNav
:
()
=>
{}
};
backendSrv
=
{
search
:
jest
.
fn
().
mockReturnValue
(
Promise
.
resolve
([])),
get
:
jest
.
fn
()
};
ctx
.
ctrl
=
new
DashboardImportCtrl
(
backendSrv
,
navModelSrv
,
{},
{},
{});
});
describe
(
'when uploading json'
,
function
()
{
beforeEach
(
function
()
{
...
...
@@ -37,13 +36,13 @@ describe('DashboardImportCtrl', function() {
});
it
(
'should build input model'
,
function
()
{
expect
(
ctx
.
ctrl
.
inputs
.
length
).
to
.
eql
(
1
);
expect
(
ctx
.
ctrl
.
inputs
[
0
].
name
).
to
.
eql
(
'ds'
);
expect
(
ctx
.
ctrl
.
inputs
[
0
].
info
).
to
.
eql
(
'Select a Test DB data source'
);
expect
(
ctx
.
ctrl
.
inputs
.
length
).
to
Be
(
1
);
expect
(
ctx
.
ctrl
.
inputs
[
0
].
name
).
to
Be
(
'ds'
);
expect
(
ctx
.
ctrl
.
inputs
[
0
].
info
).
to
Be
(
'Select a Test DB data source'
);
});
it
(
'should set inputValid to false'
,
function
()
{
expect
(
ctx
.
ctrl
.
inputsValid
).
to
.
eql
(
false
);
expect
(
ctx
.
ctrl
.
inputsValid
).
to
Be
(
false
);
});
});
...
...
@@ -51,7 +50,7 @@ describe('DashboardImportCtrl', function() {
beforeEach
(
function
()
{
ctx
.
ctrl
.
gnetUrl
=
'http://grafana.com/dashboards/123'
;
// setup api mock
backendSrv
.
get
=
sinon
.
spy
(()
=>
{
backendSrv
.
get
=
jest
.
fn
(()
=>
{
return
Promise
.
resolve
({
json
:
{}
});
...
...
@@ -60,7 +59,7 @@ describe('DashboardImportCtrl', function() {
});
it
(
'should call gnet api with correct dashboard id'
,
function
()
{
expect
(
backendSrv
.
get
.
getCall
(
0
).
args
[
0
]).
to
.
eql
(
'api/gnet/dashboards/123'
);
expect
(
backendSrv
.
get
.
mock
.
calls
[
0
][
0
]).
toBe
(
'api/gnet/dashboards/123'
);
});
});
...
...
@@ -68,7 +67,7 @@ describe('DashboardImportCtrl', function() {
beforeEach
(
function
()
{
ctx
.
ctrl
.
gnetUrl
=
'2342'
;
// setup api mock
backendSrv
.
get
=
sinon
.
spy
(()
=>
{
backendSrv
.
get
=
jest
.
fn
(()
=>
{
return
Promise
.
resolve
({
json
:
{}
});
...
...
@@ -77,10 +76,8 @@ describe('DashboardImportCtrl', function() {
});
it
(
'should call gnet api with correct dashboard id'
,
function
()
{
expect
(
backendSrv
.
get
.
getCall
(
0
).
args
[
0
]).
to
.
eql
(
'api/gnet/dashboards/2342'
);
expect
(
backendSrv
.
get
.
mock
.
calls
[
0
][
0
]).
toBe
(
'api/gnet/dashboards/2342'
);
});
});
});
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