From 98408bf92c1c33a27705c1ea9d39a25741822a91 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Thu, 18 Jun 2020 12:09:09 +0300 Subject: [PATCH] remove old alerting tests --- .../specs/datasource.spec.js | 106 +----------------- src/test-setup/mocks.js | 6 - 2 files changed, 1 insertion(+), 111 deletions(-) diff --git a/src/datasource-zabbix/specs/datasource.spec.js b/src/datasource-zabbix/specs/datasource.spec.js index 873a3d3..23b5e5f 100644 --- a/src/datasource-zabbix/specs/datasource.spec.js +++ b/src/datasource-zabbix/specs/datasource.spec.js @@ -29,9 +29,8 @@ describe('ZabbixDatasource', () => { ctx.templateSrv = mocks.templateSrvMock; ctx.datasourceSrv = mocks.datasourceSrvMock; - ctx.zabbixAlertingSrv = mocks.zabbixAlertingSrvMock; - ctx.ds = new ZabbixDatasource(ctx.instanceSettings, ctx.templateSrv, ctx.zabbixAlertingSrv); + ctx.ds = new ZabbixDatasource(ctx.instanceSettings, ctx.templateSrv); }); describe('When querying data', () => { @@ -330,107 +329,4 @@ describe('ZabbixDatasource', () => { done(); }); }); - - describe('When querying alerts', () => { - let options = {}; - - beforeEach(() => { - ctx.ds.replaceTemplateVars = (str) => str; - - let targetItems = [{ - "itemid": "1", - "name": "test item", - "key_": "test.key", - "value_type": "3", - "hostid": "10631", - "status": "0", - "state": "0", - "hosts": [{"hostid": "10631", "name": "Test host"}], - "item": "Test item" - }]; - ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve(targetItems)); - - options = { - "panelId": 10, - "targets": [{ - "application": {"filter": ""}, - "group": {"filter": "Test group"}, - "host": {"filter": "Test host"}, - "item": {"filter": "Test item"}, - }] - }; - }); - - it('should return threshold when comparative symbol is `less than`', () => { - - let itemTriggers = [{ - "triggerid": "15383", - "priority": "4", - "expression": "{15915}<100", - }]; - - ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers)); - - return ctx.ds.alertQuery(options) - .then(resp => { - expect(resp.thresholds).toHaveLength(1); - expect(resp.thresholds[0]).toBe(100); - return resp; - }); - }); - - it('should return threshold when comparative symbol is `less than or equal`', () => { - - let itemTriggers = [{ - "triggerid": "15383", - "priority": "4", - "expression": "{15915}<=100", - }]; - - ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers)); - - return ctx.ds.alertQuery(options) - .then(resp => { - expect(resp.thresholds.length).toBe(1); - expect(resp.thresholds[0]).toBe(100); - return resp; - }); - }); - - it('should return threshold when comparative symbol is `greater than or equal`', () => { - - let itemTriggers = [{ - "triggerid": "15383", - "priority": "4", - "expression": "{15915}>=30", - }]; - - ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers)); - - return ctx.ds.alertQuery(options) - .then(resp => { - expect(resp.thresholds.length).toBe(1); - expect(resp.thresholds[0]).toBe(30); - return resp; - }); - }); - - it('should return threshold when comparative symbol is `equal`', () => { - - let itemTriggers = [{ - "triggerid": "15383", - "priority": "4", - "expression": "{15915}=50", - }]; - - ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers)); - - return ctx.ds.alertQuery(options) - .then(resp => { - expect(resp.thresholds.length).toBe(1); - expect(resp.thresholds[0]).toBe(50); - return resp; - }); - }); - }); }); diff --git a/src/test-setup/mocks.js b/src/test-setup/mocks.js index e5f910e..f2b659c 100644 --- a/src/test-setup/mocks.js +++ b/src/test-setup/mocks.js @@ -15,17 +15,11 @@ export let timeSrvMock = { timeRange: jest.fn().mockReturnValue({ from: '', to: '' }) }; -export let zabbixAlertingSrvMock = { - setPanelAlertState: jest.fn(), - removeZabbixThreshold: jest.fn(), -}; - const defaultExports = { templateSrvMock, backendSrvMock, datasourceSrvMock, timeSrvMock, - zabbixAlertingSrvMock }; export default defaultExports;