Remove commented out code and format

This commit is contained in:
Zoltán Bedi
2023-09-24 23:41:35 +02:00
parent bd44b080c4
commit 50b9a83eec

View File

@@ -1,87 +1,123 @@
import { PanelCtrl, MetricsPanelCtrl } from './panelStub'; import { PanelCtrl, MetricsPanelCtrl } from './panelStub';
jest.mock('grafana/app/features/templating/template_srv', () => { jest.mock(
return {}; 'grafana/app/features/templating/template_srv',
}, {virtual: true}); () => {
return {};
},
{ virtual: true }
);
jest.mock('grafana/app/features/dashboard/dashboard_srv', () => { jest.mock(
return {}; 'grafana/app/features/dashboard/dashboard_srv',
}, {virtual: true}); () => {
return {};
},
{ virtual: true }
);
jest.mock('@grafana/runtime', () => { jest.mock(
return { '@grafana/runtime',
getBackendSrv: () => ({ () => {
datasourceRequest: jest.fn().mockResolvedValue(), return {
}), getBackendSrv: () => ({
getTemplateSrv: () => ({ datasourceRequest: jest.fn().mockResolvedValue(),
replace: jest.fn().mockImplementation(query => query), }),
}), getTemplateSrv: () => ({
}; replace: jest.fn().mockImplementation((query) => query),
}, {virtual: true}); }),
};
},
{ virtual: true }
);
jest.mock('grafana/app/core/core_module', () => { jest.mock(
return { 'grafana/app/core/core_module',
directive: function() {}, () => {
}; return {
}, {virtual: true}); directive: function () {},
};
},
{ virtual: true }
);
jest.mock('grafana/app/core/core', () => ({ jest.mock(
contextSrv: {}, 'grafana/app/core/core',
}), {virtual: true}); () => ({
contextSrv: {},
}),
{ virtual: true }
);
const mockPanelCtrl = PanelCtrl; const mockPanelCtrl = PanelCtrl;
const mockMetricsPanelCtrl = MetricsPanelCtrl; const mockMetricsPanelCtrl = MetricsPanelCtrl;
jest.mock('grafana/app/plugins/sdk', () => { jest.mock(
return { 'grafana/app/plugins/sdk',
QueryCtrl: null, () => {
PanelCtrl: mockPanelCtrl, return {
loadPluginCss: () => {}, QueryCtrl: null,
PanelCtrl: mockPanelCtrl, PanelCtrl: mockPanelCtrl,
MetricsPanelCtrl: mockMetricsPanelCtrl, loadPluginCss: () => {},
}; PanelCtrl: mockPanelCtrl,
}, {virtual: true}); MetricsPanelCtrl: mockMetricsPanelCtrl,
};
},
{ virtual: true }
);
jest.mock('grafana/app/core/utils/datemath', () => { jest.mock(
const datemath = require('./modules/datemath'); 'grafana/app/core/utils/datemath',
return { () => {
parse: datemath.parse, const datemath = require('./modules/datemath');
parseDateMath: datemath.parseDateMath, return {
isValid: datemath.isValid parse: datemath.parse,
}; parseDateMath: datemath.parseDateMath,
}, {virtual: true}); isValid: datemath.isValid,
};
},
{ virtual: true }
);
jest.mock('grafana/app/core/table_model', () => { jest.mock(
return class TableModel { 'grafana/app/core/table_model',
constructor() { () => {
this.columns = []; return class TableModel {
this.columnMap = {}; constructor() {
this.rows = []; this.columns = [];
this.type = 'table'; this.columnMap = {};
} this.rows = [];
this.type = 'table';
addColumn(col) {
if (!this.columnMap[col.text]) {
this.columns.push(col);
this.columnMap[col.text] = col;
} }
}
};
}, {virtual: true});
jest.mock('grafana/app/core/config', () => { addColumn(col) {
return { if (!this.columnMap[col.text]) {
buildInfo: { env: 'development' } this.columns.push(col);
}; this.columnMap[col.text] = col;
}, {virtual: true}); }
}
};
},
{ virtual: true }
);
jest.mock('grafana/app/core/utils/kbn', () => { jest.mock(
return { 'grafana/app/core/config',
round_interval: n => n, () => {
secondsToHms: n => n + 'ms' return {
}; buildInfo: { env: 'development' },
}, {virtual: true}); };
},
{ virtual: true }
);
// Mock Canvas.getContext(), fixes jest.mock(
// Error: Not implemented: HTMLCanvasElement.prototype.getContext (without installing the canvas npm package) 'grafana/app/core/utils/kbn',
// window.HTMLCanvasElement.prototype.getContext = () => {}; () => {
return {
round_interval: (n) => n,
secondsToHms: (n) => n + 'ms',
};
},
{ virtual: true }
);