Fix PR feedback

This commit is contained in:
Tobias Skarhed
2018-06-14 14:37:48 +02:00
parent a3552a60e1
commit 23abf044ff
@@ -14,43 +14,39 @@ describe('given dashboard with repeated panels', () => {
beforeEach(done => { beforeEach(done => {
dash = { dash = {
templating: { list: [] }, templating: {
annotations: { list: [] }, list: [
}; {
config.buildInfo = {
version: '3.0.2',
};
dash.templating.list.push({
name: 'apps', name: 'apps',
type: 'query', type: 'query',
datasource: 'gfdb', datasource: 'gfdb',
current: { value: 'Asd', text: 'Asd' }, current: { value: 'Asd', text: 'Asd' },
options: [{ value: 'Asd', text: 'Asd' }], options: [{ value: 'Asd', text: 'Asd' }],
}); },
{
dash.templating.list.push({
name: 'prefix', name: 'prefix',
type: 'constant', type: 'constant',
current: { value: 'collectd', text: 'collectd' }, current: { value: 'collectd', text: 'collectd' },
options: [], options: [],
}); },
{
dash.templating.list.push({
name: 'ds', name: 'ds',
type: 'datasource', type: 'datasource',
query: 'testdb', query: 'testdb',
current: { value: 'prod', text: 'prod' }, current: { value: 'prod', text: 'prod' },
options: [], options: [],
}); },
],
dash.annotations.list.push({ },
annotations: {
list: [
{
name: 'logs', name: 'logs',
datasource: 'gfdb', datasource: 'gfdb',
}); },
],
dash.panels = [ },
panels: [
{ id: 6, datasource: 'gfdb', type: 'graph' }, { id: 6, datasource: 'gfdb', type: 'graph' },
{ id: 7 }, { id: 7 },
{ {
@@ -59,15 +55,19 @@ describe('given dashboard with repeated panels', () => {
targets: [{ datasource: 'other' }], targets: [{ datasource: 'other' }],
}, },
{ id: 9, datasource: '$ds' }, { id: 9, datasource: '$ds' },
]; {
dash.panels.push({
id: 2, id: 2,
repeat: 'apps', repeat: 'apps',
datasource: 'gfdb', datasource: 'gfdb',
type: 'graph', type: 'graph',
}); },
dash.panels.push({ id: 3, repeat: null, repeatPanelId: 2 }); { id: 3, repeat: null, repeatPanelId: 2 },
],
};
config.buildInfo = {
version: '3.0.2',
};
//Stubs test function calls //Stubs test function calls
var datasourceSrvStub = { get: jest.fn(arg => getStub(arg)) }; var datasourceSrvStub = { get: jest.fn(arg => getStub(arg)) };
@@ -157,20 +157,19 @@ describe('given dashboard with repeated panels', () => {
}); });
}); });
function getStub(arg) { // Stub responses
// Stub responses var stubs = [];
var stubs = []; stubs['gfdb'] = {
stubs['gfdb'] = {
name: 'gfdb', name: 'gfdb',
meta: { id: 'testdb', info: { version: '1.2.1' }, name: 'TestDB' }, meta: { id: 'testdb', info: { version: '1.2.1' }, name: 'TestDB' },
}; };
stubs['other'] = { stubs['other'] = {
name: 'other', name: 'other',
meta: { id: 'other', info: { version: '1.2.1' }, name: 'OtherDB' }, meta: { id: 'other', info: { version: '1.2.1' }, name: 'OtherDB' },
}; };
stubs['-- Mixed --'] = { stubs['-- Mixed --'] = {
name: 'mixed', name: 'mixed',
meta: { meta: {
id: 'mixed', id: 'mixed',
@@ -178,9 +177,9 @@ function getStub(arg) {
name: 'Mixed', name: 'Mixed',
builtIn: true, builtIn: true,
}, },
}; };
stubs['-- Grafana --'] = { stubs['-- Grafana --'] = {
name: '-- Grafana --', name: '-- Grafana --',
meta: { meta: {
id: 'grafana', id: 'grafana',
@@ -188,7 +187,8 @@ function getStub(arg) {
name: 'grafana', name: 'grafana',
builtIn: true, builtIn: true,
}, },
}; };
function getStub(arg) {
return Promise.resolve(stubs[arg]); return Promise.resolve(stubs[arg]);
} }