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,38 +1,60 @@
import { PanelCtrl, MetricsPanelCtrl } from './panelStub'; import { PanelCtrl, MetricsPanelCtrl } from './panelStub';
jest.mock('grafana/app/features/templating/template_srv', () => { jest.mock(
'grafana/app/features/templating/template_srv',
() => {
return {}; return {};
}, {virtual: true}); },
{ virtual: true }
);
jest.mock('grafana/app/features/dashboard/dashboard_srv', () => { jest.mock(
'grafana/app/features/dashboard/dashboard_srv',
() => {
return {}; return {};
}, {virtual: true}); },
{ virtual: true }
);
jest.mock('@grafana/runtime', () => { jest.mock(
'@grafana/runtime',
() => {
return { return {
getBackendSrv: () => ({ getBackendSrv: () => ({
datasourceRequest: jest.fn().mockResolvedValue(), datasourceRequest: jest.fn().mockResolvedValue(),
}), }),
getTemplateSrv: () => ({ getTemplateSrv: () => ({
replace: jest.fn().mockImplementation(query => query), replace: jest.fn().mockImplementation((query) => query),
}), }),
}; };
}, {virtual: true}); },
{ virtual: true }
);
jest.mock('grafana/app/core/core_module', () => { jest.mock(
'grafana/app/core/core_module',
() => {
return { return {
directive: function () {}, directive: function () {},
}; };
}, {virtual: true}); },
{ virtual: true }
);
jest.mock('grafana/app/core/core', () => ({ jest.mock(
'grafana/app/core/core',
() => ({
contextSrv: {}, contextSrv: {},
}), {virtual: true}); }),
{ virtual: true }
);
const mockPanelCtrl = PanelCtrl; const mockPanelCtrl = PanelCtrl;
const mockMetricsPanelCtrl = MetricsPanelCtrl; const mockMetricsPanelCtrl = MetricsPanelCtrl;
jest.mock('grafana/app/plugins/sdk', () => { jest.mock(
'grafana/app/plugins/sdk',
() => {
return { return {
QueryCtrl: null, QueryCtrl: null,
PanelCtrl: mockPanelCtrl, PanelCtrl: mockPanelCtrl,
@@ -40,18 +62,26 @@ jest.mock('grafana/app/plugins/sdk', () => {
PanelCtrl: mockPanelCtrl, PanelCtrl: mockPanelCtrl,
MetricsPanelCtrl: mockMetricsPanelCtrl, MetricsPanelCtrl: mockMetricsPanelCtrl,
}; };
}, {virtual: true}); },
{ virtual: true }
);
jest.mock('grafana/app/core/utils/datemath', () => { jest.mock(
'grafana/app/core/utils/datemath',
() => {
const datemath = require('./modules/datemath'); const datemath = require('./modules/datemath');
return { return {
parse: datemath.parse, parse: datemath.parse,
parseDateMath: datemath.parseDateMath, parseDateMath: datemath.parseDateMath,
isValid: datemath.isValid isValid: datemath.isValid,
}; };
}, {virtual: true}); },
{ virtual: true }
);
jest.mock('grafana/app/core/table_model', () => { jest.mock(
'grafana/app/core/table_model',
() => {
return class TableModel { return class TableModel {
constructor() { constructor() {
this.columns = []; this.columns = [];
@@ -67,21 +97,27 @@ jest.mock('grafana/app/core/table_model', () => {
} }
} }
}; };
}, {virtual: true}); },
{ virtual: true }
);
jest.mock('grafana/app/core/config', () => { jest.mock(
'grafana/app/core/config',
() => {
return { return {
buildInfo: { env: 'development' } buildInfo: { env: 'development' },
}; };
}, {virtual: true}); },
{ virtual: true }
);
jest.mock('grafana/app/core/utils/kbn', () => { jest.mock(
'grafana/app/core/utils/kbn',
() => {
return { return {
round_interval: n => n, round_interval: (n) => n,
secondsToHms: n => n + 'ms' secondsToHms: (n) => n + 'ms',
}; };
}, {virtual: true}); },
{ virtual: true }
// Mock Canvas.getContext(), fixes );
// Error: Not implemented: HTMLCanvasElement.prototype.getContext (without installing the canvas npm package)
// window.HTMLCanvasElement.prototype.getContext = () => {};