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
35071649
Commit
35071649
authored
Jan 29, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests(playlist): refactor playlist edit ctrl
parent
d27bb4d3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
65 deletions
+49
-65
public/app/features/playlist/specs/playlist-edit-ctrl-specs.ts
+49
-65
No files found.
public/app/features/playlist/specs/playlist-edit-ctrl-specs.ts
View file @
35071649
import
'../playlist_edit_ctrl'
;
import
{
describe
,
beforeEach
,
it
,
expect
,
angularMocks
}
from
'test/lib/common'
;
import
helpers
from
'test/specs/helpers'
;
import
{
PlaylistEditCtrl
}
from
'../playlist_edit_ctrl'
;
describe
(
'PlaylistEditCtrl'
,
function
()
{
var
ctx
=
new
helpers
.
ControllerTestContext
();
describe
.
only
(
'PlaylistEditCtrl'
,
function
()
{
var
ctx
:
any
;
beforeEach
(()
=>
{
ctx
=
new
PlaylistEditCtrl
(
null
,
null
,
null
,
null
,
{
current
:
{
params
:
{}
}
});
var
searchResult
=
[
{
id
:
2
,
title
:
'dashboard: 2'
},
{
id
:
3
,
title
:
'dashboard: 3'
}
ctx
.
dashboardresult
=
[
{
id
:
2
,
title
:
'dashboard: 2'
},
{
id
:
3
,
title
:
'dashboard: 3'
}
];
var
playlistSrv
=
{};
var
backendSrv
=
{
search
:
(
query
)
=>
{
return
ctx
.
$q
.
when
(
searchResult
);
}
};
beforeEach
(
angularMocks
.
module
(
'grafana.core'
));
beforeEach
(
angularMocks
.
module
(
'grafana.controllers'
));
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
ctx
.
providePhase
({
playlistSrv
:
playlistSrv
,
backendSrv
:
backendSrv
,
$route
:
{
current
:
{
params
:
{
}
}
},
}));
beforeEach
(
ctx
.
createControllerPhase
(
'PlaylistEditCtrl'
));
ctx
.
tagresult
=
[
{
term
:
'graphie'
,
count
:
1
},
{
term
:
'nyc'
,
count
:
2
}
];
});
beforeEach
(()
=>
{
ctx
.
scope
.
$digest
();
describe
(
'searchresult returns 2 dashboards'
,
function
()
{
it
(
'found dashboard should be 2'
,
function
()
{
expect
(
ctx
.
dashboardresult
.
length
).
to
.
be
(
2
);
});
describe
(
'searchresult returns 2 dashboards'
,
function
()
{
it
(
'found dashboard should be 2'
,
function
()
{
expect
(
ctx
.
scope
.
foundPlaylistItems
.
length
).
to
.
be
(
2
);
});
it
(
'filtred dashboard should be 2'
,
function
()
{
expect
(
ctx
.
scope
.
filteredPlaylistItems
.
length
).
to
.
be
(
2
);
});
it
(
'filtred dashboard should be 2'
,
function
()
{
ctx
.
filterFoundPlaylistItems
();
expect
(
ctx
.
filteredDashboards
.
length
).
to
.
be
(
2
);
});
describe
(
'adds one dashboard to playlist'
,
()
=>
{
beforeEach
(()
=>
{
ctx
.
scope
.
addPlaylistItem
({
id
:
2
,
title
:
'dashboard: 2'
});
});
describe
(
'adds one dashboard to playlist'
,
()
=>
{
beforeEach
(()
=>
{
ctx
.
addPlaylistItem
({
id
:
2
,
title
:
'dashboard: 2'
});
ctx
.
filterFoundPlaylistItems
();
});
it
(
'playlistitems should be increased by one'
,
()
=>
{
expect
(
ctx
.
scope
.
playlistItems
.
length
).
to
.
be
(
1
);
});
it
(
'playlistitems should be increased by one'
,
()
=>
{
expect
(
ctx
.
playlistItems
.
length
).
to
.
be
(
1
);
});
it
(
'filtred playlistitems should be reduced by one'
,
()
=>
{
expect
(
ctx
.
scope
.
filteredPlaylistItem
s
.
length
).
to
.
be
(
1
);
});
it
(
'filtred playlistitems should be reduced by one'
,
()
=>
{
expect
(
ctx
.
filteredDashboard
s
.
length
).
to
.
be
(
1
);
});
it
(
'found dashboard should be 2'
,
function
()
{
expect
(
ctx
.
scope
.
foundPlaylistItems
.
length
).
to
.
be
(
2
);
});
it
(
'found dashboard should be 2'
,
function
()
{
expect
(
ctx
.
dashboardresult
.
length
).
to
.
be
(
2
);
});
describe
(
'removes one dashboard from playlist'
,
()
=>
{
beforeEach
(()
=>
{
ctx
.
scope
.
removePlaylistItem
(
ctx
.
scope
.
playlistItems
[
0
]);
});
describe
(
'removes one dashboard from playlist'
,
()
=>
{
beforeEach
(()
=>
{
ctx
.
removePlaylistItem
(
ctx
.
playlistItems
[
0
]);
ctx
.
filterFoundPlaylistItems
();
});
it
(
'playlistitems should be increased by one'
,
()
=>
{
expect
(
ctx
.
scope
.
playlistItems
.
length
).
to
.
be
(
0
);
});
it
(
'playlistitems should be increased by one'
,
()
=>
{
expect
(
ctx
.
playlistItems
.
length
).
to
.
be
(
0
);
});
it
(
'found dashboard should be 2'
,
function
()
{
expect
(
ctx
.
scope
.
foundPlaylistItems
.
length
).
to
.
be
(
2
);
});
it
(
'found dashboard should be 2'
,
function
()
{
expect
(
ctx
.
dashboardresult
.
length
).
to
.
be
(
2
);
});
it
(
'filtred playlist should be reduced by one'
,
()
=>
{
expect
(
ctx
.
scope
.
filteredPlaylistItems
.
length
).
to
.
be
(
2
);
});
});
it
(
'filtred playlist should be reduced by one'
,
()
=>
{
expect
(
ctx
.
filteredDashboards
.
length
).
to
.
be
(
2
);
});
});
});
});
});
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