mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
tests(playlist): add more test for playlist ui
This commit is contained in:
parent
7f15e2c167
commit
eef506d8c4
@ -41,7 +41,11 @@ export class PlaylistEditCtrl {
|
||||
});
|
||||
});
|
||||
|
||||
this.filteredTags = this.tagresult;
|
||||
this.filteredTags = _.reject(this.tagresult, (tag) => {
|
||||
return _.findWhere(this.playlistItems, (listPlaylistItem) => {
|
||||
return listPlaylistItem.value === tag.term;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
addPlaylistItem(playlistItem) {
|
||||
|
@ -2,7 +2,7 @@ import '../playlist_edit_ctrl';
|
||||
import {describe, beforeEach, it, expect} from 'test/lib/common';
|
||||
import {PlaylistEditCtrl} from '../playlist_edit_ctrl';
|
||||
|
||||
describe.only('PlaylistEditCtrl', function() {
|
||||
describe('PlaylistEditCtrl', () => {
|
||||
var ctx: any;
|
||||
beforeEach(() => {
|
||||
ctx = new PlaylistEditCtrl(null, null, null, null, { current: { params: {} } });
|
||||
@ -13,41 +13,45 @@ describe.only('PlaylistEditCtrl', function() {
|
||||
];
|
||||
|
||||
ctx.tagresult = [
|
||||
{ term: 'graphie', count: 1 },
|
||||
{ term: 'graphite', count: 1 },
|
||||
{ term: 'nyc', count: 2 }
|
||||
];
|
||||
});
|
||||
|
||||
describe('searchresult returns 2 dashboards', function() {
|
||||
it('found dashboard should be 2', function() {
|
||||
describe('searchresult returns 2 dashboards, ', () => {
|
||||
it('found dashboard should be 2', () => {
|
||||
expect(ctx.dashboardresult.length).to.be(2);
|
||||
});
|
||||
|
||||
it('filtred dashboard should be 2', function() {
|
||||
it('filtred result should be 2', () => {
|
||||
ctx.filterFoundPlaylistItems();
|
||||
expect(ctx.filteredDashboards.length).to.be(2);
|
||||
expect(ctx.filteredTags.length).to.be(2);
|
||||
});
|
||||
|
||||
describe('adds one dashboard to playlist', () => {
|
||||
describe('adds one dashboard to playlist, ', () => {
|
||||
beforeEach(() => {
|
||||
ctx.addPlaylistItem({ id: 2, title: 'dashboard: 2' });
|
||||
ctx.addTagPlaylistItem({ term: 'graphite' });
|
||||
ctx.filterFoundPlaylistItems();
|
||||
});
|
||||
|
||||
it('playlistitems should be increased by one', () => {
|
||||
expect(ctx.playlistItems.length).to.be(1);
|
||||
expect(ctx.playlistItems.length).to.be(2);
|
||||
});
|
||||
|
||||
it('filtred playlistitems should be reduced by one', () => {
|
||||
expect(ctx.filteredDashboards.length).to.be(1);
|
||||
expect(ctx.filteredTags.length).to.be(1);
|
||||
});
|
||||
|
||||
it('found dashboard should be 2', function() {
|
||||
it('found dashboard should be 2', () => {
|
||||
expect(ctx.dashboardresult.length).to.be(2);
|
||||
});
|
||||
|
||||
describe('removes one dashboard from playlist', () => {
|
||||
describe('removes one dashboard from playlist, ', () => {
|
||||
beforeEach(() => {
|
||||
ctx.removePlaylistItem(ctx.playlistItems[0]);
|
||||
ctx.removePlaylistItem(ctx.playlistItems[0]);
|
||||
ctx.filterFoundPlaylistItems();
|
||||
});
|
||||
@ -56,12 +60,11 @@ describe.only('PlaylistEditCtrl', function() {
|
||||
expect(ctx.playlistItems.length).to.be(0);
|
||||
});
|
||||
|
||||
it('found dashboard should be 2', function() {
|
||||
it('found dashboard should be 2', () => {
|
||||
expect(ctx.dashboardresult.length).to.be(2);
|
||||
});
|
||||
|
||||
it('filtred playlist should be reduced by one', () => {
|
||||
expect(ctx.filteredDashboards.length).to.be(2);
|
||||
expect(ctx.filteredTags.length).to.be(2);
|
||||
expect(ctx.tagresult.length).to.be(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user