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
5bf72fc9
Commit
5bf72fc9
authored
Jun 18, 2018
by
Tobias Skarhed
Committed by
Torkel Ödegaard
Jun 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Karma to Jest: team_details_ctrl (#12321)
parent
2b849086
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
48 deletions
+42
-48
public/app/features/org/specs/team_details_ctrl.jest.ts
+42
-0
public/app/features/org/specs/team_details_ctrl_specs.ts
+0
-48
No files found.
public/app/features/org/specs/team_details_ctrl.jest.ts
0 → 100644
View file @
5bf72fc9
import
'../team_details_ctrl'
;
import
TeamDetailsCtrl
from
'../team_details_ctrl'
;
describe
(
'TeamDetailsCtrl'
,
()
=>
{
var
backendSrv
=
{
searchUsers
:
jest
.
fn
(()
=>
Promise
.
resolve
([])),
get
:
jest
.
fn
(()
=>
Promise
.
resolve
([])),
post
:
jest
.
fn
(()
=>
Promise
.
resolve
([])),
};
//Team id
var
routeParams
=
{
id
:
1
,
};
var
navModelSrv
=
{
getNav
:
jest
.
fn
(),
};
var
teamDetailsCtrl
=
new
TeamDetailsCtrl
({
$broadcast
:
jest
.
fn
()
},
backendSrv
,
routeParams
,
navModelSrv
);
describe
(
'when user is chosen to be added to team'
,
()
=>
{
beforeEach
(()
=>
{
teamDetailsCtrl
=
new
TeamDetailsCtrl
({
$broadcast
:
jest
.
fn
()
},
backendSrv
,
routeParams
,
navModelSrv
);
const
userItem
=
{
id
:
2
,
login
:
'user2'
,
};
teamDetailsCtrl
.
userPicked
(
userItem
);
});
it
(
'should parse the result and save to db'
,
()
=>
{
expect
(
backendSrv
.
post
.
mock
.
calls
[
0
][
0
]).
toBe
(
'/api/teams/1/members'
);
expect
(
backendSrv
.
post
.
mock
.
calls
[
0
][
1
].
userId
).
toBe
(
2
);
});
it
(
'should refresh the list after saving.'
,
()
=>
{
expect
(
backendSrv
.
get
.
mock
.
calls
[
0
][
0
]).
toBe
(
'/api/teams/1'
);
expect
(
backendSrv
.
get
.
mock
.
calls
[
1
][
0
]).
toBe
(
'/api/teams/1/members'
);
});
});
});
public/app/features/org/specs/team_details_ctrl_specs.ts
deleted
100644 → 0
View file @
2b849086
import
'../team_details_ctrl'
;
import
{
describe
,
beforeEach
,
it
,
expect
,
sinon
,
angularMocks
}
from
'test/lib/common'
;
import
TeamDetailsCtrl
from
'../team_details_ctrl'
;
describe
(
'TeamDetailsCtrl'
,
()
=>
{
var
ctx
:
any
=
{};
var
backendSrv
=
{
searchUsers
:
sinon
.
stub
().
returns
(
Promise
.
resolve
([])),
get
:
sinon
.
stub
().
returns
(
Promise
.
resolve
([])),
post
:
sinon
.
stub
().
returns
(
Promise
.
resolve
([])),
};
beforeEach
(
angularMocks
.
module
(
'grafana.core'
));
beforeEach
(
angularMocks
.
module
(
'grafana.controllers'
));
beforeEach
(
angularMocks
.
inject
((
$rootScope
,
$controller
,
$q
)
=>
{
ctx
.
$q
=
$q
;
ctx
.
scope
=
$rootScope
.
$new
();
ctx
.
ctrl
=
$controller
(
TeamDetailsCtrl
,
{
$scope
:
ctx
.
scope
,
backendSrv
:
backendSrv
,
$routeParams
:
{
id
:
1
},
navModelSrv
:
{
getNav
:
sinon
.
stub
()
},
});
})
);
describe
(
'when user is chosen to be added to team'
,
()
=>
{
beforeEach
(()
=>
{
const
userItem
=
{
id
:
2
,
login
:
'user2'
,
};
ctx
.
ctrl
.
userPicked
(
userItem
);
});
it
(
'should parse the result and save to db'
,
()
=>
{
expect
(
backendSrv
.
post
.
getCall
(
0
).
args
[
0
]).
to
.
eql
(
'/api/teams/1/members'
);
expect
(
backendSrv
.
post
.
getCall
(
0
).
args
[
1
].
userId
).
to
.
eql
(
2
);
});
it
(
'should refresh the list after saving.'
,
()
=>
{
expect
(
backendSrv
.
get
.
getCall
(
0
).
args
[
0
]).
to
.
eql
(
'/api/teams/1'
);
expect
(
backendSrv
.
get
.
getCall
(
1
).
args
[
0
]).
to
.
eql
(
'/api/teams/1/members'
);
});
});
});
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