From 0662b5f962eb43a92ea7bba2e7eaeb4da6eabebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 14 Oct 2018 11:13:04 +0200 Subject: [PATCH] fixing unit tests --- .../app/features/dashboard/dashgrid/QueriesTab.tsx | 14 ++++++++++---- public/app/features/dashboard/panel_model.ts | 2 -- .../features/dashboard/specs/viewstate_srv.test.ts | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/public/app/features/dashboard/dashgrid/QueriesTab.tsx b/public/app/features/dashboard/dashgrid/QueriesTab.tsx index 179d074d547..21159df00aa 100644 --- a/public/app/features/dashboard/dashgrid/QueriesTab.tsx +++ b/public/app/features/dashboard/dashgrid/QueriesTab.tsx @@ -21,15 +21,21 @@ export class QueriesTab extends React.Component { return; } + const { panel, dashboard } = this.props; + + // make sure the panel has datasource & queries properties + panel.datasource = panel.datasource || null; + panel.targets = panel.targets || [{}]; + const loader = getAngularLoader(); const template = ''; const scopeProps = { ctrl: { - panel: this.props.panel, - dashboard: this.props.dashboard, + panel: panel, + dashboard: dashboard, panelCtrl: { - panel: this.props.panel, - dashboard: this.props.dashboard, + panel: panel, + dashboard: dashboard, }, }, }; diff --git a/public/app/features/dashboard/panel_model.ts b/public/app/features/dashboard/panel_model.ts index a3053ae48f8..415238d4e7b 100644 --- a/public/app/features/dashboard/panel_model.ts +++ b/public/app/features/dashboard/panel_model.ts @@ -52,8 +52,6 @@ export class PanelModel { // defaults this.gridPos = this.gridPos || { x: 0, y: 0, h: 3, w: 6 }; - this.datasource = this.datasource || null; - this.targets = this.targets || [{}]; } getSaveModel() { diff --git a/public/app/features/dashboard/specs/viewstate_srv.test.ts b/public/app/features/dashboard/specs/viewstate_srv.test.ts index c2d9a28ea51..f9963afbf85 100644 --- a/public/app/features/dashboard/specs/viewstate_srv.test.ts +++ b/public/app/features/dashboard/specs/viewstate_srv.test.ts @@ -11,6 +11,7 @@ describe('when updating view state', () => { }; const $scope = { + appEvent: jest.fn(), onAppEvent: jest.fn(() => {}), dashboard: new DashboardModel({ panels: [{ id: 1 }],