From f3545f01e5e1c27af76cbc80de1e9ed9ec29ab0c Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Tue, 12 May 2020 19:24:43 +0300 Subject: [PATCH] fix panel migration tests --- src/panel-triggers/specs/migrations.spec.ts | 33 +++++++-------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/src/panel-triggers/specs/migrations.spec.ts b/src/panel-triggers/specs/migrations.spec.ts index d28b484..5026028 100644 --- a/src/panel-triggers/specs/migrations.spec.ts +++ b/src/panel-triggers/specs/migrations.spec.ts @@ -1,8 +1,8 @@ import _ from 'lodash'; import mocks from '../../test-setup/mocks'; import {TriggerPanelCtrl} from '../triggers_panel_ctrl'; -import {DEFAULT_TARGET, DEFAULT_SEVERITY, PANEL_DEFAULTS} from '../triggers_panel_ctrl'; -import {CURRENT_SCHEMA_VERSION} from '../migrations'; +import { DEFAULT_TARGET, DEFAULT_SEVERITY, PANEL_DEFAULTS } from '../triggers_panel_ctrl'; +import { CURRENT_SCHEMA_VERSION } from '../migrations'; jest.mock('@grafana/runtime', () => { return { @@ -56,10 +56,17 @@ describe('Triggers Panel schema migration', () => { const expected = _.defaultsDeep({ schemaVersion: CURRENT_SCHEMA_VERSION, + datasource: 'zabbix', targets: [ { ...DEFAULT_TARGET, - datasource: 'zabbix', + queryType: 5, + options: { + hostsInMaintenance: true, + showTriggers: 'all triggers', + sortTriggersBy: { text: 'last change', value: 'lastchange' }, + showEvents: { text: 'Problems', value: 1 }, + } } ], ageField: true, @@ -79,27 +86,7 @@ describe('Triggers Panel schema migration', () => { const expected = _.defaultsDeep({ schemaVersion: CURRENT_SCHEMA_VERSION, - targets: [{ - ...DEFAULT_TARGET, - datasource: 'zabbix_default' - }] }, PANEL_DEFAULTS); expect(updatedPanelCtrl.panel).toEqual(expected); }); - - it('should set default targets for new panel with empty targets', () => { - ctx.scope.panel = { - targets: [] - }; - const updatedPanelCtrl = updatePanelCtrl(ctx.scope); - - const expected = _.defaultsDeep({ - targets: [{ - ...DEFAULT_TARGET, - datasource: 'zabbix_default' - }] - }, PANEL_DEFAULTS); - - expect(updatedPanelCtrl.panel).toEqual(expected); - }); });