diff --git a/public/app/features/admin/admin.ts b/public/app/features/admin/admin.ts index 383b50b5d25..00e98821779 100644 --- a/public/app/features/admin/admin.ts +++ b/public/app/features/admin/admin.ts @@ -12,7 +12,7 @@ class AdminSettingsCtrl { constructor($scope, backendSrv, navModelSrv) { this.navModel = navModelSrv.getNav('cfg', 'admin', 'server-settings', 1); - backendSrv.get('/api/admin/settings').then(function(settings) { + backendSrv.get('/api/admin/settings').then(settings => { $scope.settings = settings; }); } diff --git a/public/app/features/admin/admin_edit_org_ctrl.ts b/public/app/features/admin/admin_edit_org_ctrl.ts index d1e201dbe58..ec3f8548023 100644 --- a/public/app/features/admin/admin_edit_org_ctrl.ts +++ b/public/app/features/admin/admin_edit_org_ctrl.ts @@ -3,7 +3,7 @@ import angular from 'angular'; export class AdminEditOrgCtrl { /** @ngInject */ constructor($scope, $routeParams, backendSrv, $location, navModelSrv) { - $scope.init = function() { + $scope.init = () => { $scope.navModel = navModelSrv.getNav('cfg', 'admin', 'global-orgs', 1); if ($routeParams.id) { @@ -12,34 +12,34 @@ export class AdminEditOrgCtrl { } }; - $scope.getOrg = function(id) { - backendSrv.get('/api/orgs/' + id).then(function(org) { + $scope.getOrg = id => { + backendSrv.get('/api/orgs/' + id).then(org => { $scope.org = org; }); }; - $scope.getOrgUsers = function(id) { - backendSrv.get('/api/orgs/' + id + '/users').then(function(orgUsers) { + $scope.getOrgUsers = id => { + backendSrv.get('/api/orgs/' + id + '/users').then(orgUsers => { $scope.orgUsers = orgUsers; }); }; - $scope.update = function() { + $scope.update = () => { if (!$scope.orgDetailsForm.$valid) { return; } - backendSrv.put('/api/orgs/' + $scope.org.id, $scope.org).then(function() { + backendSrv.put('/api/orgs/' + $scope.org.id, $scope.org).then(() => { $location.path('/admin/orgs'); }); }; - $scope.updateOrgUser = function(orgUser) { + $scope.updateOrgUser = orgUser => { backendSrv.patch('/api/orgs/' + orgUser.orgId + '/users/' + orgUser.userId, orgUser); }; - $scope.removeOrgUser = function(orgUser) { - backendSrv.delete('/api/orgs/' + orgUser.orgId + '/users/' + orgUser.userId).then(function() { + $scope.removeOrgUser = orgUser => { + backendSrv.delete('/api/orgs/' + orgUser.orgId + '/users/' + orgUser.userId).then(() => { $scope.getOrgUsers($scope.org.id); }); }; diff --git a/public/app/features/admin/admin_edit_user_ctrl.ts b/public/app/features/admin/admin_edit_user_ctrl.ts index b84b690d44a..c34ccdc1cad 100644 --- a/public/app/features/admin/admin_edit_user_ctrl.ts +++ b/public/app/features/admin/admin_edit_user_ctrl.ts @@ -9,72 +9,72 @@ export class AdminEditUserCtrl { $scope.permissions = {}; $scope.navModel = navModelSrv.getNav('cfg', 'admin', 'global-users', 1); - $scope.init = function() { + $scope.init = () => { if ($routeParams.id) { $scope.getUser($routeParams.id); $scope.getUserOrgs($routeParams.id); } }; - $scope.getUser = function(id) { - backendSrv.get('/api/users/' + id).then(function(user) { + $scope.getUser = id => { + backendSrv.get('/api/users/' + id).then(user => { $scope.user = user; $scope.user_id = id; $scope.permissions.isGrafanaAdmin = user.isGrafanaAdmin; }); }; - $scope.setPassword = function() { + $scope.setPassword = () => { if (!$scope.passwordForm.$valid) { return; } const payload = { password: $scope.password }; - backendSrv.put('/api/admin/users/' + $scope.user_id + '/password', payload).then(function() { + backendSrv.put('/api/admin/users/' + $scope.user_id + '/password', payload).then(() => { $location.path('/admin/users'); }); }; - $scope.updatePermissions = function() { + $scope.updatePermissions = () => { const payload = $scope.permissions; - backendSrv.put('/api/admin/users/' + $scope.user_id + '/permissions', payload).then(function() { + backendSrv.put('/api/admin/users/' + $scope.user_id + '/permissions', payload).then(() => { $location.path('/admin/users'); }); }; - $scope.create = function() { + $scope.create = () => { if (!$scope.userForm.$valid) { return; } - backendSrv.post('/api/admin/users', $scope.user).then(function() { + backendSrv.post('/api/admin/users', $scope.user).then(() => { $location.path('/admin/users'); }); }; - $scope.getUserOrgs = function(id) { - backendSrv.get('/api/users/' + id + '/orgs').then(function(orgs) { + $scope.getUserOrgs = id => { + backendSrv.get('/api/users/' + id + '/orgs').then(orgs => { $scope.orgs = orgs; }); }; - $scope.update = function() { + $scope.update = () => { if (!$scope.userForm.$valid) { return; } - backendSrv.put('/api/users/' + $scope.user_id, $scope.user).then(function() { + backendSrv.put('/api/users/' + $scope.user_id, $scope.user).then(() => { $location.path('/admin/users'); }); }; - $scope.updateOrgUser = function(orgUser) { - backendSrv.patch('/api/orgs/' + orgUser.orgId + '/users/' + $scope.user_id, orgUser).then(function() {}); + $scope.updateOrgUser = orgUser => { + backendSrv.patch('/api/orgs/' + orgUser.orgId + '/users/' + $scope.user_id, orgUser).then(() => {}); }; - $scope.removeOrgUser = function(orgUser) { - backendSrv.delete('/api/orgs/' + orgUser.orgId + '/users/' + $scope.user_id).then(function() { + $scope.removeOrgUser = orgUser => { + backendSrv.delete('/api/orgs/' + orgUser.orgId + '/users/' + $scope.user_id).then(() => { $scope.getUser($scope.user_id); $scope.getUserOrgs($scope.user_id); }); @@ -82,19 +82,19 @@ export class AdminEditUserCtrl { $scope.orgsSearchCache = []; - $scope.searchOrgs = function(queryStr, callback) { + $scope.searchOrgs = (queryStr, callback) => { if ($scope.orgsSearchCache.length > 0) { callback(_.map($scope.orgsSearchCache, 'name')); return; } - backendSrv.get('/api/orgs', { query: '' }).then(function(result) { + backendSrv.get('/api/orgs', { query: '' }).then(result => { $scope.orgsSearchCache = result; callback(_.map(result, 'name')); }); }; - $scope.addOrgUser = function() { + $scope.addOrgUser = () => { if (!$scope.addOrgForm.$valid) { return; } @@ -108,7 +108,7 @@ export class AdminEditUserCtrl { $scope.newOrg.loginOrEmail = $scope.user.login; - backendSrv.post('/api/orgs/' + orgInfo.id + '/users/', $scope.newOrg).then(function() { + backendSrv.post('/api/orgs/' + orgInfo.id + '/users/', $scope.newOrg).then(() => { $scope.getUser($scope.user_id); $scope.getUserOrgs($scope.user_id); }); diff --git a/public/app/features/admin/admin_list_orgs_ctrl.ts b/public/app/features/admin/admin_list_orgs_ctrl.ts index d6d1b9e7dda..0513752aa3e 100644 --- a/public/app/features/admin/admin_list_orgs_ctrl.ts +++ b/public/app/features/admin/admin_list_orgs_ctrl.ts @@ -3,26 +3,26 @@ import angular from 'angular'; export class AdminListOrgsCtrl { /** @ngInject */ constructor($scope, backendSrv, navModelSrv) { - $scope.init = function() { + $scope.init = () => { $scope.navModel = navModelSrv.getNav('cfg', 'admin', 'global-orgs', 1); $scope.getOrgs(); }; - $scope.getOrgs = function() { - backendSrv.get('/api/orgs').then(function(orgs) { + $scope.getOrgs = () => { + backendSrv.get('/api/orgs').then(orgs => { $scope.orgs = orgs; }); }; - $scope.deleteOrg = function(org) { + $scope.deleteOrg = org => { $scope.appEvent('confirm-modal', { title: 'Delete', text: 'Do you want to delete organization ' + org.name + '?', text2: 'All dashboards for this organization will be removed!', icon: 'fa-trash', yesText: 'Delete', - onConfirm: function() { - backendSrv.delete('/api/orgs/' + org.id).then(function() { + onConfirm: () => { + backendSrv.delete('/api/orgs/' + org.id).then(() => { $scope.getOrgs(); }); }, diff --git a/public/app/features/annotations/specs/annotations_srv.test.ts b/public/app/features/annotations/specs/annotations_srv.test.ts index f262544da43..a00fc9b841d 100644 --- a/public/app/features/annotations/specs/annotations_srv.test.ts +++ b/public/app/features/annotations/specs/annotations_srv.test.ts @@ -2,7 +2,7 @@ import '../annotations_srv'; import 'app/features/dashboard/time_srv'; import { AnnotationsSrv } from '../annotations_srv'; -describe('AnnotationsSrv', function() { +describe('AnnotationsSrv', () => { const $rootScope = { onAppEvent: jest.fn(), }; diff --git a/public/app/features/dashboard/specs/dashboard_import_ctrl.test.ts b/public/app/features/dashboard/specs/dashboard_import_ctrl.test.ts index fca857184f1..bcde009cb3a 100644 --- a/public/app/features/dashboard/specs/dashboard_import_ctrl.test.ts +++ b/public/app/features/dashboard/specs/dashboard_import_ctrl.test.ts @@ -1,7 +1,7 @@ import { DashboardImportCtrl } from '../dashboard_import_ctrl'; import config from '../../../core/config'; -describe('DashboardImportCtrl', function() { +describe('DashboardImportCtrl', () => { const ctx: any = {}; let navModelSrv; @@ -26,8 +26,8 @@ describe('DashboardImportCtrl', function() { ctx.ctrl = new DashboardImportCtrl(backendSrv, validationSrv, navModelSrv, {}, {}); }); - describe('when uploading json', function() { - beforeEach(function() { + describe('when uploading json', () => { + beforeEach(() => { config.datasources = { ds: { type: 'test-db', @@ -46,19 +46,19 @@ describe('DashboardImportCtrl', function() { }); }); - it('should build input model', function() { + it('should build input model', () => { expect(ctx.ctrl.inputs.length).toBe(1); expect(ctx.ctrl.inputs[0].name).toBe('ds'); expect(ctx.ctrl.inputs[0].info).toBe('Select a Test DB data source'); }); - it('should set inputValid to false', function() { + it('should set inputValid to false', () => { expect(ctx.ctrl.inputsValid).toBe(false); }); }); - describe('when specifying grafana.com url', function() { - beforeEach(function() { + describe('when specifying grafana.com url', () => { + beforeEach(() => { ctx.ctrl.gnetUrl = 'http://grafana.com/dashboards/123'; // setup api mock backendSrv.get = jest.fn(() => { @@ -69,13 +69,13 @@ describe('DashboardImportCtrl', function() { return ctx.ctrl.checkGnetDashboard(); }); - it('should call gnet api with correct dashboard id', function() { + it('should call gnet api with correct dashboard id', () => { expect(backendSrv.get.mock.calls[0][0]).toBe('api/gnet/dashboards/123'); }); }); - describe('when specifying dashboard id', function() { - beforeEach(function() { + describe('when specifying dashboard id', () => { + beforeEach(() => { ctx.ctrl.gnetUrl = '2342'; // setup api mock backendSrv.get = jest.fn(() => { @@ -86,7 +86,7 @@ describe('DashboardImportCtrl', function() { return ctx.ctrl.checkGnetDashboard(); }); - it('should call gnet api with correct dashboard id', function() { + it('should call gnet api with correct dashboard id', () => { expect(backendSrv.get.mock.calls[0][0]).toBe('api/gnet/dashboards/2342'); }); }); diff --git a/public/app/features/dashboard/specs/dashboard_migration.test.ts b/public/app/features/dashboard/specs/dashboard_migration.test.ts index d07df0e7be2..5f693c9f6d9 100644 --- a/public/app/features/dashboard/specs/dashboard_migration.test.ts +++ b/public/app/features/dashboard/specs/dashboard_migration.test.ts @@ -6,14 +6,14 @@ import { expect } from 'test/lib/common'; jest.mock('app/core/services/context_srv', () => ({})); -describe('DashboardModel', function() { - describe('when creating dashboard with old schema', function() { +describe('DashboardModel', () => { + describe('when creating dashboard with old schema', () => { let model; let graph; let singlestat; let table; - beforeEach(function() { + beforeEach(() => { model = new DashboardModel({ services: { filter: { time: { from: 'now-1d', to: 'now' }, list: [{}] }, @@ -65,52 +65,52 @@ describe('DashboardModel', function() { table = model.panels[2]; }); - it('should have title', function() { + it('should have title', () => { expect(model.title).toBe('No Title'); }); - it('should have panel id', function() { + it('should have panel id', () => { expect(graph.id).toBe(1); }); - it('should move time and filtering list', function() { + it('should move time and filtering list', () => { expect(model.time.from).toBe('now-1d'); expect(model.templating.list[0].allFormat).toBe('glob'); }); - it('graphite panel should change name too graph', function() { + it('graphite panel should change name too graph', () => { expect(graph.type).toBe('graph'); }); - it('single stat panel should have two thresholds', function() { + it('single stat panel should have two thresholds', () => { expect(singlestat.thresholds).toBe('20,30'); }); - it('queries without refId should get it', function() { + it('queries without refId should get it', () => { expect(graph.targets[1].refId).toBe('B'); }); - it('update legend setting', function() { + it('update legend setting', () => { expect(graph.legend.show).toBe(true); }); - it('move aliasYAxis to series override', function() { + it('move aliasYAxis to series override', () => { expect(graph.seriesOverrides[0].alias).toBe('test'); expect(graph.seriesOverrides[0].yaxis).toBe(2); }); - it('should move pulldowns to new schema', function() { + it('should move pulldowns to new schema', () => { expect(model.annotations.list[1].name).toBe('old'); }); - it('table panel should only have two thresholds values', function() { + it('table panel should only have two thresholds values', () => { expect(table.styles[0].thresholds[0]).toBe('20'); expect(table.styles[0].thresholds[1]).toBe('30'); expect(table.styles[1].thresholds[0]).toBe('200'); expect(table.styles[1].thresholds[1]).toBe('300'); }); - it('graph grid to yaxes options', function() { + it('graph grid to yaxes options', () => { expect(graph.yaxes[0].min).toBe(1); expect(graph.yaxes[0].max).toBe(10); expect(graph.yaxes[0].format).toBe('kbyte'); @@ -126,11 +126,11 @@ describe('DashboardModel', function() { expect(graph.y_formats).toBe(undefined); }); - it('dashboard schema version should be set to latest', function() { + it('dashboard schema version should be set to latest', () => { expect(model.schemaVersion).toBe(16); }); - it('graph thresholds should be migrated', function() { + it('graph thresholds should be migrated', () => { expect(graph.thresholds.length).toBe(2); expect(graph.thresholds[0].op).toBe('gt'); expect(graph.thresholds[0].value).toBe(200); @@ -140,16 +140,16 @@ describe('DashboardModel', function() { }); }); - describe('when migrating to the grid layout', function() { + describe('when migrating to the grid layout', () => { let model; - beforeEach(function() { + beforeEach(() => { model = { rows: [], }; }); - it('should create proper grid', function() { + it('should create proper grid', () => { model.rows = [createRow({ collapse: false, height: 8 }, [[6], [6]])]; const dashboard = new DashboardModel(model); const panelGridPos = getGridPositions(dashboard); @@ -158,7 +158,7 @@ describe('DashboardModel', function() { expect(panelGridPos).toEqual(expectedGrid); }); - it('should add special "row" panel if row is collapsed', function() { + it('should add special "row" panel if row is collapsed', () => { model.rows = [createRow({ collapse: true, height: 8 }, [[6], [6]]), createRow({ height: 8 }, [[12]])]; const dashboard = new DashboardModel(model); const panelGridPos = getGridPositions(dashboard); @@ -171,7 +171,7 @@ describe('DashboardModel', function() { expect(panelGridPos).toEqual(expectedGrid); }); - it('should add special "row" panel if row has visible title', function() { + it('should add special "row" panel if row has visible title', () => { model.rows = [ createRow({ showTitle: true, title: 'Row', height: 8 }, [[6], [6]]), createRow({ height: 8 }, [[12]]), @@ -189,7 +189,7 @@ describe('DashboardModel', function() { expect(panelGridPos).toEqual(expectedGrid); }); - it('should not add "row" panel if row has not visible title or not collapsed', function() { + it('should not add "row" panel if row has not visible title or not collapsed', () => { model.rows = [ createRow({ collapse: true, height: 8 }, [[12]]), createRow({ height: 8 }, [[12]]), @@ -212,7 +212,7 @@ describe('DashboardModel', function() { expect(panelGridPos).toEqual(expectedGrid); }); - it('should add all rows if even one collapsed or titled row is present', function() { + it('should add all rows if even one collapsed or titled row is present', () => { model.rows = [createRow({ collapse: true, height: 8 }, [[6], [6]]), createRow({ height: 8 }, [[12]])]; const dashboard = new DashboardModel(model); const panelGridPos = getGridPositions(dashboard); @@ -225,7 +225,7 @@ describe('DashboardModel', function() { expect(panelGridPos).toEqual(expectedGrid); }); - it('should properly place panels with fixed height', function() { + it('should properly place panels with fixed height', () => { model.rows = [ createRow({ height: 6 }, [[6], [6, 3], [6, 3]]), createRow({ height: 6 }, [[4], [4], [4, 3], [4, 3]]), @@ -245,7 +245,7 @@ describe('DashboardModel', function() { expect(panelGridPos).toEqual(expectedGrid); }); - it('should place panel to the right side of panel having bigger height', function() { + it('should place panel to the right side of panel having bigger height', () => { model.rows = [createRow({ height: 6 }, [[4], [2, 3], [4, 6], [2, 3], [2, 3]])]; const dashboard = new DashboardModel(model); const panelGridPos = getGridPositions(dashboard); @@ -260,7 +260,7 @@ describe('DashboardModel', function() { expect(panelGridPos).toEqual(expectedGrid); }); - it('should fill current row if it possible', function() { + it('should fill current row if it possible', () => { model.rows = [createRow({ height: 9 }, [[4], [2, 3], [4, 6], [2, 3], [2, 3], [8, 3]])]; const dashboard = new DashboardModel(model); const panelGridPos = getGridPositions(dashboard); @@ -276,7 +276,7 @@ describe('DashboardModel', function() { expect(panelGridPos).toEqual(expectedGrid); }); - it('should fill current row if it possible (2)', function() { + it('should fill current row if it possible (2)', () => { model.rows = [createRow({ height: 8 }, [[4], [2, 3], [4, 6], [2, 3], [2, 3], [8, 3]])]; const dashboard = new DashboardModel(model); const panelGridPos = getGridPositions(dashboard); @@ -292,7 +292,7 @@ describe('DashboardModel', function() { expect(panelGridPos).toEqual(expectedGrid); }); - it('should fill current row if panel height more than row height', function() { + it('should fill current row if panel height more than row height', () => { model.rows = [createRow({ height: 6 }, [[4], [2, 3], [4, 8], [2, 3], [2, 3]])]; const dashboard = new DashboardModel(model); const panelGridPos = getGridPositions(dashboard); @@ -307,7 +307,7 @@ describe('DashboardModel', function() { expect(panelGridPos).toEqual(expectedGrid); }); - it('should wrap panels to multiple rows', function() { + it('should wrap panels to multiple rows', () => { model.rows = [createRow({ height: 6 }, [[6], [6], [12], [6], [3], [3]])]; const dashboard = new DashboardModel(model); const panelGridPos = getGridPositions(dashboard); @@ -323,7 +323,7 @@ describe('DashboardModel', function() { expect(panelGridPos).toEqual(expectedGrid); }); - it('should add repeated row if repeat set', function() { + it('should add repeated row if repeat set', () => { model.rows = [ createRow({ showTitle: true, title: 'Row', height: 8, repeat: 'server' }, [[6]]), createRow({ height: 8 }, [[12]]), @@ -344,7 +344,7 @@ describe('DashboardModel', function() { expect(dashboard.panels[3].repeat).toBeUndefined(); }); - it('should ignore repeated row', function() { + it('should ignore repeated row', () => { model.rows = [ createRow({ showTitle: true, title: 'Row1', height: 8, repeat: 'server' }, [[6]]), createRow( @@ -364,7 +364,7 @@ describe('DashboardModel', function() { expect(dashboard.panels.length).toBe(2); }); - it('minSpan should be twice', function() { + it('minSpan should be twice', () => { model.rows = [createRow({ height: 8 }, [[6]])]; model.rows[0].panels[0] = { minSpan: 12 }; @@ -372,7 +372,7 @@ describe('DashboardModel', function() { expect(dashboard.panels[0].minSpan).toBe(24); }); - it('should assign id', function() { + it('should assign id', () => { model.rows = [createRow({ collapse: true, height: 8 }, [[6], [6]])]; model.rows[0].panels[0] = {}; diff --git a/public/app/features/dashboard/specs/dashboard_model.test.ts b/public/app/features/dashboard/specs/dashboard_model.test.ts index 24d036a8233..e59d52f2410 100644 --- a/public/app/features/dashboard/specs/dashboard_model.test.ts +++ b/public/app/features/dashboard/specs/dashboard_model.test.ts @@ -4,43 +4,43 @@ import { PanelModel } from '../panel_model'; jest.mock('app/core/services/context_srv', () => ({})); -describe('DashboardModel', function() { - describe('when creating new dashboard model defaults only', function() { +describe('DashboardModel', () => { + describe('when creating new dashboard model defaults only', () => { let model; - beforeEach(function() { + beforeEach(() => { model = new DashboardModel({}, {}); }); - it('should have title', function() { + it('should have title', () => { expect(model.title).toBe('No Title'); }); - it('should have meta', function() { + it('should have meta', () => { expect(model.meta.canSave).toBe(true); expect(model.meta.canShare).toBe(true); }); - it('should have default properties', function() { + it('should have default properties', () => { expect(model.panels.length).toBe(0); }); }); - describe('when getting next panel id', function() { + describe('when getting next panel id', () => { let model; - beforeEach(function() { + beforeEach(() => { model = new DashboardModel({ panels: [{ id: 5 }], }); }); - it('should return max id + 1', function() { + it('should return max id + 1', () => { expect(model.getNextPanelId()).toBe(6); }); }); - describe('getSaveModelClone', function() { + describe('getSaveModelClone', () => { it('should sort keys', () => { const model = new DashboardModel({}); const saveModel = model.getSaveModelClone(); @@ -68,20 +68,20 @@ describe('DashboardModel', function() { }); }); - describe('row and panel manipulation', function() { + describe('row and panel manipulation', () => { let dashboard; - beforeEach(function() { + beforeEach(() => { dashboard = new DashboardModel({}); }); - it('adding panel should new up panel model', function() { + it('adding panel should new up panel model', () => { dashboard.addPanel({ type: 'test', title: 'test' }); expect(dashboard.panels[0] instanceof PanelModel).toBe(true); }); - it('duplicate panel should try to add to the right if there is space', function() { + it('duplicate panel should try to add to the right if there is space', () => { const panel = { id: 10, gridPos: { x: 0, y: 0, w: 6, h: 2 } }; dashboard.addPanel(panel); @@ -95,7 +95,7 @@ describe('DashboardModel', function() { }); }); - it('duplicate panel should remove repeat data', function() { + it('duplicate panel should remove repeat data', () => { const panel = { id: 10, gridPos: { x: 0, y: 0, w: 6, h: 2 }, @@ -111,29 +111,29 @@ describe('DashboardModel', function() { }); }); - describe('Given editable false dashboard', function() { + describe('Given editable false dashboard', () => { let model; - beforeEach(function() { + beforeEach(() => { model = new DashboardModel({ editable: false }); }); - it('Should set meta canEdit and canSave to false', function() { + it('Should set meta canEdit and canSave to false', () => { expect(model.meta.canSave).toBe(false); expect(model.meta.canEdit).toBe(false); }); - it('getSaveModelClone should remove meta', function() { + it('getSaveModelClone should remove meta', () => { const clone = model.getSaveModelClone(); expect(clone.meta).toBe(undefined); }); }); - describe('when loading dashboard with old influxdb query schema', function() { + describe('when loading dashboard with old influxdb query schema', () => { let model; let target; - beforeEach(function() { + beforeEach(() => { model = new DashboardModel({ panels: [ { @@ -185,7 +185,7 @@ describe('DashboardModel', function() { target = model.panels[0].targets[0]; }); - it('should update query schema', function() { + it('should update query schema', () => { expect(target.fields).toBe(undefined); expect(target.select.length).toBe(2); expect(target.select[0].length).toBe(4); @@ -196,10 +196,10 @@ describe('DashboardModel', function() { }); }); - describe('when creating dashboard model with missing list for annoations or templating', function() { + describe('when creating dashboard model with missing list for annoations or templating', () => { let model; - beforeEach(function() { + beforeEach(() => { model = new DashboardModel({ annotations: { enable: true, @@ -210,54 +210,54 @@ describe('DashboardModel', function() { }); }); - it('should add empty list', function() { + it('should add empty list', () => { expect(model.annotations.list.length).toBe(1); expect(model.templating.list.length).toBe(0); }); - it('should add builtin annotation query', function() { + it('should add builtin annotation query', () => { expect(model.annotations.list[0].builtIn).toBe(1); expect(model.templating.list.length).toBe(0); }); }); - describe('Formatting epoch timestamp when timezone is set as utc', function() { + describe('Formatting epoch timestamp when timezone is set as utc', () => { let dashboard; - beforeEach(function() { + beforeEach(() => { dashboard = new DashboardModel({ timezone: 'utc' }); }); - it('Should format timestamp with second resolution by default', function() { + it('Should format timestamp with second resolution by default', () => { expect(dashboard.formatDate(1234567890000)).toBe('2009-02-13 23:31:30'); }); - it('Should format timestamp with second resolution even if second format is passed as parameter', function() { + it('Should format timestamp with second resolution even if second format is passed as parameter', () => { expect(dashboard.formatDate(1234567890007, 'YYYY-MM-DD HH:mm:ss')).toBe('2009-02-13 23:31:30'); }); - it('Should format timestamp with millisecond resolution if format is passed as parameter', function() { + it('Should format timestamp with millisecond resolution if format is passed as parameter', () => { expect(dashboard.formatDate(1234567890007, 'YYYY-MM-DD HH:mm:ss.SSS')).toBe('2009-02-13 23:31:30.007'); }); }); - describe('updateSubmenuVisibility with empty lists', function() { + describe('updateSubmenuVisibility with empty lists', () => { let model; - beforeEach(function() { + beforeEach(() => { model = new DashboardModel({}); model.updateSubmenuVisibility(); }); - it('should not enable submmenu', function() { + it('should not enable submmenu', () => { expect(model.meta.submenuEnabled).toBe(false); }); }); - describe('updateSubmenuVisibility with annotation', function() { + describe('updateSubmenuVisibility with annotation', () => { let model; - beforeEach(function() { + beforeEach(() => { model = new DashboardModel({ annotations: { list: [{}], @@ -266,15 +266,15 @@ describe('DashboardModel', function() { model.updateSubmenuVisibility(); }); - it('should enable submmenu', function() { + it('should enable submmenu', () => { expect(model.meta.submenuEnabled).toBe(true); }); }); - describe('updateSubmenuVisibility with template var', function() { + describe('updateSubmenuVisibility with template var', () => { let model; - beforeEach(function() { + beforeEach(() => { model = new DashboardModel({ templating: { list: [{}], @@ -283,15 +283,15 @@ describe('DashboardModel', function() { model.updateSubmenuVisibility(); }); - it('should enable submmenu', function() { + it('should enable submmenu', () => { expect(model.meta.submenuEnabled).toBe(true); }); }); - describe('updateSubmenuVisibility with hidden template var', function() { + describe('updateSubmenuVisibility with hidden template var', () => { let model; - beforeEach(function() { + beforeEach(() => { model = new DashboardModel({ templating: { list: [{ hide: 2 }], @@ -300,15 +300,15 @@ describe('DashboardModel', function() { model.updateSubmenuVisibility(); }); - it('should not enable submmenu', function() { + it('should not enable submmenu', () => { expect(model.meta.submenuEnabled).toBe(false); }); }); - describe('updateSubmenuVisibility with hidden annotation toggle', function() { + describe('updateSubmenuVisibility with hidden annotation toggle', () => { let dashboard; - beforeEach(function() { + beforeEach(() => { dashboard = new DashboardModel({ annotations: { list: [{ hide: true }], @@ -317,15 +317,15 @@ describe('DashboardModel', function() { dashboard.updateSubmenuVisibility(); }); - it('should not enable submmenu', function() { + it('should not enable submmenu', () => { expect(dashboard.meta.submenuEnabled).toBe(false); }); }); - describe('When collapsing row', function() { + describe('When collapsing row', () => { let dashboard; - beforeEach(function() { + beforeEach(() => { dashboard = new DashboardModel({ panels: [ { id: 1, type: 'graph', gridPos: { x: 0, y: 0, w: 24, h: 2 } }, @@ -338,36 +338,36 @@ describe('DashboardModel', function() { dashboard.toggleRow(dashboard.panels[1]); }); - it('should remove panels and put them inside collapsed row', function() { + it('should remove panels and put them inside collapsed row', () => { expect(dashboard.panels.length).toBe(3); expect(dashboard.panels[1].panels.length).toBe(2); }); - describe('and when removing row and its panels', function() { - beforeEach(function() { + describe('and when removing row and its panels', () => { + beforeEach(() => { dashboard.removeRow(dashboard.panels[1], true); }); - it('should remove row and its panels', function() { + it('should remove row and its panels', () => { expect(dashboard.panels.length).toBe(2); }); }); - describe('and when removing only the row', function() { - beforeEach(function() { + describe('and when removing only the row', () => { + beforeEach(() => { dashboard.removeRow(dashboard.panels[1], false); }); - it('should only remove row', function() { + it('should only remove row', () => { expect(dashboard.panels.length).toBe(4); }); }); }); - describe('When expanding row', function() { + describe('When expanding row', () => { let dashboard; - beforeEach(function() { + beforeEach(() => { dashboard = new DashboardModel({ panels: [ { id: 1, type: 'graph', gridPos: { x: 0, y: 0, w: 24, h: 6 } }, @@ -387,16 +387,16 @@ describe('DashboardModel', function() { dashboard.toggleRow(dashboard.panels[1]); }); - it('should add panels back', function() { + it('should add panels back', () => { expect(dashboard.panels.length).toBe(5); }); - it('should add them below row in array', function() { + it('should add them below row in array', () => { expect(dashboard.panels[2].id).toBe(3); expect(dashboard.panels[3].id).toBe(4); }); - it('should position them below row', function() { + it('should position them below row', () => { expect(dashboard.panels[2].gridPos).toMatchObject({ x: 0, y: 7, @@ -405,7 +405,7 @@ describe('DashboardModel', function() { }); }); - it('should move panels below down', function() { + it('should move panels below down', () => { expect(dashboard.panels[4].gridPos).toMatchObject({ x: 0, y: 9, @@ -414,22 +414,22 @@ describe('DashboardModel', function() { }); }); - describe('and when removing row and its panels', function() { - beforeEach(function() { + describe('and when removing row and its panels', () => { + beforeEach(() => { dashboard.removeRow(dashboard.panels[1], true); }); - it('should remove row and its panels', function() { + it('should remove row and its panels', () => { expect(dashboard.panels.length).toBe(2); }); }); - describe('and when removing only the row', function() { - beforeEach(function() { + describe('and when removing only the row', () => { + beforeEach(() => { dashboard.removeRow(dashboard.panels[1], false); }); - it('should only remove row', function() { + it('should only remove row', () => { expect(dashboard.panels.length).toBe(4); }); }); diff --git a/public/app/features/dashboard/specs/history_srv.test.ts b/public/app/features/dashboard/specs/history_srv.test.ts index 5c8578ecf39..1e2bd57a221 100644 --- a/public/app/features/dashboard/specs/history_srv.test.ts +++ b/public/app/features/dashboard/specs/history_srv.test.ts @@ -4,7 +4,7 @@ import { HistorySrv } from '../history/history_srv'; import { DashboardModel } from '../dashboard_model'; jest.mock('app/core/store'); -describe('historySrv', function() { +describe('historySrv', () => { const versionsResponse = versions(); const restoreResponse = restore; @@ -19,35 +19,35 @@ describe('historySrv', function() { const emptyDash = new DashboardModel({}); const historyListOpts = { limit: 10, start: 0 }; - describe('getHistoryList', function() { - it('should return a versions array for the given dashboard id', function() { + describe('getHistoryList', () => { + it('should return a versions array for the given dashboard id', () => { backendSrv.get = jest.fn(() => Promise.resolve(versionsResponse)); historySrv = new HistorySrv(backendSrv); - return historySrv.getHistoryList(dash, historyListOpts).then(function(versions) { + return historySrv.getHistoryList(dash, historyListOpts).then(versions => { expect(versions).toEqual(versionsResponse); }); }); - it('should return an empty array when not given an id', function() { - return historySrv.getHistoryList(emptyDash, historyListOpts).then(function(versions) { + it('should return an empty array when not given an id', () => { + return historySrv.getHistoryList(emptyDash, historyListOpts).then(versions => { expect(versions).toEqual([]); }); }); - it('should return an empty array when not given a dashboard', function() { - return historySrv.getHistoryList(null, historyListOpts).then(function(versions) { + it('should return an empty array when not given a dashboard', () => { + return historySrv.getHistoryList(null, historyListOpts).then(versions => { expect(versions).toEqual([]); }); }); }); describe('restoreDashboard', () => { - it('should return a success response given valid parameters', function() { + it('should return a success response given valid parameters', () => { const version = 6; backendSrv.post = jest.fn(() => Promise.resolve(restoreResponse(version))); historySrv = new HistorySrv(backendSrv); - return historySrv.restoreDashboard(dash, version).then(function(response) { + return historySrv.restoreDashboard(dash, version).then(response => { expect(response).toEqual(restoreResponse(version)); }); }); diff --git a/public/app/features/dashboard/specs/repeat.test.ts b/public/app/features/dashboard/specs/repeat.test.ts index 47e3590ef9e..49fb4ea9ee7 100644 --- a/public/app/features/dashboard/specs/repeat.test.ts +++ b/public/app/features/dashboard/specs/repeat.test.ts @@ -4,10 +4,10 @@ import { expect } from 'test/lib/common'; jest.mock('app/core/services/context_srv', () => ({})); -describe('given dashboard with panel repeat', function() { +describe('given dashboard with panel repeat', () => { let dashboard; - beforeEach(function() { + beforeEach(() => { const dashboardJSON = { panels: [ { id: 1, type: 'row', gridPos: { x: 0, y: 0, h: 1, w: 24 } }, @@ -35,7 +35,7 @@ describe('given dashboard with panel repeat', function() { dashboard.processRepeats(); }); - it('should repeat panels when row is expanding', function() { + it('should repeat panels when row is expanding', () => { expect(dashboard.panels.length).toBe(4); // toggle row @@ -55,10 +55,10 @@ describe('given dashboard with panel repeat', function() { }); }); -describe('given dashboard with panel repeat in horizontal direction', function() { +describe('given dashboard with panel repeat in horizontal direction', () => { let dashboard; - beforeEach(function() { + beforeEach(() => { dashboard = new DashboardModel({ panels: [ { @@ -89,22 +89,22 @@ describe('given dashboard with panel repeat in horizontal direction', function() dashboard.processRepeats(); }); - it('should repeat panel 3 times', function() { + it('should repeat panel 3 times', () => { expect(dashboard.panels.length).toBe(3); }); - it('should mark panel repeated', function() { + it('should mark panel repeated', () => { expect(dashboard.panels[0].repeat).toBe('apps'); expect(dashboard.panels[1].repeatPanelId).toBe(2); }); - it('should set scopedVars on panels', function() { + it('should set scopedVars on panels', () => { expect(dashboard.panels[0].scopedVars.apps.value).toBe('se1'); expect(dashboard.panels[1].scopedVars.apps.value).toBe('se2'); expect(dashboard.panels[2].scopedVars.apps.value).toBe('se3'); }); - it('should place on first row and adjust width so all fit', function() { + it('should place on first row and adjust width so all fit', () => { expect(dashboard.panels[0].gridPos).toMatchObject({ x: 0, y: 0, @@ -125,23 +125,23 @@ describe('given dashboard with panel repeat in horizontal direction', function() }); }); - describe('After a second iteration', function() { - beforeEach(function() { + describe('After a second iteration', () => { + beforeEach(() => { dashboard.panels[0].fill = 10; dashboard.processRepeats(); }); - it('reused panel should copy properties from source', function() { + it('reused panel should copy properties from source', () => { expect(dashboard.panels[1].fill).toBe(10); }); - it('should have same panel count', function() { + it('should have same panel count', () => { expect(dashboard.panels.length).toBe(3); }); }); - describe('After a second iteration with different variable', function() { - beforeEach(function() { + describe('After a second iteration with different variable', () => { + beforeEach(() => { dashboard.templating.list.push({ name: 'server', current: { text: 'se1, se2, se3', value: ['se1'] }, @@ -151,46 +151,46 @@ describe('given dashboard with panel repeat in horizontal direction', function() dashboard.processRepeats(); }); - it('should remove scopedVars value for last variable', function() { + it('should remove scopedVars value for last variable', () => { expect(dashboard.panels[0].scopedVars.apps).toBe(undefined); }); - it('should have new variable value in scopedVars', function() { + it('should have new variable value in scopedVars', () => { expect(dashboard.panels[0].scopedVars.server.value).toBe('se1'); }); }); - describe('After a second iteration and selected values reduced', function() { - beforeEach(function() { + describe('After a second iteration and selected values reduced', () => { + beforeEach(() => { dashboard.templating.list[0].options[1].selected = false; dashboard.processRepeats(); }); - it('should clean up repeated panel', function() { + it('should clean up repeated panel', () => { expect(dashboard.panels.length).toBe(2); }); }); - describe('After a second iteration and panel repeat is turned off', function() { - beforeEach(function() { + describe('After a second iteration and panel repeat is turned off', () => { + beforeEach(() => { dashboard.panels[0].repeat = null; dashboard.processRepeats(); }); - it('should clean up repeated panel', function() { + it('should clean up repeated panel', () => { expect(dashboard.panels.length).toBe(1); }); - it('should remove scoped vars from reused panel', function() { + it('should remove scoped vars from reused panel', () => { expect(dashboard.panels[0].scopedVars).toBe(undefined); }); }); }); -describe('given dashboard with panel repeat in vertical direction', function() { +describe('given dashboard with panel repeat in vertical direction', () => { let dashboard; - beforeEach(function() { + beforeEach(() => { dashboard = new DashboardModel({ panels: [ { id: 1, type: 'row', gridPos: { x: 0, y: 0, h: 1, w: 24 } }, @@ -218,7 +218,7 @@ describe('given dashboard with panel repeat in vertical direction', function() { dashboard.processRepeats(); }); - it('should place on items on top of each other and keep witdh', function() { + it('should place on items on top of each other and keep witdh', () => { expect(dashboard.panels[0].gridPos).toMatchObject({ x: 0, y: 0, h: 1, w: 24 }); // first row expect(dashboard.panels[1].gridPos).toMatchObject({ x: 5, y: 1, h: 2, w: 8 }); @@ -290,7 +290,7 @@ describe('given dashboard with row repeat and panel repeat in horizontal directi ]); }); - it('should be placed in their places', function() { + it('should be placed in their places', () => { expect(dashboard.panels[0].gridPos).toMatchObject({ x: 0, y: 0, h: 1, w: 24 }); // 1st row expect(dashboard.panels[1].gridPos).toMatchObject({ x: 0, y: 1, h: 2, w: 6 }); @@ -311,10 +311,10 @@ describe('given dashboard with row repeat and panel repeat in horizontal directi }); }); -describe('given dashboard with row repeat', function() { +describe('given dashboard with row repeat', () => { let dashboard, dashboardJSON; - beforeEach(function() { + beforeEach(() => { dashboardJSON = { panels: [ { @@ -349,12 +349,12 @@ describe('given dashboard with row repeat', function() { dashboard.processRepeats(); }); - it('should not repeat only row', function() { + it('should not repeat only row', () => { const panelTypes = _.map(dashboard.panels, 'type'); expect(panelTypes).toEqual(['row', 'graph', 'graph', 'row', 'graph', 'graph', 'row', 'graph']); }); - it('should set scopedVars for each panel', function() { + it('should set scopedVars for each panel', () => { dashboardJSON.templating.list[0].options[2].selected = true; dashboard = new DashboardModel(dashboardJSON); dashboard.processRepeats(); @@ -375,12 +375,12 @@ describe('given dashboard with row repeat', function() { expect(scopedVars).toEqual(['se1', 'se1', 'se1', 'se2', 'se2', 'se2', 'se3', 'se3', 'se3']); }); - it('should repeat only configured row', function() { + it('should repeat only configured row', () => { expect(dashboard.panels[6].id).toBe(4); expect(dashboard.panels[7].id).toBe(5); }); - it('should repeat only row if it is collapsed', function() { + it('should repeat only row if it is collapsed', () => { dashboardJSON.panels = [ { id: 1, @@ -405,7 +405,7 @@ describe('given dashboard with row repeat', function() { expect(dashboard.panels[1].panels).toHaveLength(2); }); - it('should properly repeat multiple rows', function() { + it('should properly repeat multiple rows', () => { dashboardJSON.panels = [ { id: 1, @@ -469,7 +469,7 @@ describe('given dashboard with row repeat', function() { expect(dashboard.panels[12].scopedVars['hosts'].value).toBe('backend02'); }); - it('should assign unique ids for repeated panels', function() { + it('should assign unique ids for repeated panels', () => { dashboardJSON.panels = [ { id: 1, @@ -501,7 +501,7 @@ describe('given dashboard with row repeat', function() { expect(panelIds.length).toEqual(_.uniq(panelIds).length); }); - it('should place new panels in proper order', function() { + it('should place new panels in proper order', () => { dashboardJSON.panels = [ { id: 1, type: 'row', gridPos: { x: 0, y: 0, h: 1, w: 24 }, repeat: 'apps' }, { id: 2, type: 'graph', gridPos: { x: 0, y: 1, h: 3, w: 12 } }, @@ -646,7 +646,7 @@ describe('given dashboard with row and panel repeat', () => { }); }); - it('should repeat panels when row is expanding', function() { + it('should repeat panels when row is expanding', () => { dashboard = new DashboardModel(dashboardJSON); dashboard.processRepeats(); diff --git a/public/app/features/dashboard/specs/save_as_modal.test.ts b/public/app/features/dashboard/specs/save_as_modal.test.ts index 29ed694474b..ceb7e49c550 100644 --- a/public/app/features/dashboard/specs/save_as_modal.test.ts +++ b/public/app/features/dashboard/specs/save_as_modal.test.ts @@ -10,11 +10,11 @@ describe('saving dashboard as', () => { }; const mockDashboardSrv = { - getCurrent: function() { + getCurrent: () => { return { id: 5, meta: {}, - getSaveModelClone: function() { + getSaveModelClone: () => { return json; }, }; diff --git a/public/app/features/dashboard/specs/save_provisioned_modal.test.ts b/public/app/features/dashboard/specs/save_provisioned_modal.test.ts index fb1a652a03c..a3ab27a984f 100644 --- a/public/app/features/dashboard/specs/save_provisioned_modal.test.ts +++ b/public/app/features/dashboard/specs/save_provisioned_modal.test.ts @@ -7,11 +7,11 @@ describe('SaveProvisionedDashboardModalCtrl', () => { }; const mockDashboardSrv = { - getCurrent: function() { + getCurrent: () => { return { id: 5, meta: {}, - getSaveModelClone: function() { + getSaveModelClone: () => { return json; }, }; diff --git a/public/app/features/dashboard/specs/share_modal_ctrl.test.ts b/public/app/features/dashboard/specs/share_modal_ctrl.test.ts index 6effc504861..8a8d94fdddb 100644 --- a/public/app/features/dashboard/specs/share_modal_ctrl.test.ts +++ b/public/app/features/dashboard/specs/share_modal_ctrl.test.ts @@ -136,7 +136,7 @@ describe('ShareModalCtrl', () => { ctx.$location.absUrl = () => 'http://server/#!/test'; ctx.scope.options.includeTemplateVars = true; - ctx.templateSrv.fillVariableValuesForUrl = function(params) { + ctx.templateSrv.fillVariableValuesForUrl = params => { params['var-app'] = 'mupp'; params['var-server'] = 'srv-01'; }; diff --git a/public/app/features/dashboard/specs/time_srv.test.ts b/public/app/features/dashboard/specs/time_srv.test.ts index 046ac52c9bf..514e0b90792 100644 --- a/public/app/features/dashboard/specs/time_srv.test.ts +++ b/public/app/features/dashboard/specs/time_srv.test.ts @@ -2,7 +2,7 @@ import { TimeSrv } from '../time_srv'; import '../time_srv'; import moment from 'moment'; -describe('timeSrv', function() { +describe('timeSrv', () => { const rootScope = { $on: jest.fn(), onAppEvent: jest.fn(), @@ -26,20 +26,20 @@ describe('timeSrv', function() { getTimezone: jest.fn(() => 'browser'), }; - beforeEach(function() { + beforeEach(() => { timeSrv = new TimeSrv(rootScope, jest.fn(), location, timer, { isGrafanaVisibile: jest.fn() }); timeSrv.init(_dashboard); }); - describe('timeRange', function() { - it('should return unparsed when parse is false', function() { + describe('timeRange', () => { + it('should return unparsed when parse is false', () => { timeSrv.setTime({ from: 'now', to: 'now-1h' }); const time = timeSrv.timeRange(); expect(time.raw.from).toBe('now'); expect(time.raw.to).toBe('now-1h'); }); - it('should return parsed when parse is true', function() { + it('should return parsed when parse is true', () => { timeSrv.setTime({ from: 'now', to: 'now-1h' }); const time = timeSrv.timeRange(); expect(moment.isMoment(time.from)).toBe(true); @@ -47,8 +47,8 @@ describe('timeSrv', function() { }); }); - describe('init time from url', function() { - it('should handle relative times', function() { + describe('init time from url', () => { + it('should handle relative times', () => { location = { search: jest.fn(() => ({ from: 'now-2d', @@ -63,7 +63,7 @@ describe('timeSrv', function() { expect(time.raw.to).toBe('now'); }); - it('should handle formatted dates', function() { + it('should handle formatted dates', () => { location = { search: jest.fn(() => ({ from: '20140410T052010', @@ -79,7 +79,7 @@ describe('timeSrv', function() { expect(time.to.valueOf()).toEqual(new Date('2014-05-20T03:10:22Z').getTime()); }); - it('should handle formatted dates without time', function() { + it('should handle formatted dates without time', () => { location = { search: jest.fn(() => ({ from: '20140410', @@ -95,7 +95,7 @@ describe('timeSrv', function() { expect(time.to.valueOf()).toEqual(new Date('2014-05-20T00:00:00Z').getTime()); }); - it('should handle epochs', function() { + it('should handle epochs', () => { location = { search: jest.fn(() => ({ from: '1410337646373', @@ -111,7 +111,7 @@ describe('timeSrv', function() { expect(time.to.valueOf()).toEqual(1410337665699); }); - it('should handle bad dates', function() { + it('should handle bad dates', () => { location = { search: jest.fn(() => ({ from: '20151126T00010%3C%2Fp%3E%3Cspan%20class', @@ -128,22 +128,22 @@ describe('timeSrv', function() { }); }); - describe('setTime', function() { - it('should return disable refresh if refresh is disabled for any range', function() { + describe('setTime', () => { + it('should return disable refresh if refresh is disabled for any range', () => { _dashboard.refresh = false; timeSrv.setTime({ from: '2011-01-01', to: '2015-01-01' }); expect(_dashboard.refresh).toBe(false); }); - it('should restore refresh for absolute time range', function() { + it('should restore refresh for absolute time range', () => { _dashboard.refresh = '30s'; timeSrv.setTime({ from: '2011-01-01', to: '2015-01-01' }); expect(_dashboard.refresh).toBe('30s'); }); - it('should restore refresh after relative time range is set', function() { + it('should restore refresh after relative time range is set', () => { _dashboard.refresh = '10s'; timeSrv.setTime({ from: moment([2011, 1, 1]), @@ -154,7 +154,7 @@ describe('timeSrv', function() { expect(_dashboard.refresh).toBe('10s'); }); - it('should keep refresh after relative time range is changed and now delay exists', function() { + it('should keep refresh after relative time range is changed and now delay exists', () => { _dashboard.refresh = '10s'; timeSrv.setTime({ from: 'now-1h', to: 'now-10s' }); expect(_dashboard.refresh).toBe('10s'); diff --git a/public/app/features/org/org_details_ctrl.ts b/public/app/features/org/org_details_ctrl.ts index 2ec1b57e170..1d4a92c6e8b 100644 --- a/public/app/features/org/org_details_ctrl.ts +++ b/public/app/features/org/org_details_ctrl.ts @@ -3,20 +3,20 @@ import angular from 'angular'; export class OrgDetailsCtrl { /** @ngInject */ constructor($scope, $http, backendSrv, contextSrv, navModelSrv) { - $scope.init = function() { + $scope.init = () => { $scope.getOrgInfo(); $scope.navModel = navModelSrv.getNav('cfg', 'org-settings', 0); }; - $scope.getOrgInfo = function() { - backendSrv.get('/api/org').then(function(org) { + $scope.getOrgInfo = () => { + backendSrv.get('/api/org').then(org => { $scope.org = org; $scope.address = org.address; contextSrv.user.orgName = org.name; }); }; - $scope.update = function() { + $scope.update = () => { if (!$scope.orgForm.$valid) { return; } @@ -24,7 +24,7 @@ export class OrgDetailsCtrl { backendSrv.put('/api/org', data).then($scope.getOrgInfo); }; - $scope.updateAddress = function() { + $scope.updateAddress = () => { if (!$scope.addressForm.$valid) { return; } diff --git a/public/app/features/panellinks/specs/link_srv.test.ts b/public/app/features/panellinks/specs/link_srv.test.ts index 9c6b62d4b69..e83c58f0d7c 100644 --- a/public/app/features/panellinks/specs/link_srv.test.ts +++ b/public/app/features/panellinks/specs/link_srv.test.ts @@ -6,7 +6,7 @@ jest.mock('angular', () => { return new AngularJSMock(); }); -describe('linkSrv', function() { +describe('linkSrv', () => { let linkSrv; const templateSrvMock = {}; const timeSrvMock = {}; @@ -15,24 +15,24 @@ describe('linkSrv', function() { linkSrv = new LinkSrv(templateSrvMock, timeSrvMock); }); - describe('when appending query strings', function() { - it('add ? to URL if not present', function() { + describe('when appending query strings', () => { + it('add ? to URL if not present', () => { const url = linkSrv.appendToQueryString('http://example.com', 'foo=bar'); expect(url).toBe('http://example.com?foo=bar'); }); - it('do not add & to URL if ? is present but query string is empty', function() { + it('do not add & to URL if ? is present but query string is empty', () => { const url = linkSrv.appendToQueryString('http://example.com?', 'foo=bar'); expect(url).toBe('http://example.com?foo=bar'); }); - it('add & to URL if query string is present', function() { + it('add & to URL if query string is present', () => { const url = linkSrv.appendToQueryString('http://example.com?foo=bar', 'hello=world'); expect(url).toBe('http://example.com?foo=bar&hello=world'); }); - it('do not change the URL if there is nothing to append', function() { - _.each(['', undefined, null], function(toAppend) { + it('do not change the URL if there is nothing to append', () => { + _.each(['', undefined, null], toAppend => { const url1 = linkSrv.appendToQueryString('http://example.com', toAppend); expect(url1).toBe('http://example.com'); diff --git a/public/app/features/plugins/specs/datasource_srv.test.ts b/public/app/features/plugins/specs/datasource_srv.test.ts index 653e431cb9f..a8d0807c765 100644 --- a/public/app/features/plugins/specs/datasource_srv.test.ts +++ b/public/app/features/plugins/specs/datasource_srv.test.ts @@ -15,7 +15,7 @@ const templateSrv = { ], }; -describe('datasource_srv', function() { +describe('datasource_srv', () => { const _datasourceSrv = new DatasourceSrv({}, {}, {}, templateSrv); describe('when loading explore sources', () => { diff --git a/public/app/features/templating/specs/adhoc_variable.test.ts b/public/app/features/templating/specs/adhoc_variable.test.ts index f85c49e73d5..6d15ce8362c 100644 --- a/public/app/features/templating/specs/adhoc_variable.test.ts +++ b/public/app/features/templating/specs/adhoc_variable.test.ts @@ -1,8 +1,8 @@ import { AdhocVariable } from '../adhoc_variable'; -describe('AdhocVariable', function() { - describe('when serializing to url', function() { - it('should set return key value and op separated by pipe', function() { +describe('AdhocVariable', () => { + describe('when serializing to url', () => { + it('should set return key value and op separated by pipe', () => { const variable = new AdhocVariable({ filters: [ { key: 'key1', operator: '=', value: 'value1' }, @@ -15,8 +15,8 @@ describe('AdhocVariable', function() { }); }); - describe('when deserializing from url', function() { - it('should restore filters', function() { + describe('when deserializing from url', () => { + it('should restore filters', () => { const variable = new AdhocVariable({}); variable.setValueFromUrl(['key1|=|value1', 'key2|!=|value2', 'key3|=|value3a__gfp__value3b__gfp__value3c']); diff --git a/public/app/features/templating/specs/template_srv.test.ts b/public/app/features/templating/specs/template_srv.test.ts index 984d62cb729..7f5ff959216 100644 --- a/public/app/features/templating/specs/template_srv.test.ts +++ b/public/app/features/templating/specs/template_srv.test.ts @@ -1,6 +1,6 @@ import { TemplateSrv } from '../template_srv'; -describe('templateSrv', function() { +describe('templateSrv', () => { let _templateSrv; function initTemplateSrv(variables) { @@ -8,58 +8,58 @@ describe('templateSrv', function() { _templateSrv.init(variables); } - describe('init', function() { - beforeEach(function() { + describe('init', () => { + beforeEach(() => { initTemplateSrv([{ type: 'query', name: 'test', current: { value: 'oogle' } }]); }); - it('should initialize template data', function() { + it('should initialize template data', () => { const target = _templateSrv.replace('this.[[test]].filters'); expect(target).toBe('this.oogle.filters'); }); }); - describe('replace can pass scoped vars', function() { - beforeEach(function() { + describe('replace can pass scoped vars', () => { + beforeEach(() => { initTemplateSrv([{ type: 'query', name: 'test', current: { value: 'oogle' } }]); }); - it('should replace $test with scoped value', function() { + it('should replace $test with scoped value', () => { const target = _templateSrv.replace('this.$test.filters', { test: { value: 'mupp', text: 'asd' }, }); expect(target).toBe('this.mupp.filters'); }); - it('should replace ${test} with scoped value', function() { + it('should replace ${test} with scoped value', () => { const target = _templateSrv.replace('this.${test}.filters', { test: { value: 'mupp', text: 'asd' }, }); expect(target).toBe('this.mupp.filters'); }); - it('should replace ${test:glob} with scoped value', function() { + it('should replace ${test:glob} with scoped value', () => { const target = _templateSrv.replace('this.${test:glob}.filters', { test: { value: 'mupp', text: 'asd' }, }); expect(target).toBe('this.mupp.filters'); }); - it('should replace $test with scoped text', function() { + it('should replace $test with scoped text', () => { const target = _templateSrv.replaceWithText('this.$test.filters', { test: { value: 'mupp', text: 'asd' }, }); expect(target).toBe('this.asd.filters'); }); - it('should replace ${test} with scoped text', function() { + it('should replace ${test} with scoped text', () => { const target = _templateSrv.replaceWithText('this.${test}.filters', { test: { value: 'mupp', text: 'asd' }, }); expect(target).toBe('this.asd.filters'); }); - it('should replace ${test:glob} with scoped text', function() { + it('should replace ${test:glob} with scoped text', () => { const target = _templateSrv.replaceWithText('this.${test:glob}.filters', { test: { value: 'mupp', text: 'asd' }, }); @@ -67,8 +67,8 @@ describe('templateSrv', function() { }); }); - describe('getAdhocFilters', function() { - beforeEach(function() { + describe('getAdhocFilters', () => { + beforeEach(() => { initTemplateSrv([ { type: 'datasource', @@ -80,24 +80,24 @@ describe('templateSrv', function() { ]); }); - it('should return filters if datasourceName match', function() { + it('should return filters if datasourceName match', () => { const filters = _templateSrv.getAdhocFilters('oogle'); expect(filters).toMatchObject([1]); }); - it('should return empty array if datasourceName does not match', function() { + it('should return empty array if datasourceName does not match', () => { const filters = _templateSrv.getAdhocFilters('oogleasdasd'); expect(filters).toMatchObject([]); }); - it('should return filters when datasourceName match via data source variable', function() { + it('should return filters when datasourceName match via data source variable', () => { const filters = _templateSrv.getAdhocFilters('logstash'); expect(filters).toMatchObject([2]); }); }); - describe('replace can pass multi / all format', function() { - beforeEach(function() { + describe('replace can pass multi / all format', () => { + beforeEach(() => { initTemplateSrv([ { type: 'query', @@ -107,44 +107,44 @@ describe('templateSrv', function() { ]); }); - it('should replace $test with globbed value', function() { + it('should replace $test with globbed value', () => { const target = _templateSrv.replace('this.$test.filters', {}, 'glob'); expect(target).toBe('this.{value1,value2}.filters'); }); - it('should replace ${test} with globbed value', function() { + it('should replace ${test} with globbed value', () => { const target = _templateSrv.replace('this.${test}.filters', {}, 'glob'); expect(target).toBe('this.{value1,value2}.filters'); }); - it('should replace ${test:glob} with globbed value', function() { + it('should replace ${test:glob} with globbed value', () => { const target = _templateSrv.replace('this.${test:glob}.filters', {}); expect(target).toBe('this.{value1,value2}.filters'); }); - it('should replace $test with piped value', function() { + it('should replace $test with piped value', () => { const target = _templateSrv.replace('this=$test', {}, 'pipe'); expect(target).toBe('this=value1|value2'); }); - it('should replace ${test} with piped value', function() { + it('should replace ${test} with piped value', () => { const target = _templateSrv.replace('this=${test}', {}, 'pipe'); expect(target).toBe('this=value1|value2'); }); - it('should replace ${test:pipe} with piped value', function() { + it('should replace ${test:pipe} with piped value', () => { const target = _templateSrv.replace('this=${test:pipe}', {}); expect(target).toBe('this=value1|value2'); }); - it('should replace ${test:pipe} with piped value and $test with globbed value', function() { + it('should replace ${test:pipe} with piped value and $test with globbed value', () => { const target = _templateSrv.replace('${test:pipe},$test', {}, 'glob'); expect(target).toBe('value1|value2,{value1,value2}'); }); }); - describe('variable with all option', function() { - beforeEach(function() { + describe('variable with all option', () => { + beforeEach(() => { initTemplateSrv([ { type: 'query', @@ -155,29 +155,29 @@ describe('templateSrv', function() { ]); }); - it('should replace $test with formatted all value', function() { + it('should replace $test with formatted all value', () => { const target = _templateSrv.replace('this.$test.filters', {}, 'glob'); expect(target).toBe('this.{value1,value2}.filters'); }); - it('should replace ${test} with formatted all value', function() { + it('should replace ${test} with formatted all value', () => { const target = _templateSrv.replace('this.${test}.filters', {}, 'glob'); expect(target).toBe('this.{value1,value2}.filters'); }); - it('should replace ${test:glob} with formatted all value', function() { + it('should replace ${test:glob} with formatted all value', () => { const target = _templateSrv.replace('this.${test:glob}.filters', {}); expect(target).toBe('this.{value1,value2}.filters'); }); - it('should replace ${test:pipe} with piped value and $test with globbed value', function() { + it('should replace ${test:pipe} with piped value and $test with globbed value', () => { const target = _templateSrv.replace('${test:pipe},$test', {}, 'glob'); expect(target).toBe('value1|value2,{value1,value2}'); }); }); - describe('variable with all option and custom value', function() { - beforeEach(function() { + describe('variable with all option and custom value', () => { + beforeEach(() => { initTemplateSrv([ { type: 'query', @@ -189,143 +189,143 @@ describe('templateSrv', function() { ]); }); - it('should replace $test with formatted all value', function() { + it('should replace $test with formatted all value', () => { const target = _templateSrv.replace('this.$test.filters', {}, 'glob'); expect(target).toBe('this.*.filters'); }); - it('should replace ${test} with formatted all value', function() { + it('should replace ${test} with formatted all value', () => { const target = _templateSrv.replace('this.${test}.filters', {}, 'glob'); expect(target).toBe('this.*.filters'); }); - it('should replace ${test:glob} with formatted all value', function() { + it('should replace ${test:glob} with formatted all value', () => { const target = _templateSrv.replace('this.${test:glob}.filters', {}); expect(target).toBe('this.*.filters'); }); - it('should not escape custom all value', function() { + it('should not escape custom all value', () => { const target = _templateSrv.replace('this.$test', {}, 'regex'); expect(target).toBe('this.*'); }); }); - describe('lucene format', function() { - it('should properly escape $test with lucene escape sequences', function() { + describe('lucene format', () => { + it('should properly escape $test with lucene escape sequences', () => { initTemplateSrv([{ type: 'query', name: 'test', current: { value: 'value/4' } }]); const target = _templateSrv.replace('this:$test', {}, 'lucene'); expect(target).toBe('this:value\\/4'); }); - it('should properly escape ${test} with lucene escape sequences', function() { + it('should properly escape ${test} with lucene escape sequences', () => { initTemplateSrv([{ type: 'query', name: 'test', current: { value: 'value/4' } }]); const target = _templateSrv.replace('this:${test}', {}, 'lucene'); expect(target).toBe('this:value\\/4'); }); - it('should properly escape ${test:lucene} with lucene escape sequences', function() { + it('should properly escape ${test:lucene} with lucene escape sequences', () => { initTemplateSrv([{ type: 'query', name: 'test', current: { value: 'value/4' } }]); const target = _templateSrv.replace('this:${test:lucene}', {}); expect(target).toBe('this:value\\/4'); }); }); - describe('format variable to string values', function() { - it('single value should return value', function() { + describe('format variable to string values', () => { + it('single value should return value', () => { const result = _templateSrv.formatValue('test'); expect(result).toBe('test'); }); - it('multi value and glob format should render glob string', function() { + it('multi value and glob format should render glob string', () => { const result = _templateSrv.formatValue(['test', 'test2'], 'glob'); expect(result).toBe('{test,test2}'); }); - it('multi value and lucene should render as lucene expr', function() { + it('multi value and lucene should render as lucene expr', () => { const result = _templateSrv.formatValue(['test', 'test2'], 'lucene'); expect(result).toBe('("test" OR "test2")'); }); - it('multi value and regex format should render regex string', function() { + it('multi value and regex format should render regex string', () => { const result = _templateSrv.formatValue(['test.', 'test2'], 'regex'); expect(result).toBe('(test\\.|test2)'); }); - it('multi value and pipe should render pipe string', function() { + it('multi value and pipe should render pipe string', () => { const result = _templateSrv.formatValue(['test', 'test2'], 'pipe'); expect(result).toBe('test|test2'); }); - it('multi value and distributed should render distributed string', function() { + it('multi value and distributed should render distributed string', () => { const result = _templateSrv.formatValue(['test', 'test2'], 'distributed', { name: 'build', }); expect(result).toBe('test,build=test2'); }); - it('multi value and distributed should render when not string', function() { + it('multi value and distributed should render when not string', () => { const result = _templateSrv.formatValue(['test'], 'distributed', { name: 'build', }); expect(result).toBe('test'); }); - it('multi value and csv format should render csv string', function() { + it('multi value and csv format should render csv string', () => { const result = _templateSrv.formatValue(['test', 'test2'], 'csv'); expect(result).toBe('test,test2'); }); - it('slash should be properly escaped in regex format', function() { + it('slash should be properly escaped in regex format', () => { const result = _templateSrv.formatValue('Gi3/14', 'regex'); expect(result).toBe('Gi3\\/14'); }); }); - describe('can check if variable exists', function() { - beforeEach(function() { + describe('can check if variable exists', () => { + beforeEach(() => { initTemplateSrv([{ type: 'query', name: 'test', current: { value: 'oogle' } }]); }); - it('should return true if exists', function() { + it('should return true if exists', () => { const result = _templateSrv.variableExists('$test'); expect(result).toBe(true); }); }); - describe('can highlight variables in string', function() { - beforeEach(function() { + describe('can highlight variables in string', () => { + beforeEach(() => { initTemplateSrv([{ type: 'query', name: 'test', current: { value: 'oogle' } }]); }); - it('should insert html', function() { + it('should insert html', () => { const result = _templateSrv.highlightVariablesAsHtml('$test'); expect(result).toBe('$test'); }); - it('should insert html anywhere in string', function() { + it('should insert html anywhere in string', () => { const result = _templateSrv.highlightVariablesAsHtml('this $test ok'); expect(result).toBe('this $test ok'); }); - it('should ignore if variables does not exist', function() { + it('should ignore if variables does not exist', () => { const result = _templateSrv.highlightVariablesAsHtml('this $google ok'); expect(result).toBe('this $google ok'); }); }); - describe('updateTemplateData with simple value', function() { - beforeEach(function() { + describe('updateTemplateData with simple value', () => { + beforeEach(() => { initTemplateSrv([{ type: 'query', name: 'test', current: { value: 'muuuu' } }]); }); - it('should set current value and update template data', function() { + it('should set current value and update template data', () => { const target = _templateSrv.replace('this.[[test]].filters'); expect(target).toBe('this.muuuu.filters'); }); }); - describe('fillVariableValuesForUrl with multi value', function() { - beforeEach(function() { + describe('fillVariableValuesForUrl with multi value', () => { + beforeEach(() => { initTemplateSrv([ { type: 'query', @@ -338,15 +338,15 @@ describe('templateSrv', function() { ]); }); - it('should set multiple url params', function() { + it('should set multiple url params', () => { const params = {}; _templateSrv.fillVariableValuesForUrl(params); expect(params['var-test']).toMatchObject(['val1', 'val2']); }); }); - describe('fillVariableValuesForUrl skip url sync', function() { - beforeEach(function() { + describe('fillVariableValuesForUrl skip url sync', () => { + beforeEach(() => { initTemplateSrv([ { name: 'test', @@ -359,15 +359,15 @@ describe('templateSrv', function() { ]); }); - it('should not include template variable value in url', function() { + it('should not include template variable value in url', () => { const params = {}; _templateSrv.fillVariableValuesForUrl(params); expect(params['var-test']).toBe(undefined); }); }); - describe('fillVariableValuesForUrl with multi value with skip url sync', function() { - beforeEach(function() { + describe('fillVariableValuesForUrl with multi value with skip url sync', () => { + beforeEach(() => { initTemplateSrv([ { type: 'query', @@ -381,19 +381,19 @@ describe('templateSrv', function() { ]); }); - it('should not include template variable value in url', function() { + it('should not include template variable value in url', () => { const params = {}; _templateSrv.fillVariableValuesForUrl(params); expect(params['var-test']).toBe(undefined); }); }); - describe('fillVariableValuesForUrl with multi value and scopedVars', function() { - beforeEach(function() { + describe('fillVariableValuesForUrl with multi value and scopedVars', () => { + beforeEach(() => { initTemplateSrv([{ type: 'query', name: 'test', current: { value: ['val1', 'val2'] } }]); }); - it('should set scoped value as url params', function() { + it('should set scoped value as url params', () => { const params = {}; _templateSrv.fillVariableValuesForUrl(params, { test: { value: 'val1' }, @@ -402,12 +402,12 @@ describe('templateSrv', function() { }); }); - describe('fillVariableValuesForUrl with multi value, scopedVars and skip url sync', function() { - beforeEach(function() { + describe('fillVariableValuesForUrl with multi value, scopedVars and skip url sync', () => { + beforeEach(() => { initTemplateSrv([{ type: 'query', name: 'test', current: { value: ['val1', 'val2'] } }]); }); - it('should not set scoped value as url params', function() { + it('should not set scoped value as url params', () => { const params = {}; _templateSrv.fillVariableValuesForUrl(params, { test: { name: 'test', value: 'val1', skipUrlSync: true }, @@ -416,8 +416,8 @@ describe('templateSrv', function() { }); }); - describe('replaceWithText', function() { - beforeEach(function() { + describe('replaceWithText', () => { + beforeEach(() => { initTemplateSrv([ { type: 'query', @@ -434,18 +434,18 @@ describe('templateSrv', function() { _templateSrv.updateTemplateData(); }); - it('should replace with text except for grafanaVariables', function() { + it('should replace with text except for grafanaVariables', () => { const target = _templateSrv.replaceWithText('Server: $server, period: $period'); expect(target).toBe('Server: All, period: 13m'); }); }); - describe('built in interval variables', function() { - beforeEach(function() { + describe('built in interval variables', () => { + beforeEach(() => { initTemplateSrv([]); }); - it('should replace $__interval_ms with interval milliseconds', function() { + it('should replace $__interval_ms with interval milliseconds', () => { const target = _templateSrv.replace('10 * $__interval_ms', { __interval_ms: { text: '100', value: '100' }, }); diff --git a/public/app/features/templating/specs/variable.test.ts b/public/app/features/templating/specs/variable.test.ts index 814c5fbe003..6d5e88fa4bd 100644 --- a/public/app/features/templating/specs/variable.test.ts +++ b/public/app/features/templating/specs/variable.test.ts @@ -1,53 +1,53 @@ import { containsVariable, assignModelProperties } from '../variable'; -describe('containsVariable', function() { - describe('when checking if a string contains a variable', function() { - it('should find it with $const syntax', function() { +describe('containsVariable', () => { + describe('when checking if a string contains a variable', () => { + it('should find it with $const syntax', () => { const contains = containsVariable('this.$test.filters', 'test'); expect(contains).toBe(true); }); - it('should not find it if only part matches with $const syntax', function() { + it('should not find it if only part matches with $const syntax', () => { const contains = containsVariable('this.$serverDomain.filters', 'server'); expect(contains).toBe(false); }); - it('should find it if it ends with variable and passing multiple test strings', function() { + it('should find it if it ends with variable and passing multiple test strings', () => { const contains = containsVariable('show field keys from $pgmetric', 'test string2', 'pgmetric'); expect(contains).toBe(true); }); - it('should find it with [[var]] syntax', function() { + it('should find it with [[var]] syntax', () => { const contains = containsVariable('this.[[test]].filters', 'test'); expect(contains).toBe(true); }); - it('should find it when part of segment', function() { + it('should find it when part of segment', () => { const contains = containsVariable('metrics.$env.$group-*', 'group'); expect(contains).toBe(true); }); - it('should find it its the only thing', function() { + it('should find it its the only thing', () => { const contains = containsVariable('$env', 'env'); expect(contains).toBe(true); }); - it('should be able to pass in multiple test strings', function() { + it('should be able to pass in multiple test strings', () => { const contains = containsVariable('asd', 'asd2.$env', 'env'); expect(contains).toBe(true); }); }); }); -describe('assignModelProperties', function() { - it('only set properties defined in defaults', function() { +describe('assignModelProperties', () => { + it('only set properties defined in defaults', () => { const target: any = { test: 'asd' }; assignModelProperties(target, { propA: 1, propB: 2 }, { propB: 0 }); expect(target.propB).toBe(2); expect(target.test).toBe('asd'); }); - it('use default value if not found on source', function() { + it('use default value if not found on source', () => { const target: any = { test: 'asd' }; assignModelProperties(target, { propA: 1, propB: 2 }, { propC: 10 }); expect(target.propC).toBe(10); diff --git a/public/app/features/templating/specs/variable_srv.test.ts b/public/app/features/templating/specs/variable_srv.test.ts index 06317ee1b3a..359d5b79a38 100644 --- a/public/app/features/templating/specs/variable_srv.test.ts +++ b/public/app/features/templating/specs/variable_srv.test.ts @@ -34,7 +34,7 @@ describe('VariableSrv', function(this: any) { function describeUpdateVariable(desc, fn) { describe(desc, () => { const scenario: any = {}; - scenario.setup = function(setupFn) { + scenario.setup = setupFn => { scenario.setupFn = setupFn; }; @@ -135,7 +135,7 @@ describe('VariableSrv', function(this: any) { // // Query variable update // - describeUpdateVariable('query variable with empty current object and refresh', function(scenario) { + describeUpdateVariable('query variable with empty current object and refresh', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', @@ -154,7 +154,7 @@ describe('VariableSrv', function(this: any) { describeUpdateVariable( 'query variable with multi select and new options does not contain some selected values', - function(scenario) { + scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', @@ -177,7 +177,7 @@ describe('VariableSrv', function(this: any) { describeUpdateVariable( 'query variable with multi select and new options does not contain any selected values', - function(scenario) { + scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', @@ -198,7 +198,7 @@ describe('VariableSrv', function(this: any) { } ); - describeUpdateVariable('query variable with multi select and $__all selected', function(scenario) { + describeUpdateVariable('query variable with multi select and $__all selected', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', @@ -219,7 +219,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('query variable with numeric results', function(scenario) { + describeUpdateVariable('query variable with numeric results', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', @@ -237,7 +237,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('basic query variable', function(scenario) { + describeUpdateVariable('basic query variable', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', query: 'apps.*', name: 'test' }; scenario.queryResult = [{ text: 'backend1' }, { text: 'backend2' }]; @@ -255,7 +255,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('and existing value still exists in options', function(scenario) { + describeUpdateVariable('and existing value still exists in options', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', query: 'apps.*', name: 'test' }; scenario.variableModel.current = { value: 'backend2', text: 'backend2' }; @@ -267,7 +267,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('and regex pattern exists', function(scenario) { + describeUpdateVariable('and regex pattern exists', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', query: 'apps.*', name: 'test' }; scenario.variableModel.regex = '/apps.*(backend_[0-9]+)/'; @@ -282,7 +282,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('and regex pattern exists and no match', function(scenario) { + describeUpdateVariable('and regex pattern exists and no match', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', query: 'apps.*', name: 'test' }; scenario.variableModel.regex = '/apps.*(backendasd[0-9]+)/'; @@ -298,7 +298,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('regex pattern without slashes', function(scenario) { + describeUpdateVariable('regex pattern without slashes', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', query: 'apps.*', name: 'test' }; scenario.variableModel.regex = 'backend_01'; @@ -313,7 +313,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('regex pattern remove duplicates', function(scenario) { + describeUpdateVariable('regex pattern remove duplicates', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', query: 'apps.*', name: 'test' }; scenario.variableModel.regex = '/backend_01/'; @@ -328,7 +328,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('with include All', function(scenario) { + describeUpdateVariable('with include All', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', @@ -345,7 +345,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('with include all and custom value', function(scenario) { + describeUpdateVariable('with include all and custom value', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', @@ -362,7 +362,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('without sort', function(scenario) { + describeUpdateVariable('without sort', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', @@ -380,7 +380,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('with alphabetical sort (asc)', function(scenario) { + describeUpdateVariable('with alphabetical sort (asc)', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', @@ -398,7 +398,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('with alphabetical sort (desc)', function(scenario) { + describeUpdateVariable('with alphabetical sort (desc)', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', @@ -416,7 +416,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('with numerical sort (asc)', function(scenario) { + describeUpdateVariable('with numerical sort (asc)', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', @@ -434,7 +434,7 @@ describe('VariableSrv', function(this: any) { }); }); - describeUpdateVariable('with numerical sort (desc)', function(scenario) { + describeUpdateVariable('with numerical sort (desc)', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'query', @@ -455,7 +455,7 @@ describe('VariableSrv', function(this: any) { // // datasource variable update // - describeUpdateVariable('datasource variable with regex filter', function(scenario) { + describeUpdateVariable('datasource variable with regex filter', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'datasource', @@ -486,7 +486,7 @@ describe('VariableSrv', function(this: any) { // // Custom variable update // - describeUpdateVariable('update custom variable', function(scenario) { + describeUpdateVariable('update custom variable', scenario => { scenario.setup(() => { scenario.variableModel = { type: 'custom', diff --git a/public/app/plugins/datasource/cloudwatch/specs/datasource.test.ts b/public/app/plugins/datasource/cloudwatch/specs/datasource.test.ts index db08c1d6f81..497c773687f 100644 --- a/public/app/plugins/datasource/cloudwatch/specs/datasource.test.ts +++ b/public/app/plugins/datasource/cloudwatch/specs/datasource.test.ts @@ -3,7 +3,7 @@ import CloudWatchDatasource from '../datasource'; import * as dateMath from 'app/core/utils/datemath'; import _ from 'lodash'; -describe('CloudWatchDatasource', function() { +describe('CloudWatchDatasource', () => { const instanceSettings = { jsonData: { defaultRegion: 'us-east-1', access: 'proxy' }, }; @@ -34,7 +34,7 @@ describe('CloudWatchDatasource', function() { ctx.ds = new CloudWatchDatasource(instanceSettings, {}, backendSrv, templateSrv, timeSrv); }); - describe('When performing CloudWatch query', function() { + describe('When performing CloudWatch query', () => { let requestParams; const query = { @@ -80,8 +80,8 @@ describe('CloudWatchDatasource', function() { }); }); - it('should generate the correct query', function(done) { - ctx.ds.query(query).then(function() { + it('should generate the correct query', done => { + ctx.ds.query(query).then(() => { const params = requestParams.queries[0]; expect(params.namespace).toBe(query.targets[0].namespace); expect(params.metricName).toBe(query.targets[0].metricName); @@ -92,7 +92,7 @@ describe('CloudWatchDatasource', function() { }); }); - it('should generate the correct query with interval variable', function(done) { + it('should generate the correct query with interval variable', done => { ctx.templateSrv.data = { period: '10m', }; @@ -114,14 +114,14 @@ describe('CloudWatchDatasource', function() { ], }; - ctx.ds.query(query).then(function() { + ctx.ds.query(query).then(() => { const params = requestParams.queries[0]; expect(params.period).toBe('600'); done(); }); }); - it('should cancel query for invalid extended statistics', function() { + it('should cancel query for invalid extended statistics', () => { const query = { range: { from: 'now-1h', to: 'now' }, rangeRaw: { from: 1483228800, to: 1483232400 }, @@ -141,8 +141,8 @@ describe('CloudWatchDatasource', function() { expect(ctx.ds.query.bind(ctx.ds, query)).toThrow(/Invalid extended statistics/); }); - it('should return series list', function(done) { - ctx.ds.query(query).then(function(result) { + it('should return series list', done => { + ctx.ds.query(query).then(result => { expect(result.data[0].target).toBe(response.results.A.series[0].name); expect(result.data[0].datapoints[0][0]).toBe(response.results.A.series[0].points[0][0]); done(); @@ -150,8 +150,8 @@ describe('CloudWatchDatasource', function() { }); }); - describe('When query region is "default"', function() { - it('should return the datasource region if empty or "default"', function() { + describe('When query region is "default"', () => { + it('should return the datasource region if empty or "default"', () => { const defaultRegion = instanceSettings.jsonData.defaultRegion; expect(ctx.ds.getActualRegion()).toBe(defaultRegion); @@ -159,19 +159,19 @@ describe('CloudWatchDatasource', function() { expect(ctx.ds.getActualRegion('default')).toBe(defaultRegion); }); - it('should return the specified region if specified', function() { + it('should return the specified region if specified', () => { expect(ctx.ds.getActualRegion('some-fake-region-1')).toBe('some-fake-region-1'); }); let requestParams; - beforeEach(function() { + beforeEach(() => { ctx.ds.performTimeSeriesQuery = jest.fn(request => { requestParams = request; return Promise.resolve({ data: {} }); }); }); - it('should query for the datasource region if empty or "default"', function(done) { + it('should query for the datasource region if empty or "default"', done => { const query = { range: { from: 'now-1h', to: 'now' }, rangeRaw: { from: 1483228800, to: 1483232400 }, @@ -189,14 +189,14 @@ describe('CloudWatchDatasource', function() { ], }; - ctx.ds.query(query).then(function(result) { + ctx.ds.query(query).then(result => { expect(requestParams.queries[0].region).toBe(instanceSettings.jsonData.defaultRegion); done(); }); }); }); - describe('When performing CloudWatch query for extended statistics', function() { + describe('When performing CloudWatch query for extended statistics', () => { const query = { range: { from: 'now-1h', to: 'now' }, rangeRaw: { from: 1483228800, to: 1483232400 }, @@ -235,14 +235,14 @@ describe('CloudWatchDatasource', function() { }, }; - beforeEach(function() { + beforeEach(() => { ctx.backendSrv.datasourceRequest = jest.fn(params => { return Promise.resolve({ data: response }); }); }); - it('should return series list', function(done) { - ctx.ds.query(query).then(function(result) { + it('should return series list', done => { + ctx.ds.query(query).then(result => { expect(result.data[0].target).toBe(response.results.A.series[0].name); expect(result.data[0].datapoints[0][0]).toBe(response.results.A.series[0].points[0][0]); done(); @@ -378,7 +378,7 @@ describe('CloudWatchDatasource', function() { }); }); - it('should caclculate the correct period', function() { + it('should caclculate the correct period', () => { const hourSec = 60 * 60; const daySec = hourSec * 24; const start = 1483196400 * 1000; diff --git a/public/app/plugins/datasource/elasticsearch/specs/datasource.test.ts b/public/app/plugins/datasource/elasticsearch/specs/datasource.test.ts index 980fbe14593..4be0c35852c 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/datasource.test.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/datasource.test.ts @@ -43,8 +43,8 @@ describe('ElasticDatasource', function(this: any) { ctx.ds = new ElasticDatasource(instanceSettings, {}, backendSrv, templateSrv, timeSrv); } - describe('When testing datasource with index pattern', function() { - beforeEach(function() { + describe('When testing datasource with index pattern', () => { + beforeEach(() => { createDatasource({ url: 'http://es.com', index: '[asd-]YYYY.MM.DD', @@ -52,7 +52,7 @@ describe('ElasticDatasource', function(this: any) { }); }); - it('should translate index pattern to current day', function() { + it('should translate index pattern to current day', () => { let requestOptions; ctx.backendSrv.datasourceRequest = jest.fn(options => { requestOptions = options; @@ -66,7 +66,7 @@ describe('ElasticDatasource', function(this: any) { }); }); - describe('When issuing metric query with interval pattern', function() { + describe('When issuing metric query with interval pattern', () => { let requestOptions, parts, header; beforeEach(() => { @@ -99,20 +99,20 @@ describe('ElasticDatasource', function(this: any) { header = angular.fromJson(parts[0]); }); - it('should translate index pattern to current day', function() { + it('should translate index pattern to current day', () => { expect(header.index).toEqual(['asd-2015.05.30', 'asd-2015.05.31', 'asd-2015.06.01']); }); - it('should json escape lucene query', function() { + it('should json escape lucene query', () => { const body = angular.fromJson(parts[1]); expect(body.query.bool.filter[1].query_string.query).toBe('escape\\:test'); }); }); - describe('When issuing document query', function() { + describe('When issuing document query', () => { let requestOptions, parts, header; - beforeEach(function() { + beforeEach(() => { createDatasource({ url: 'http://es.com', index: 'test', @@ -142,17 +142,17 @@ describe('ElasticDatasource', function(this: any) { header = angular.fromJson(parts[0]); }); - it('should set search type to query_then_fetch', function() { + it('should set search type to query_then_fetch', () => { expect(header.search_type).toEqual('query_then_fetch'); }); - it('should set size', function() { + it('should set size', () => { const body = angular.fromJson(parts[1]); expect(body.size).toBe(500); }); }); - describe('When getting fields', function() { + describe('When getting fields', () => { beforeEach(() => { createDatasource({ url: 'http://es.com', index: 'metricbeat' }); @@ -203,7 +203,7 @@ describe('ElasticDatasource', function(this: any) { }); }); - it('should return nested fields', function() { + it('should return nested fields', () => { ctx.ds .getFields({ find: 'fields', @@ -224,7 +224,7 @@ describe('ElasticDatasource', function(this: any) { }); }); - it('should return fields related to query type', function() { + it('should return fields related to query type', () => { ctx.ds .getFields({ find: 'fields', @@ -249,10 +249,10 @@ describe('ElasticDatasource', function(this: any) { }); }); - describe('When issuing aggregation query on es5.x', function() { + describe('When issuing aggregation query on es5.x', () => { let requestOptions, parts, header; - beforeEach(function() { + beforeEach(() => { createDatasource({ url: 'http://es.com', index: 'test', @@ -282,17 +282,17 @@ describe('ElasticDatasource', function(this: any) { header = angular.fromJson(parts[0]); }); - it('should not set search type to count', function() { + it('should not set search type to count', () => { expect(header.search_type).not.toEqual('count'); }); - it('should set size to 0', function() { + it('should set size to 0', () => { const body = angular.fromJson(parts[1]); expect(body.size).toBe(0); }); }); - describe('When issuing metricFind query on es5.x', function() { + describe('When issuing metricFind query on es5.x', () => { let requestOptions, parts, header, body, results; beforeEach(() => { diff --git a/public/app/plugins/datasource/graphite/specs/datasource.test.ts b/public/app/plugins/datasource/graphite/specs/datasource.test.ts index 563f1047cdb..cd60a059123 100644 --- a/public/app/plugins/datasource/graphite/specs/datasource.test.ts +++ b/public/app/plugins/datasource/graphite/specs/datasource.test.ts @@ -12,12 +12,12 @@ describe('graphiteDatasource', () => { instanceSettings: { url: 'url', name: 'graphiteProd', jsonData: {} }, }; - beforeEach(function() { + beforeEach(() => { ctx.instanceSettings.url = '/api/datasources/proxy/1'; ctx.ds = new GraphiteDatasource(ctx.instanceSettings, ctx.$q, ctx.backendSrv, ctx.templateSrv); }); - describe('When querying graphite with one target using query editor target spec', function() { + describe('When querying graphite with one target using query editor target spec', () => { const query = { panelId: 3, dashboardId: 5, @@ -30,14 +30,14 @@ describe('graphiteDatasource', () => { let requestOptions; beforeEach(async () => { - ctx.backendSrv.datasourceRequest = function(options) { + ctx.backendSrv.datasourceRequest = options => { requestOptions = options; return ctx.$q.when({ data: [{ target: 'prod1.count', datapoints: [[10, 1], [12, 1]] }], }); }; - await ctx.ds.query(query).then(function(data) { + await ctx.ds.query(query).then(data => { results = data; }); }); @@ -47,15 +47,15 @@ describe('graphiteDatasource', () => { expect(requestOptions.headers['X-Panel-Id']).toBe(3); }); - it('should generate the correct query', function() { + it('should generate the correct query', () => { expect(requestOptions.url).toBe('/api/datasources/proxy/1/render'); }); - it('should set unique requestId', function() { + it('should set unique requestId', () => { expect(requestOptions.requestId).toBe('graphiteProd.panelId.3'); }); - it('should query correctly', function() { + it('should query correctly', () => { const params = requestOptions.data.split('&'); expect(params).toContain('target=prod1.count'); expect(params).toContain('target=prod2.count'); @@ -63,17 +63,17 @@ describe('graphiteDatasource', () => { expect(params).toContain('until=now'); }); - it('should exclude undefined params', function() { + it('should exclude undefined params', () => { const params = requestOptions.data.split('&'); expect(params).not.toContain('cacheTimeout=undefined'); }); - it('should return series list', function() { + it('should return series list', () => { expect(results.data.length).toBe(1); expect(results.data[0].target).toBe('prod1.count'); }); - it('should convert to millisecond resolution', function() { + it('should convert to millisecond resolution', () => { expect(results.data[0].datapoints[0][0]).toBe(10); }); }); @@ -106,11 +106,11 @@ describe('graphiteDatasource', () => { }; beforeEach(async () => { - ctx.backendSrv.datasourceRequest = function(options) { + ctx.backendSrv.datasourceRequest = options => { return ctx.$q.when(response); }; - await ctx.ds.annotationQuery(options).then(function(data) { + await ctx.ds.annotationQuery(options).then(data => { results = data; }); }); @@ -136,11 +136,11 @@ describe('graphiteDatasource', () => { ], }; beforeEach(() => { - ctx.backendSrv.datasourceRequest = function(options) { + ctx.backendSrv.datasourceRequest = options => { return ctx.$q.when(response); }; - ctx.ds.annotationQuery(options).then(function(data) { + ctx.ds.annotationQuery(options).then(data => { results = data; }); // ctx.$rootScope.$apply(); @@ -155,29 +155,29 @@ describe('graphiteDatasource', () => { }); }); - describe('building graphite params', function() { - it('should return empty array if no targets', function() { + describe('building graphite params', () => { + it('should return empty array if no targets', () => { const results = ctx.ds.buildGraphiteParams({ targets: [{}], }); expect(results.length).toBe(0); }); - it('should uri escape targets', function() { + it('should uri escape targets', () => { const results = ctx.ds.buildGraphiteParams({ targets: [{ target: 'prod1.{test,test2}' }, { target: 'prod2.count' }], }); expect(results).toContain('target=prod1.%7Btest%2Ctest2%7D'); }); - it('should replace target placeholder', function() { + it('should replace target placeholder', () => { const results = ctx.ds.buildGraphiteParams({ targets: [{ target: 'series1' }, { target: 'series2' }, { target: 'asPercent(#A,#B)' }], }); expect(results[2]).toBe('target=asPercent(series1%2Cseries2)'); }); - it('should replace target placeholder for hidden series', function() { + it('should replace target placeholder for hidden series', () => { const results = ctx.ds.buildGraphiteParams({ targets: [ { target: 'series1', hide: true }, @@ -188,28 +188,28 @@ describe('graphiteDatasource', () => { expect(results[0]).toBe('target=' + encodeURIComponent('asPercent(series1,sumSeries(series1))')); }); - it('should replace target placeholder when nesting query references', function() { + it('should replace target placeholder when nesting query references', () => { const results = ctx.ds.buildGraphiteParams({ targets: [{ target: 'series1' }, { target: 'sumSeries(#A)' }, { target: 'asPercent(#A,#B)' }], }); expect(results[2]).toBe('target=' + encodeURIComponent('asPercent(series1,sumSeries(series1))')); }); - it('should fix wrong minute interval parameters', function() { + it('should fix wrong minute interval parameters', () => { const results = ctx.ds.buildGraphiteParams({ targets: [{ target: "summarize(prod.25m.count, '25m', 'sum')" }], }); expect(results[0]).toBe('target=' + encodeURIComponent("summarize(prod.25m.count, '25min', 'sum')")); }); - it('should fix wrong month interval parameters', function() { + it('should fix wrong month interval parameters', () => { const results = ctx.ds.buildGraphiteParams({ targets: [{ target: "summarize(prod.5M.count, '5M', 'sum')" }], }); expect(results[0]).toBe('target=' + encodeURIComponent("summarize(prod.5M.count, '5mon', 'sum')")); }); - it('should ignore empty targets', function() { + it('should ignore empty targets', () => { const results = ctx.ds.buildGraphiteParams({ targets: [{ target: 'series1' }, { target: '' }], }); @@ -222,7 +222,7 @@ describe('graphiteDatasource', () => { let requestOptions; beforeEach(() => { - ctx.backendSrv.datasourceRequest = function(options) { + ctx.backendSrv.datasourceRequest = options => { requestOptions = options; return ctx.$q.when({ data: ['backend_01', 'backend_02'], @@ -307,7 +307,7 @@ describe('graphiteDatasource', () => { }); function accessScenario(name, url, fn) { - describe('access scenario ' + name, function() { + describe('access scenario ' + name, () => { const ctx: any = { backendSrv: {}, $q: $q, @@ -332,12 +332,12 @@ function accessScenario(name, url, fn) { }); } -accessScenario('with proxy access', '/api/datasources/proxy/1', function(httpOptions) { +accessScenario('with proxy access', '/api/datasources/proxy/1', httpOptions => { expect(httpOptions.headers['X-Dashboard-Id']).toBe(1); expect(httpOptions.headers['X-Panel-Id']).toBe(2); }); -accessScenario('with direct access', 'http://localhost:8080', function(httpOptions) { +accessScenario('with direct access', 'http://localhost:8080', httpOptions => { expect(httpOptions.headers['X-Dashboard-Id']).toBe(undefined); expect(httpOptions.headers['X-Panel-Id']).toBe(undefined); }); diff --git a/public/app/plugins/datasource/graphite/specs/gfunc.test.ts b/public/app/plugins/datasource/graphite/specs/gfunc.test.ts index 61a0e896b0f..1809adc0940 100644 --- a/public/app/plugins/datasource/graphite/specs/gfunc.test.ts +++ b/public/app/plugins/datasource/graphite/specs/gfunc.test.ts @@ -1,7 +1,7 @@ import gfunc from '../gfunc'; -describe('when creating func instance from func names', function() { - it('should return func instance', function() { +describe('when creating func instance from func names', () => { + it('should return func instance', () => { const func = gfunc.createFuncInstance('sumSeries'); expect(func).toBeTruthy(); expect(func.def.name).toEqual('sumSeries'); @@ -10,18 +10,18 @@ describe('when creating func instance from func names', function() { expect(func.def.defaultParams.length).toEqual(1); }); - it('should return func instance with shortName', function() { + it('should return func instance with shortName', () => { const func = gfunc.createFuncInstance('sum'); expect(func).toBeTruthy(); }); - it('should return func instance from funcDef', function() { + it('should return func instance from funcDef', () => { const func = gfunc.createFuncInstance('sum'); const func2 = gfunc.createFuncInstance(func.def); expect(func2).toBeTruthy(); }); - it('func instance should have text representation', function() { + it('func instance should have text representation', () => { const func = gfunc.createFuncInstance('groupByNode'); func.params[0] = 5; func.params[1] = 'avg'; @@ -30,78 +30,78 @@ describe('when creating func instance from func names', function() { }); }); -describe('when rendering func instance', function() { - it('should handle single metric param', function() { +describe('when rendering func instance', () => { + it('should handle single metric param', () => { const func = gfunc.createFuncInstance('sumSeries'); expect(func.render('hello.metric')).toEqual('sumSeries(hello.metric)'); }); - it('should include default params if options enable it', function() { + it('should include default params if options enable it', () => { const func = gfunc.createFuncInstance('scaleToSeconds', { withDefaultParams: true, }); expect(func.render('hello')).toEqual('scaleToSeconds(hello, 1)'); }); - it('should handle int or interval params with number', function() { + it('should handle int or interval params with number', () => { const func = gfunc.createFuncInstance('movingMedian'); func.params[0] = '5'; expect(func.render('hello')).toEqual('movingMedian(hello, 5)'); }); - it('should handle int or interval params with interval string', function() { + it('should handle int or interval params with interval string', () => { const func = gfunc.createFuncInstance('movingMedian'); func.params[0] = '5min'; expect(func.render('hello')).toEqual("movingMedian(hello, '5min')"); }); - it('should never quote boolean paramater', function() { + it('should never quote boolean paramater', () => { const func = gfunc.createFuncInstance('sortByName'); func.params[0] = '$natural'; expect(func.render('hello')).toEqual('sortByName(hello, $natural)'); }); - it('should never quote int paramater', function() { + it('should never quote int paramater', () => { const func = gfunc.createFuncInstance('maximumAbove'); func.params[0] = '$value'; expect(func.render('hello')).toEqual('maximumAbove(hello, $value)'); }); - it('should never quote node paramater', function() { + it('should never quote node paramater', () => { const func = gfunc.createFuncInstance('aliasByNode'); func.params[0] = '$node'; expect(func.render('hello')).toEqual('aliasByNode(hello, $node)'); }); - it('should handle metric param and int param and string param', function() { + it('should handle metric param and int param and string param', () => { const func = gfunc.createFuncInstance('groupByNode'); func.params[0] = 5; func.params[1] = 'avg'; expect(func.render('hello.metric')).toEqual("groupByNode(hello.metric, 5, 'avg')"); }); - it('should handle function with no metric param', function() { + it('should handle function with no metric param', () => { const func = gfunc.createFuncInstance('randomWalk'); func.params[0] = 'test'; expect(func.render(undefined)).toEqual("randomWalk('test')"); }); - it('should handle function multiple series params', function() { + it('should handle function multiple series params', () => { const func = gfunc.createFuncInstance('asPercent'); func.params[0] = '#B'; expect(func.render('#A')).toEqual('asPercent(#A, #B)'); }); }); -describe('when requesting function definitions', function() { - it('should return function definitions', function() { +describe('when requesting function definitions', () => { + it('should return function definitions', () => { const funcIndex = gfunc.getFuncDefs('1.0'); expect(Object.keys(funcIndex).length).toBeGreaterThan(8); }); }); -describe('when updating func param', function() { - it('should update param value and update text representation', function() { +describe('when updating func param', () => { + it('should update param value and update text representation', () => { const func = gfunc.createFuncInstance('summarize', { withDefaultParams: true, }); @@ -110,21 +110,21 @@ describe('when updating func param', function() { expect(func.text).toBe('summarize(1h, sum, false)'); }); - it('should parse numbers as float', function() { + it('should parse numbers as float', () => { const func = gfunc.createFuncInstance('scale'); func.updateParam('0.001', 0); expect(func.params[0]).toBe('0.001'); }); }); -describe('when updating func param with optional second parameter', function() { - it('should update value and text', function() { +describe('when updating func param with optional second parameter', () => { + it('should update value and text', () => { const func = gfunc.createFuncInstance('aliasByNode'); func.updateParam('1', 0); expect(func.params[0]).toBe('1'); }); - it('should slit text and put value in second param', function() { + it('should slit text and put value in second param', () => { const func = gfunc.createFuncInstance('aliasByNode'); func.updateParam('4,-5', 0); expect(func.params[0]).toBe('4'); @@ -132,7 +132,7 @@ describe('when updating func param with optional second parameter', function() { expect(func.text).toBe('aliasByNode(4, -5)'); }); - it('should remove second param when empty string is set', function() { + it('should remove second param when empty string is set', () => { const func = gfunc.createFuncInstance('aliasByNode'); func.updateParam('4,-5', 0); func.updateParam('', 1); diff --git a/public/app/plugins/datasource/graphite/specs/lexer.test.ts b/public/app/plugins/datasource/graphite/specs/lexer.test.ts index f00df17a725..4bfe7217bfa 100644 --- a/public/app/plugins/datasource/graphite/specs/lexer.test.ts +++ b/public/app/plugins/datasource/graphite/specs/lexer.test.ts @@ -1,7 +1,7 @@ import { Lexer } from '../lexer'; -describe('when lexing graphite expression', function() { - it('should tokenize metric expression', function() { +describe('when lexing graphite expression', () => { + it('should tokenize metric expression', () => { const lexer = new Lexer('metric.test.*.asd.count'); const tokens = lexer.tokenize(); expect(tokens[0].value).toBe('metric'); @@ -11,27 +11,27 @@ describe('when lexing graphite expression', function() { expect(tokens[4].pos).toBe(13); }); - it('should tokenize metric expression with dash', function() { + it('should tokenize metric expression with dash', () => { const lexer = new Lexer('metric.test.se1-server-*.asd.count'); const tokens = lexer.tokenize(); expect(tokens[4].type).toBe('identifier'); expect(tokens[4].value).toBe('se1-server-*'); }); - it('should tokenize metric expression with dash2', function() { + it('should tokenize metric expression with dash2', () => { const lexer = new Lexer('net.192-168-1-1.192-168-1-9.ping_value.*'); const tokens = lexer.tokenize(); expect(tokens[0].value).toBe('net'); expect(tokens[2].value).toBe('192-168-1-1'); }); - it('should tokenize metric expression with equal sign', function() { + it('should tokenize metric expression with equal sign', () => { const lexer = new Lexer('apps=test'); const tokens = lexer.tokenize(); expect(tokens[0].value).toBe('apps=test'); }); - it('simple function2', function() { + it('simple function2', () => { const lexer = new Lexer('offset(test.metric, -100)'); const tokens = lexer.tokenize(); expect(tokens[2].type).toBe('identifier'); @@ -39,7 +39,7 @@ describe('when lexing graphite expression', function() { expect(tokens[6].type).toBe('number'); }); - it('should tokenize metric expression with curly braces', function() { + it('should tokenize metric expression with curly braces', () => { const lexer = new Lexer('metric.se1-{first, second}.count'); const tokens = lexer.tokenize(); expect(tokens.length).toBe(10); @@ -49,7 +49,7 @@ describe('when lexing graphite expression', function() { expect(tokens[6].value).toBe('second'); }); - it('should tokenize metric expression with number segments', function() { + it('should tokenize metric expression with number segments', () => { const lexer = new Lexer('metric.10.12_10.test'); const tokens = lexer.tokenize(); expect(tokens[0].type).toBe('identifier'); @@ -59,7 +59,7 @@ describe('when lexing graphite expression', function() { expect(tokens[4].type).toBe('identifier'); }); - it('should tokenize metric expression with segment that start with number', function() { + it('should tokenize metric expression with segment that start with number', () => { const lexer = new Lexer('metric.001-server'); const tokens = lexer.tokenize(); expect(tokens[0].type).toBe('identifier'); @@ -67,7 +67,7 @@ describe('when lexing graphite expression', function() { expect(tokens.length).toBe(3); }); - it('should tokenize func call with numbered metric and number arg', function() { + it('should tokenize func call with numbered metric and number arg', () => { const lexer = new Lexer('scale(metric.10, 15)'); const tokens = lexer.tokenize(); expect(tokens[0].type).toBe('identifier'); @@ -78,7 +78,7 @@ describe('when lexing graphite expression', function() { expect(tokens[6].type).toBe('number'); }); - it('should tokenize metric with template parameter', function() { + it('should tokenize metric with template parameter', () => { const lexer = new Lexer('metric.[[server]].test'); const tokens = lexer.tokenize(); expect(tokens[2].type).toBe('identifier'); @@ -86,7 +86,7 @@ describe('when lexing graphite expression', function() { expect(tokens[4].type).toBe('identifier'); }); - it('should tokenize metric with question mark', function() { + it('should tokenize metric with question mark', () => { const lexer = new Lexer('metric.server_??.test'); const tokens = lexer.tokenize(); expect(tokens[2].type).toBe('identifier'); @@ -94,7 +94,7 @@ describe('when lexing graphite expression', function() { expect(tokens[4].type).toBe('identifier'); }); - it('should handle error with unterminated string', function() { + it('should handle error with unterminated string', () => { const lexer = new Lexer("alias(metric, 'asd)"); const tokens = lexer.tokenize(); expect(tokens[0].value).toBe('alias'); @@ -106,14 +106,14 @@ describe('when lexing graphite expression', function() { expect(tokens[4].pos).toBe(20); }); - it('should handle float parameters', function() { + it('should handle float parameters', () => { const lexer = new Lexer('alias(metric, 0.002)'); const tokens = lexer.tokenize(); expect(tokens[4].type).toBe('number'); expect(tokens[4].value).toBe('0.002'); }); - it('should handle bool parameters', function() { + it('should handle bool parameters', () => { const lexer = new Lexer('alias(metric, true, false)'); const tokens = lexer.tokenize(); expect(tokens[4].type).toBe('bool'); diff --git a/public/app/plugins/datasource/graphite/specs/parser.test.ts b/public/app/plugins/datasource/graphite/specs/parser.test.ts index 966eb213d64..25cabd5d20c 100644 --- a/public/app/plugins/datasource/graphite/specs/parser.test.ts +++ b/public/app/plugins/datasource/graphite/specs/parser.test.ts @@ -1,7 +1,7 @@ import { Parser } from '../parser'; -describe('when parsing', function() { - it('simple metric expression', function() { +describe('when parsing', () => { + it('simple metric expression', () => { const parser = new Parser('metric.test.*.asd.count'); const rootNode = parser.getAst(); @@ -10,7 +10,7 @@ describe('when parsing', function() { expect(rootNode.segments[0].value).toBe('metric'); }); - it('simple metric expression with numbers in segments', function() { + it('simple metric expression with numbers in segments', () => { const parser = new Parser('metric.10.15_20.5'); const rootNode = parser.getAst(); @@ -21,7 +21,7 @@ describe('when parsing', function() { expect(rootNode.segments[3].value).toBe('5'); }); - it('simple metric expression with curly braces', function() { + it('simple metric expression with curly braces', () => { const parser = new Parser('metric.se1-{count, max}'); const rootNode = parser.getAst(); @@ -30,7 +30,7 @@ describe('when parsing', function() { expect(rootNode.segments[1].value).toBe('se1-{count,max}'); }); - it('simple metric expression with curly braces at start of segment and with post chars', function() { + it('simple metric expression with curly braces at start of segment and with post chars', () => { const parser = new Parser('metric.{count, max}-something.count'); const rootNode = parser.getAst(); @@ -39,14 +39,14 @@ describe('when parsing', function() { expect(rootNode.segments[1].value).toBe('{count,max}-something'); }); - it('simple function', function() { + it('simple function', () => { const parser = new Parser('sum(test)'); const rootNode = parser.getAst(); expect(rootNode.type).toBe('function'); expect(rootNode.params.length).toBe(1); }); - it('simple function2', function() { + it('simple function2', () => { const parser = new Parser('offset(test.metric, -100)'); const rootNode = parser.getAst(); expect(rootNode.type).toBe('function'); @@ -54,7 +54,7 @@ describe('when parsing', function() { expect(rootNode.params[1].type).toBe('number'); }); - it('simple function with string arg', function() { + it('simple function with string arg', () => { const parser = new Parser("randomWalk('test')"); const rootNode = parser.getAst(); expect(rootNode.type).toBe('function'); @@ -62,7 +62,7 @@ describe('when parsing', function() { expect(rootNode.params[0].type).toBe('string'); }); - it('function with multiple args', function() { + it('function with multiple args', () => { const parser = new Parser("sum(test, 1, 'test')"); const rootNode = parser.getAst(); @@ -73,7 +73,7 @@ describe('when parsing', function() { expect(rootNode.params[2].type).toBe('string'); }); - it('function with nested function', function() { + it('function with nested function', () => { const parser = new Parser('sum(scaleToSeconds(test, 1))'); const rootNode = parser.getAst(); @@ -86,7 +86,7 @@ describe('when parsing', function() { expect(rootNode.params[0].params[1].type).toBe('number'); }); - it('function with multiple series', function() { + it('function with multiple series', () => { const parser = new Parser('sum(test.test.*.count, test.timers.*.count)'); const rootNode = parser.getAst(); @@ -96,7 +96,7 @@ describe('when parsing', function() { expect(rootNode.params[1].type).toBe('metric'); }); - it('function with templated series', function() { + it('function with templated series', () => { const parser = new Parser('sum(test.[[server]].count)'); const rootNode = parser.getAst(); @@ -106,7 +106,7 @@ describe('when parsing', function() { expect(rootNode.params[0].segments[1].value).toBe('[[server]]'); }); - it('invalid metric expression', function() { + it('invalid metric expression', () => { const parser = new Parser('metric.test.*.asd.'); const rootNode = parser.getAst(); @@ -114,7 +114,7 @@ describe('when parsing', function() { expect(rootNode.pos).toBe(19); }); - it('invalid function expression missing closing parenthesis', function() { + it('invalid function expression missing closing parenthesis', () => { const parser = new Parser('sum(test'); const rootNode = parser.getAst(); @@ -122,7 +122,7 @@ describe('when parsing', function() { expect(rootNode.pos).toBe(9); }); - it('unclosed string in function', function() { + it('unclosed string in function', () => { const parser = new Parser("sum('test)"); const rootNode = parser.getAst(); @@ -130,13 +130,13 @@ describe('when parsing', function() { expect(rootNode.pos).toBe(11); }); - it('handle issue #69', function() { + it('handle issue #69', () => { const parser = new Parser('cactiStyle(offset(scale(net.192-168-1-1.192-168-1-9.ping_value.*,0.001),-100))'); const rootNode = parser.getAst(); expect(rootNode.type).toBe('function'); }); - it('handle float function arguments', function() { + it('handle float function arguments', () => { const parser = new Parser('scale(test, 0.002)'); const rootNode = parser.getAst(); expect(rootNode.type).toBe('function'); @@ -144,7 +144,7 @@ describe('when parsing', function() { expect(rootNode.params[1].value).toBe(0.002); }); - it('handle curly brace pattern at start', function() { + it('handle curly brace pattern at start', () => { const parser = new Parser('{apps}.test'); const rootNode = parser.getAst(); expect(rootNode.type).toBe('metric'); @@ -152,7 +152,7 @@ describe('when parsing', function() { expect(rootNode.segments[1].value).toBe('test'); }); - it('series parameters', function() { + it('series parameters', () => { const parser = new Parser('asPercent(#A, #B)'); const rootNode = parser.getAst(); expect(rootNode.type).toBe('function'); @@ -161,7 +161,7 @@ describe('when parsing', function() { expect(rootNode.params[1].value).toBe('#B'); }); - it('series parameters, issue 2788', function() { + it('series parameters, issue 2788', () => { const parser = new Parser("summarize(diffSeries(#A, #B), '10m', 'sum', false)"); const rootNode = parser.getAst(); expect(rootNode.type).toBe('function'); @@ -170,7 +170,7 @@ describe('when parsing', function() { expect(rootNode.params[3].type).toBe('bool'); }); - it('should parse metric expression with ip number segments', function() { + it('should parse metric expression with ip number segments', () => { const parser = new Parser('5.10.123.5'); const rootNode = parser.getAst(); expect(rootNode.segments[0].value).toBe('5'); diff --git a/public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts b/public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts index 6a07e44252d..13ac2a48223 100644 --- a/public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts +++ b/public/app/plugins/datasource/graphite/specs/query_ctrl.test.ts @@ -137,7 +137,7 @@ describe('GraphiteQueryCtrl', () => { ctx.ctrl.target.target = 'test.count'; ctx.ctrl.datasource.metricFindQuery = () => Promise.resolve([]); ctx.ctrl.parseTarget(); - ctx.ctrl.getAltSegments(1).then(function(results) { + ctx.ctrl.getAltSegments(1).then(results => { ctx.altSegments = results; }); }); diff --git a/public/app/plugins/datasource/influxdb/specs/datasource.test.ts b/public/app/plugins/datasource/influxdb/specs/datasource.test.ts index 60f49bd4905..62049535e3e 100644 --- a/public/app/plugins/datasource/influxdb/specs/datasource.test.ts +++ b/public/app/plugins/datasource/influxdb/specs/datasource.test.ts @@ -10,7 +10,7 @@ describe('InfluxDataSource', () => { instanceSettings: { url: 'url', name: 'influxDb', jsonData: {} }, }; - beforeEach(function() { + beforeEach(() => { ctx.instanceSettings.url = '/api/datasources/proxy/1'; ctx.ds = new InfluxDatasource(ctx.instanceSettings, ctx.$q, ctx.backendSrv, ctx.templateSrv); }); @@ -26,7 +26,7 @@ describe('InfluxDataSource', () => { let requestQuery; beforeEach(async () => { - ctx.backendSrv.datasourceRequest = function(req) { + ctx.backendSrv.datasourceRequest = req => { requestQuery = req.params.q; return ctx.$q.when({ results: [ @@ -43,7 +43,7 @@ describe('InfluxDataSource', () => { }); }; - await ctx.ds.metricFindQuery(query, queryOptions).then(function(_) {}); + await ctx.ds.metricFindQuery(query, queryOptions).then(_ => {}); }); it('should replace $timefilter', () => { diff --git a/public/app/plugins/datasource/influxdb/specs/influx_query.test.ts b/public/app/plugins/datasource/influxdb/specs/influx_query.test.ts index a62d5384ac6..f8e65c21f2d 100644 --- a/public/app/plugins/datasource/influxdb/specs/influx_query.test.ts +++ b/public/app/plugins/datasource/influxdb/specs/influx_query.test.ts @@ -1,10 +1,10 @@ import InfluxQuery from '../influx_query'; -describe('InfluxQuery', function() { +describe('InfluxQuery', () => { const templateSrv = { replace: val => val }; - describe('render series with mesurement only', function() { - it('should generate correct query', function() { + describe('render series with mesurement only', () => { + it('should generate correct query', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -18,8 +18,8 @@ describe('InfluxQuery', function() { }); }); - describe('render series with policy only', function() { - it('should generate correct query', function() { + describe('render series with policy only', () => { + it('should generate correct query', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -36,8 +36,8 @@ describe('InfluxQuery', function() { }); }); - describe('render series with math and alias', function() { - it('should generate correct query', function() { + describe('render series with math and alias', () => { + it('should generate correct query', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -61,8 +61,8 @@ describe('InfluxQuery', function() { }); }); - describe('series with single tag only', function() { - it('should generate correct query', function() { + describe('series with single tag only', () => { + it('should generate correct query', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -81,7 +81,7 @@ describe('InfluxQuery', function() { ); }); - it('should switch regex operator with tag value is regex', function() { + it('should switch regex operator with tag value is regex', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -99,8 +99,8 @@ describe('InfluxQuery', function() { }); }); - describe('series with multiple tags only', function() { - it('should generate correct query', function() { + describe('series with multiple tags only', () => { + it('should generate correct query', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -119,8 +119,8 @@ describe('InfluxQuery', function() { }); }); - describe('series with tags OR condition', function() { - it('should generate correct query', function() { + describe('series with tags OR condition', () => { + it('should generate correct query', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -139,8 +139,8 @@ describe('InfluxQuery', function() { }); }); - describe('query with value condition', function() { - it('should not quote value', function() { + describe('query with value condition', () => { + it('should not quote value', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -156,8 +156,8 @@ describe('InfluxQuery', function() { }); }); - describe('series with groupByTag', function() { - it('should generate correct query', function() { + describe('series with groupByTag', () => { + it('should generate correct query', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -173,8 +173,8 @@ describe('InfluxQuery', function() { }); }); - describe('render series without group by', function() { - it('should generate correct query', function() { + describe('render series without group by', () => { + it('should generate correct query', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -189,8 +189,8 @@ describe('InfluxQuery', function() { }); }); - describe('render series without group by and fill', function() { - it('should generate correct query', function() { + describe('render series without group by and fill', () => { + it('should generate correct query', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -205,8 +205,8 @@ describe('InfluxQuery', function() { }); }); - describe('when adding group by part', function() { - it('should add tag before fill', function() { + describe('when adding group by part', () => { + it('should add tag before fill', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -223,7 +223,7 @@ describe('InfluxQuery', function() { expect(query.target.groupBy[2].type).toBe('fill'); }); - it('should add tag last if no fill', function() { + it('should add tag last if no fill', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -239,8 +239,8 @@ describe('InfluxQuery', function() { }); }); - describe('when adding select part', function() { - it('should add mean after after field', function() { + describe('when adding select part', () => { + it('should add mean after after field', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -255,7 +255,7 @@ describe('InfluxQuery', function() { expect(query.target.select[0][1].type).toBe('mean'); }); - it('should replace sum by mean', function() { + it('should replace sum by mean', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -270,7 +270,7 @@ describe('InfluxQuery', function() { expect(query.target.select[0][1].type).toBe('sum'); }); - it('should add math before alias', function() { + it('should add math before alias', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -285,7 +285,7 @@ describe('InfluxQuery', function() { expect(query.target.select[0][2].type).toBe('math'); }); - it('should add math last', function() { + it('should add math last', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -300,7 +300,7 @@ describe('InfluxQuery', function() { expect(query.target.select[0][2].type).toBe('math'); }); - it('should replace math', function() { + it('should replace math', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -315,7 +315,7 @@ describe('InfluxQuery', function() { expect(query.target.select[0][2].type).toBe('math'); }); - it('should add math when one only query part', function() { + it('should add math when one only query part', () => { const query = new InfluxQuery( { measurement: 'cpu', @@ -330,8 +330,8 @@ describe('InfluxQuery', function() { expect(query.target.select[0][1].type).toBe('math'); }); - describe('when render adhoc filters', function() { - it('should generate correct query segment', function() { + describe('when render adhoc filters', () => { + it('should generate correct query segment', () => { const query = new InfluxQuery({ measurement: 'cpu' }, templateSrv, {}); const queryText = query.renderAdhocFilters([ diff --git a/public/app/plugins/datasource/influxdb/specs/influx_series.test.ts b/public/app/plugins/datasource/influxdb/specs/influx_series.test.ts index bb20db1ba76..44232173e27 100644 --- a/public/app/plugins/datasource/influxdb/specs/influx_series.test.ts +++ b/public/app/plugins/datasource/influxdb/specs/influx_series.test.ts @@ -1,7 +1,7 @@ import InfluxSeries from '../influx_series'; -describe('when generating timeseries from influxdb response', function() { - describe('given multiple fields for series', function() { +describe('when generating timeseries from influxdb response', () => { + describe('given multiple fields for series', () => { const options = { alias: '', series: [ @@ -13,8 +13,8 @@ describe('when generating timeseries from influxdb response', function() { }, ], }; - describe('and no alias', function() { - it('should generate multiple datapoints for each column', function() { + describe('and no alias', () => { + it('should generate multiple datapoints for each column', () => { const series = new InfluxSeries(options); const result = series.getTimeSeries(); @@ -39,8 +39,8 @@ describe('when generating timeseries from influxdb response', function() { }); }); - describe('and simple alias', function() { - it('should use alias', function() { + describe('and simple alias', () => { + it('should use alias', () => { options.alias = 'new series'; const series = new InfluxSeries(options); const result = series.getTimeSeries(); @@ -51,8 +51,8 @@ describe('when generating timeseries from influxdb response', function() { }); }); - describe('and alias patterns', function() { - it('should replace patterns', function() { + describe('and alias patterns', () => { + it('should replace patterns', () => { options.alias = 'alias: $m -> $tag_server ([[measurement]])'; const series = new InfluxSeries(options); const result = series.getTimeSeries(); @@ -64,7 +64,7 @@ describe('when generating timeseries from influxdb response', function() { }); }); - describe('given measurement with default fieldname', function() { + describe('given measurement with default fieldname', () => { const options = { series: [ { @@ -82,8 +82,8 @@ describe('when generating timeseries from influxdb response', function() { ], }; - describe('and no alias', function() { - it('should generate label with no field', function() { + describe('and no alias', () => { + it('should generate label with no field', () => { const series = new InfluxSeries(options); const result = series.getTimeSeries(); @@ -93,7 +93,7 @@ describe('when generating timeseries from influxdb response', function() { }); }); - describe('given two series', function() { + describe('given two series', () => { const options = { alias: '', series: [ @@ -112,8 +112,8 @@ describe('when generating timeseries from influxdb response', function() { ], }; - describe('and no alias', function() { - it('should generate two time series', function() { + describe('and no alias', () => { + it('should generate two time series', () => { const series = new InfluxSeries(options); const result = series.getTimeSeries(); @@ -132,8 +132,8 @@ describe('when generating timeseries from influxdb response', function() { }); }); - describe('and simple alias', function() { - it('should use alias', function() { + describe('and simple alias', () => { + it('should use alias', () => { options.alias = 'new series'; const series = new InfluxSeries(options); const result = series.getTimeSeries(); @@ -142,8 +142,8 @@ describe('when generating timeseries from influxdb response', function() { }); }); - describe('and alias patterns', function() { - it('should replace patterns', function() { + describe('and alias patterns', () => { + it('should replace patterns', () => { options.alias = 'alias: $m -> $tag_server ([[measurement]])'; const series = new InfluxSeries(options); const result = series.getTimeSeries(); @@ -154,7 +154,7 @@ describe('when generating timeseries from influxdb response', function() { }); }); - describe('given measurement with dots', function() { + describe('given measurement with dots', () => { const options = { alias: '', series: [ @@ -167,7 +167,7 @@ describe('when generating timeseries from influxdb response', function() { ], }; - it('should replace patterns', function() { + it('should replace patterns', () => { options.alias = 'alias: $1 -> [[3]]'; const series = new InfluxSeries(options); const result = series.getTimeSeries(); @@ -176,7 +176,7 @@ describe('when generating timeseries from influxdb response', function() { }); }); - describe('given table response', function() { + describe('given table response', () => { const options = { alias: '', series: [ @@ -189,7 +189,7 @@ describe('when generating timeseries from influxdb response', function() { ], }; - it('should return table', function() { + it('should return table', () => { const series = new InfluxSeries(options); const table = series.getTable(); @@ -200,7 +200,7 @@ describe('when generating timeseries from influxdb response', function() { }); }); - describe('given table response from SHOW CARDINALITY', function() { + describe('given table response from SHOW CARDINALITY', () => { const options = { alias: '', series: [ @@ -212,7 +212,7 @@ describe('when generating timeseries from influxdb response', function() { ], }; - it('should return table', function() { + it('should return table', () => { const series = new InfluxSeries(options); const table = series.getTable(); @@ -223,8 +223,8 @@ describe('when generating timeseries from influxdb response', function() { }); }); - describe('given annotation response', function() { - describe('with empty tagsColumn', function() { + describe('given annotation response', () => { + describe('with empty tagsColumn', () => { const options = { alias: '', annotation: {}, @@ -238,7 +238,7 @@ describe('when generating timeseries from influxdb response', function() { ], }; - it('should multiple tags', function() { + it('should multiple tags', () => { const series = new InfluxSeries(options); const annotations = series.getAnnotations(); @@ -246,7 +246,7 @@ describe('when generating timeseries from influxdb response', function() { }); }); - describe('given annotation response', function() { + describe('given annotation response', () => { const options = { alias: '', annotation: { @@ -262,7 +262,7 @@ describe('when generating timeseries from influxdb response', function() { ], }; - it('should multiple tags', function() { + it('should multiple tags', () => { const series = new InfluxSeries(options); const annotations = series.getAnnotations(); diff --git a/public/app/plugins/datasource/influxdb/specs/query_builder.test.ts b/public/app/plugins/datasource/influxdb/specs/query_builder.test.ts index d8b27f8b1bf..e21b95ac374 100644 --- a/public/app/plugins/datasource/influxdb/specs/query_builder.test.ts +++ b/public/app/plugins/datasource/influxdb/specs/query_builder.test.ts @@ -1,14 +1,14 @@ import { InfluxQueryBuilder } from '../query_builder'; -describe('InfluxQueryBuilder', function() { - describe('when building explore queries', function() { - it('should only have measurement condition in tag keys query given query with measurement', function() { +describe('InfluxQueryBuilder', () => { + describe('when building explore queries', () => { + it('should only have measurement condition in tag keys query given query with measurement', () => { const builder = new InfluxQueryBuilder({ measurement: 'cpu', tags: [] }); const query = builder.buildExploreQuery('TAG_KEYS'); expect(query).toBe('SHOW TAG KEYS FROM "cpu"'); }); - it('should handle regex measurement in tag keys query', function() { + it('should handle regex measurement in tag keys query', () => { const builder = new InfluxQueryBuilder({ measurement: '/.*/', tags: [], @@ -17,13 +17,13 @@ describe('InfluxQueryBuilder', function() { expect(query).toBe('SHOW TAG KEYS FROM /.*/'); }); - it('should have no conditions in tags keys query given query with no measurement or tag', function() { + it('should have no conditions in tags keys query given query with no measurement or tag', () => { const builder = new InfluxQueryBuilder({ measurement: '', tags: [] }); const query = builder.buildExploreQuery('TAG_KEYS'); expect(query).toBe('SHOW TAG KEYS'); }); - it('should have where condition in tag keys query with tags', function() { + it('should have where condition in tag keys query with tags', () => { const builder = new InfluxQueryBuilder({ measurement: '', tags: [{ key: 'host', value: 'se1' }], @@ -32,25 +32,25 @@ describe('InfluxQueryBuilder', function() { expect(query).toBe('SHOW TAG KEYS WHERE "host" = \'se1\''); }); - it('should have no conditions in measurement query for query with no tags', function() { + it('should have no conditions in measurement query for query with no tags', () => { const builder = new InfluxQueryBuilder({ measurement: '', tags: [] }); const query = builder.buildExploreQuery('MEASUREMENTS'); expect(query).toBe('SHOW MEASUREMENTS LIMIT 100'); }); - it('should have no conditions in measurement query for query with no tags and empty query', function() { + it('should have no conditions in measurement query for query with no tags and empty query', () => { const builder = new InfluxQueryBuilder({ measurement: '', tags: [] }); const query = builder.buildExploreQuery('MEASUREMENTS', undefined, ''); expect(query).toBe('SHOW MEASUREMENTS LIMIT 100'); }); - it('should have WITH MEASUREMENT in measurement query for non-empty query with no tags', function() { + it('should have WITH MEASUREMENT in measurement query for non-empty query with no tags', () => { const builder = new InfluxQueryBuilder({ measurement: '', tags: [] }); const query = builder.buildExploreQuery('MEASUREMENTS', undefined, 'something'); expect(query).toBe('SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/ LIMIT 100'); }); - it('should have WITH MEASUREMENT WHERE in measurement query for non-empty query with tags', function() { + it('should have WITH MEASUREMENT WHERE in measurement query for non-empty query with tags', () => { const builder = new InfluxQueryBuilder({ measurement: '', tags: [{ key: 'app', value: 'email' }], @@ -59,7 +59,7 @@ describe('InfluxQueryBuilder', function() { expect(query).toBe('SHOW MEASUREMENTS WITH MEASUREMENT =~ /something/ WHERE "app" = \'email\' LIMIT 100'); }); - it('should have where condition in measurement query for query with tags', function() { + it('should have where condition in measurement query for query with tags', () => { const builder = new InfluxQueryBuilder({ measurement: '', tags: [{ key: 'app', value: 'email' }], @@ -68,7 +68,7 @@ describe('InfluxQueryBuilder', function() { expect(query).toBe('SHOW MEASUREMENTS WHERE "app" = \'email\' LIMIT 100'); }); - it('should have where tag name IN filter in tag values query for query with one tag', function() { + it('should have where tag name IN filter in tag values query for query with one tag', () => { const builder = new InfluxQueryBuilder({ measurement: '', tags: [{ key: 'app', value: 'asdsadsad' }], @@ -77,7 +77,7 @@ describe('InfluxQueryBuilder', function() { expect(query).toBe('SHOW TAG VALUES WITH KEY = "app"'); }); - it('should have measurement tag condition and tag name IN filter in tag values query', function() { + it('should have measurement tag condition and tag name IN filter in tag values query', () => { const builder = new InfluxQueryBuilder({ measurement: 'cpu', tags: [{ key: 'app', value: 'email' }, { key: 'host', value: 'server1' }], @@ -86,7 +86,7 @@ describe('InfluxQueryBuilder', function() { expect(query).toBe('SHOW TAG VALUES FROM "cpu" WITH KEY = "app" WHERE "host" = \'server1\''); }); - it('should select from policy correctly if policy is specified', function() { + it('should select from policy correctly if policy is specified', () => { const builder = new InfluxQueryBuilder({ measurement: 'cpu', policy: 'one_week', @@ -96,7 +96,7 @@ describe('InfluxQueryBuilder', function() { expect(query).toBe('SHOW TAG VALUES FROM "one_week"."cpu" WITH KEY = "app" WHERE "host" = \'server1\''); }); - it('should not include policy when policy is default', function() { + it('should not include policy when policy is default', () => { const builder = new InfluxQueryBuilder({ measurement: 'cpu', policy: 'default', @@ -106,7 +106,7 @@ describe('InfluxQueryBuilder', function() { expect(query).toBe('SHOW TAG VALUES FROM "cpu" WITH KEY = "app"'); }); - it('should switch to regex operator in tag condition', function() { + it('should switch to regex operator in tag condition', () => { const builder = new InfluxQueryBuilder({ measurement: 'cpu', tags: [{ key: 'host', value: '/server.*/' }], @@ -115,7 +115,7 @@ describe('InfluxQueryBuilder', function() { expect(query).toBe('SHOW TAG VALUES FROM "cpu" WITH KEY = "app" WHERE "host" =~ /server.*/'); }); - it('should build show field query', function() { + it('should build show field query', () => { const builder = new InfluxQueryBuilder({ measurement: 'cpu', tags: [{ key: 'app', value: 'email' }], @@ -124,7 +124,7 @@ describe('InfluxQueryBuilder', function() { expect(query).toBe('SHOW FIELD KEYS FROM "cpu"'); }); - it('should build show field query with regexp', function() { + it('should build show field query with regexp', () => { const builder = new InfluxQueryBuilder({ measurement: '/$var/', tags: [{ key: 'app', value: 'email' }], @@ -133,7 +133,7 @@ describe('InfluxQueryBuilder', function() { expect(query).toBe('SHOW FIELD KEYS FROM /$var/'); }); - it('should build show retention policies query', function() { + it('should build show retention policies query', () => { const builder = new InfluxQueryBuilder({ measurement: 'cpu', tags: [] }, 'site'); const query = builder.buildExploreQuery('RETENTION POLICIES'); expect(query).toBe('SHOW RETENTION POLICIES on "site"'); diff --git a/public/app/plugins/datasource/mssql/specs/datasource.test.ts b/public/app/plugins/datasource/mssql/specs/datasource.test.ts index 0308717775b..0dd496bfe59 100644 --- a/public/app/plugins/datasource/mssql/specs/datasource.test.ts +++ b/public/app/plugins/datasource/mssql/specs/datasource.test.ts @@ -4,20 +4,20 @@ import { TemplateSrvStub } from 'test/specs/helpers'; import { CustomVariable } from 'app/features/templating/custom_variable'; import q from 'q'; -describe('MSSQLDatasource', function() { +describe('MSSQLDatasource', () => { const ctx: any = { backendSrv: {}, templateSrv: new TemplateSrvStub(), }; - beforeEach(function() { + beforeEach(() => { ctx.$q = q; ctx.instanceSettings = { name: 'mssql' }; ctx.ds = new MssqlDatasource(ctx.instanceSettings, ctx.backendSrv, ctx.$q, ctx.templateSrv); }); - describe('When performing annotationQuery', function() { + describe('When performing annotationQuery', () => { let results; const annotationName = 'MyAnno'; @@ -61,7 +61,7 @@ describe('MSSQLDatasource', function() { }); }); - it('should return annotation list', function() { + it('should return annotation list', () => { expect(results.length).toBe(3); expect(results[0].text).toBe('some text'); @@ -75,7 +75,7 @@ describe('MSSQLDatasource', function() { }); }); - describe('When performing metricFindQuery', function() { + describe('When performing metricFindQuery', () => { let results; const query = 'select * from atable'; const response = { @@ -95,24 +95,24 @@ describe('MSSQLDatasource', function() { }, }; - beforeEach(function() { - ctx.backendSrv.datasourceRequest = function(options) { + beforeEach(() => { + ctx.backendSrv.datasourceRequest = options => { return ctx.$q.when({ data: response, status: 200 }); }; - return ctx.ds.metricFindQuery(query).then(function(data) { + return ctx.ds.metricFindQuery(query).then(data => { results = data; }); }); - it('should return list of all column values', function() { + it('should return list of all column values', () => { expect(results.length).toBe(6); expect(results[0].text).toBe('aTitle'); expect(results[5].text).toBe('some text3'); }); }); - describe('When performing metricFindQuery with key, value columns', function() { + describe('When performing metricFindQuery with key, value columns', () => { let results; const query = 'select * from atable'; const response = { @@ -132,17 +132,17 @@ describe('MSSQLDatasource', function() { }, }; - beforeEach(function() { - ctx.backendSrv.datasourceRequest = function(options) { + beforeEach(() => { + ctx.backendSrv.datasourceRequest = options => { return ctx.$q.when({ data: response, status: 200 }); }; - return ctx.ds.metricFindQuery(query).then(function(data) { + return ctx.ds.metricFindQuery(query).then(data => { results = data; }); }); - it('should return list of as text, value', function() { + it('should return list of as text, value', () => { expect(results.length).toBe(3); expect(results[0].text).toBe('aTitle'); expect(results[0].value).toBe('value1'); @@ -151,7 +151,7 @@ describe('MSSQLDatasource', function() { }); }); - describe('When performing metricFindQuery with key, value columns and with duplicate keys', function() { + describe('When performing metricFindQuery with key, value columns and with duplicate keys', () => { let results; const query = 'select * from atable'; const response = { @@ -171,17 +171,17 @@ describe('MSSQLDatasource', function() { }, }; - beforeEach(function() { - ctx.backendSrv.datasourceRequest = function(options) { + beforeEach(() => { + ctx.backendSrv.datasourceRequest = options => { return ctx.$q.when({ data: response, status: 200 }); }; - return ctx.ds.metricFindQuery(query).then(function(data) { + return ctx.ds.metricFindQuery(query).then(data => { results = data; }); }); - it('should return list of unique keys', function() { + it('should return list of unique keys', () => { expect(results.length).toBe(1); expect(results[0].text).toBe('aTitle'); expect(results[0].value).toBe('same'); @@ -189,7 +189,7 @@ describe('MSSQLDatasource', function() { }); describe('When interpolating variables', () => { - beforeEach(function() { + beforeEach(() => { ctx.variable = new CustomVariable({}, {}); }); diff --git a/public/app/plugins/datasource/mysql/specs/datasource.test.ts b/public/app/plugins/datasource/mysql/specs/datasource.test.ts index 0990be6f21c..2cd9b189ec0 100644 --- a/public/app/plugins/datasource/mysql/specs/datasource.test.ts +++ b/public/app/plugins/datasource/mysql/specs/datasource.test.ts @@ -2,7 +2,7 @@ import moment from 'moment'; import { MysqlDatasource } from '../datasource'; import { CustomVariable } from 'app/features/templating/custom_variable'; -describe('MySQLDatasource', function() { +describe('MySQLDatasource', () => { const instanceSettings = { name: 'mysql' }; const backendSrv = {}; const templateSrv = { @@ -17,7 +17,7 @@ describe('MySQLDatasource', function() { ctx.ds = new MysqlDatasource(instanceSettings, backendSrv, {}, templateSrv); }); - describe('When performing annotationQuery', function() { + describe('When performing annotationQuery', () => { let results; const annotationName = 'MyAnno'; @@ -51,16 +51,16 @@ describe('MySQLDatasource', function() { }, }; - beforeEach(function() { + beforeEach(() => { ctx.backendSrv.datasourceRequest = jest.fn(options => { return Promise.resolve({ data: response, status: 200 }); }); - ctx.ds.annotationQuery(options).then(function(data) { + ctx.ds.annotationQuery(options).then(data => { results = data; }); }); - it('should return annotation list', function() { + it('should return annotation list', () => { expect(results.length).toBe(3); expect(results[0].text).toBe('some text'); @@ -74,7 +74,7 @@ describe('MySQLDatasource', function() { }); }); - describe('When performing metricFindQuery', function() { + describe('When performing metricFindQuery', () => { let results; const query = 'select * from atable'; const response = { @@ -94,23 +94,23 @@ describe('MySQLDatasource', function() { }, }; - beforeEach(function() { + beforeEach(() => { ctx.backendSrv.datasourceRequest = jest.fn(options => { return Promise.resolve({ data: response, status: 200 }); }); - ctx.ds.metricFindQuery(query).then(function(data) { + ctx.ds.metricFindQuery(query).then(data => { results = data; }); }); - it('should return list of all column values', function() { + it('should return list of all column values', () => { expect(results.length).toBe(6); expect(results[0].text).toBe('aTitle'); expect(results[5].text).toBe('some text3'); }); }); - describe('When performing metricFindQuery with key, value columns', function() { + describe('When performing metricFindQuery with key, value columns', () => { let results; const query = 'select * from atable'; const response = { @@ -130,16 +130,16 @@ describe('MySQLDatasource', function() { }, }; - beforeEach(function() { + beforeEach(() => { ctx.backendSrv.datasourceRequest = jest.fn(options => { return Promise.resolve({ data: response, status: 200 }); }); - ctx.ds.metricFindQuery(query).then(function(data) { + ctx.ds.metricFindQuery(query).then(data => { results = data; }); }); - it('should return list of as text, value', function() { + it('should return list of as text, value', () => { expect(results.length).toBe(3); expect(results[0].text).toBe('aTitle'); expect(results[0].value).toBe('value1'); @@ -148,7 +148,7 @@ describe('MySQLDatasource', function() { }); }); - describe('When performing metricFindQuery with key, value columns and with duplicate keys', function() { + describe('When performing metricFindQuery with key, value columns and with duplicate keys', () => { let results; const query = 'select * from atable'; const response = { @@ -168,16 +168,16 @@ describe('MySQLDatasource', function() { }, }; - beforeEach(function() { + beforeEach(() => { ctx.backendSrv.datasourceRequest = jest.fn(options => { return Promise.resolve({ data: response, status: 200 }); }); - ctx.ds.metricFindQuery(query).then(function(data) { + ctx.ds.metricFindQuery(query).then(data => { results = data; }); }); - it('should return list of unique keys', function() { + it('should return list of unique keys', () => { expect(results.length).toBe(1); expect(results[0].text).toBe('aTitle'); expect(results[0].value).toBe('same'); @@ -185,7 +185,7 @@ describe('MySQLDatasource', function() { }); describe('When interpolating variables', () => { - beforeEach(function() { + beforeEach(() => { ctx.variable = new CustomVariable({}, {}); }); diff --git a/public/app/plugins/datasource/postgres/specs/datasource.test.ts b/public/app/plugins/datasource/postgres/specs/datasource.test.ts index 67ba6872b0d..49541028caf 100644 --- a/public/app/plugins/datasource/postgres/specs/datasource.test.ts +++ b/public/app/plugins/datasource/postgres/specs/datasource.test.ts @@ -2,7 +2,7 @@ import moment from 'moment'; import { PostgresDatasource } from '../datasource'; import { CustomVariable } from 'app/features/templating/custom_variable'; -describe('PostgreSQLDatasource', function() { +describe('PostgreSQLDatasource', () => { const instanceSettings = { name: 'postgresql' }; const backendSrv = {}; @@ -28,7 +28,7 @@ describe('PostgreSQLDatasource', function() { ctx.ds = new PostgresDatasource(instanceSettings, backendSrv, {}, templateSrv, ctx.timeSrvMock); }); - describe('When performing annotationQuery', function() { + describe('When performing annotationQuery', () => { let results; const annotationName = 'MyAnno'; @@ -62,16 +62,16 @@ describe('PostgreSQLDatasource', function() { }, }; - beforeEach(function() { + beforeEach(() => { ctx.backendSrv.datasourceRequest = jest.fn(options => { return Promise.resolve({ data: response, status: 200 }); }); - ctx.ds.annotationQuery(options).then(function(data) { + ctx.ds.annotationQuery(options).then(data => { results = data; }); }); - it('should return annotation list', function() { + it('should return annotation list', () => { expect(results.length).toBe(3); expect(results[0].text).toBe('some text'); @@ -85,7 +85,7 @@ describe('PostgreSQLDatasource', function() { }); }); - describe('When performing metricFindQuery', function() { + describe('When performing metricFindQuery', () => { let results; const query = 'select * from atable'; const response = { @@ -105,23 +105,23 @@ describe('PostgreSQLDatasource', function() { }, }; - beforeEach(function() { + beforeEach(() => { ctx.backendSrv.datasourceRequest = jest.fn(options => { return Promise.resolve({ data: response, status: 200 }); }); - ctx.ds.metricFindQuery(query).then(function(data) { + ctx.ds.metricFindQuery(query).then(data => { results = data; }); }); - it('should return list of all column values', function() { + it('should return list of all column values', () => { expect(results.length).toBe(6); expect(results[0].text).toBe('aTitle'); expect(results[5].text).toBe('some text3'); }); }); - describe('When performing metricFindQuery with key, value columns', function() { + describe('When performing metricFindQuery with key, value columns', () => { let results; const query = 'select * from atable'; const response = { @@ -141,16 +141,16 @@ describe('PostgreSQLDatasource', function() { }, }; - beforeEach(function() { + beforeEach(() => { ctx.backendSrv.datasourceRequest = jest.fn(options => { return Promise.resolve({ data: response, status: 200 }); }); - ctx.ds.metricFindQuery(query).then(function(data) { + ctx.ds.metricFindQuery(query).then(data => { results = data; }); }); - it('should return list of as text, value', function() { + it('should return list of as text, value', () => { expect(results.length).toBe(3); expect(results[0].text).toBe('aTitle'); expect(results[0].value).toBe('value1'); @@ -159,7 +159,7 @@ describe('PostgreSQLDatasource', function() { }); }); - describe('When performing metricFindQuery with key, value columns and with duplicate keys', function() { + describe('When performing metricFindQuery with key, value columns and with duplicate keys', () => { let results; const query = 'select * from atable'; const response = { @@ -183,13 +183,13 @@ describe('PostgreSQLDatasource', function() { ctx.backendSrv.datasourceRequest = jest.fn(options => { return Promise.resolve({ data: response, status: 200 }); }); - ctx.ds.metricFindQuery(query).then(function(data) { + ctx.ds.metricFindQuery(query).then(data => { results = data; }); //ctx.$rootScope.$apply(); }); - it('should return list of unique keys', function() { + it('should return list of unique keys', () => { expect(results.length).toBe(1); expect(results[0].text).toBe('aTitle'); expect(results[0].value).toBe('same'); @@ -197,7 +197,7 @@ describe('PostgreSQLDatasource', function() { }); describe('When interpolating variables', () => { - beforeEach(function() { + beforeEach(() => { ctx.variable = new CustomVariable({}, {}); }); diff --git a/public/app/plugins/datasource/prometheus/specs/completer.test.ts b/public/app/plugins/datasource/prometheus/specs/completer.test.ts index 05952e1dc4a..36765ef708b 100644 --- a/public/app/plugins/datasource/prometheus/specs/completer.test.ts +++ b/public/app/plugins/datasource/prometheus/specs/completer.test.ts @@ -4,7 +4,7 @@ import { BackendSrv } from 'app/core/services/backend_srv'; jest.mock('../datasource'); jest.mock('app/core/services/backend_srv'); -describe('Prometheus editor completer', function() { +describe('Prometheus editor completer', () => { function getSessionStub(data) { return { getTokenAt: jest.fn(() => data.currentToken), diff --git a/public/app/plugins/datasource/prometheus/specs/datasource.test.ts b/public/app/plugins/datasource/prometheus/specs/datasource.test.ts index 35d13684240..064f1bc1818 100644 --- a/public/app/plugins/datasource/prometheus/specs/datasource.test.ts +++ b/public/app/plugins/datasource/prometheus/specs/datasource.test.ts @@ -437,7 +437,7 @@ describe('PrometheusDatasource', () => { backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); - await ctx.ds.query(query).then(function(data) { + await ctx.ds.query(query).then(data => { results = data; }); }); @@ -487,7 +487,7 @@ describe('PrometheusDatasource', () => { backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); - await ctx.ds.query(query).then(function(data) { + await ctx.ds.query(query).then(data => { results = data; }); }); @@ -548,7 +548,7 @@ describe('PrometheusDatasource', () => { backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); - await ctx.ds.query(query).then(function(data) { + await ctx.ds.query(query).then(data => { results = data; }); }); @@ -603,7 +603,7 @@ describe('PrometheusDatasource', () => { backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); - await ctx.ds.annotationQuery(options).then(function(data) { + await ctx.ds.annotationQuery(options).then(data => { results = data; }); }); @@ -642,7 +642,7 @@ describe('PrometheusDatasource', () => { backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); - await ctx.ds.query(query).then(function(data) { + await ctx.ds.query(query).then(data => { results = data; }); }); @@ -1156,7 +1156,7 @@ describe('PrometheusDatasource for POST', () => { }; backendSrv.datasourceRequest = jest.fn(() => Promise.resolve(response)); ctx.ds = new PrometheusDatasource(instanceSettings, q, backendSrv as any, templateSrv, timeSrv); - await ctx.ds.query(query).then(function(data) { + await ctx.ds.query(query).then(data => { results = data; }); }); diff --git a/public/app/plugins/datasource/prometheus/specs/metric_find_query.test.ts b/public/app/plugins/datasource/prometheus/specs/metric_find_query.test.ts index bfbf241ba06..1466bd8ac96 100644 --- a/public/app/plugins/datasource/prometheus/specs/metric_find_query.test.ts +++ b/public/app/plugins/datasource/prometheus/specs/metric_find_query.test.ts @@ -3,7 +3,7 @@ import { PrometheusDatasource } from '../datasource'; import PrometheusMetricFindQuery from '../metric_find_query'; import q from 'q'; -describe('PrometheusMetricFindQuery', function() { +describe('PrometheusMetricFindQuery', () => { const instanceSettings = { url: 'proxied', directUrl: 'direct', diff --git a/public/app/plugins/panel/graph/specs/align_yaxes.test.ts b/public/app/plugins/panel/graph/specs/align_yaxes.test.ts index da3aff91275..d87de91fdd5 100644 --- a/public/app/plugins/panel/graph/specs/align_yaxes.test.ts +++ b/public/app/plugins/panel/graph/specs/align_yaxes.test.ts @@ -1,6 +1,6 @@ import { alignYLevel } from '../align_yaxes'; -describe('Graph Y axes aligner', function() { +describe('Graph Y axes aligner', () => { let yaxes, expected; let alignY = 0; diff --git a/public/app/plugins/panel/graph/specs/data_processor.test.ts b/public/app/plugins/panel/graph/specs/data_processor.test.ts index 2e8d4eb6eab..b919bb0f3b1 100644 --- a/public/app/plugins/panel/graph/specs/data_processor.test.ts +++ b/public/app/plugins/panel/graph/specs/data_processor.test.ts @@ -1,6 +1,6 @@ import { DataProcessor } from '../data_processor'; -describe('Graph DataProcessor', function() { +describe('Graph DataProcessor', () => { const panel: any = { xaxis: {}, }; diff --git a/public/app/plugins/panel/graph/specs/graph.test.ts b/public/app/plugins/panel/graph/specs/graph.test.ts index 037a02a5bf0..d86e860b27d 100644 --- a/public/app/plugins/panel/graph/specs/graph.test.ts +++ b/public/app/plugins/panel/graph/specs/graph.test.ts @@ -1,5 +1,5 @@ jest.mock('app/features/annotations/all', () => ({ - EventManager: function() { + EventManager: () => { return { on: () => {}, addFlotEvents: () => {}, @@ -40,7 +40,7 @@ const scope = { }; let link; -describe('grafanaGraph', function() { +describe('grafanaGraph', () => { const setupCtx = (beforeRender?) => { config.bootData = { user: { @@ -242,7 +242,7 @@ describe('grafanaGraph', function() { }); }); - it('should apply axis transform, autoscaling (if necessary) and ticks', function() { + it('should apply axis transform, autoscaling (if necessary) and ticks', () => { const axisAutoscale = ctx.plotOptions.yaxes[0]; expect(axisAutoscale.transform(100)).toBe(2); expect(axisAutoscale.inverseTransform(-3)).toBeCloseTo(0.001); @@ -277,7 +277,7 @@ describe('grafanaGraph', function() { }); }); - it('should not set min and max and should create some fake ticks', function() { + it('should not set min and max and should create some fake ticks', () => { const axisAutoscale = ctx.plotOptions.yaxes[0]; expect(axisAutoscale.transform(100)).toBe(2); expect(axisAutoscale.inverseTransform(-3)).toBeCloseTo(0.001); @@ -303,7 +303,7 @@ describe('grafanaGraph', function() { ctx.data[0].yaxis = 1; }); }); - it('should set min to 0.1 and add a tick for 0.1', function() { + it('should set min to 0.1 and add a tick for 0.1', () => { const axisAutoscale = ctx.plotOptions.yaxes[0]; expect(axisAutoscale.transform(100)).toBe(2); expect(axisAutoscale.inverseTransform(-3)).toBeCloseTo(0.001); @@ -330,7 +330,7 @@ describe('grafanaGraph', function() { }); }); - it('should regenerate ticks so that if fits on the y-axis', function() { + it('should regenerate ticks so that if fits on the y-axis', () => { const axisAutoscale = ctx.plotOptions.yaxes[0]; expect(axisAutoscale.min).toBe(0.1); expect(axisAutoscale.ticks.length).toBe(8); @@ -339,7 +339,7 @@ describe('grafanaGraph', function() { expect(axisAutoscale.max).toBe(262144); }); - it('should set axis max to be max tick value', function() { + it('should set axis max to be max tick value', () => { expect(ctx.plotOptions.yaxes[0].max).toBe(262144); }); }); @@ -353,7 +353,7 @@ describe('grafanaGraph', function() { }); }); - it('should configure dashed plot with correct options', function() { + it('should configure dashed plot with correct options', () => { expect(ctx.plotOptions.series.lines.show).toBe(true); expect(ctx.plotOptions.series.dashes.lineWidth).toBe(2); expect(ctx.plotOptions.series.dashes.show).toBe(true); @@ -371,7 +371,7 @@ describe('grafanaGraph', function() { }); }); - it('should set barWidth', function() { + it('should set barWidth', () => { expect(ctx.plotOptions.series.bars.barWidth).toBe(1 / 1.5); }); }); @@ -388,7 +388,7 @@ describe('grafanaGraph', function() { }); }); - it('should match second series and fill zero, and enable points', function() { + it('should match second series and fill zero, and enable points', () => { expect(ctx.plotOptions.series.lines.fill).toBe(0.5); expect(ctx.plotData[1].lines.fill).toBe(0.001); expect(ctx.plotData[1].points.show).toBe(true); @@ -403,7 +403,7 @@ describe('grafanaGraph', function() { }); }); - it('should move zindex 2 last', function() { + it('should move zindex 2 last', () => { expect(ctx.plotData[0].alias).toBe('series2'); expect(ctx.plotData[1].alias).toBe('series1'); }); @@ -416,7 +416,7 @@ describe('grafanaGraph', function() { }); }); - it('should remove datapoints and disable stack', function() { + it('should remove datapoints and disable stack', () => { expect(ctx.plotData[0].alias).toBe('series1'); expect(ctx.plotData[1].data.length).toBe(0); expect(ctx.plotData[1].stack).toBe(false); @@ -431,7 +431,7 @@ describe('grafanaGraph', function() { }); }); - it('should show percentage', function() { + it('should show percentage', () => { const axis = ctx.plotOptions.yaxes[0]; expect(axis.tickFormatter(100, axis)).toBe('100%'); }); @@ -439,7 +439,7 @@ describe('grafanaGraph', function() { describe('when panel too narrow to show x-axis dates in same granularity as wide panels', () => { //Set width to 10px - describe('and the range is less than 24 hours', function() { + describe('and the range is less than 24 hours', () => { beforeEach(() => { setupCtx(() => { ctrl.range.from = moment([2015, 1, 1, 10]); @@ -447,13 +447,13 @@ describe('grafanaGraph', function() { }); }); - it('should format dates as hours minutes', function() { + it('should format dates as hours minutes', () => { const axis = ctx.plotOptions.xaxis; expect(axis.timeformat).toBe('%H:%M'); }); }); - describe('and the range is less than one year', function() { + describe('and the range is less than one year', () => { beforeEach(() => { setupCtx(() => { ctrl.range.from = moment([2015, 1, 1]); @@ -461,7 +461,7 @@ describe('grafanaGraph', function() { }); }); - it('should format dates as month days', function() { + it('should format dates as month days', () => { const axis = ctx.plotOptions.xaxis; expect(axis.timeformat).toBe('%m/%d'); }); @@ -485,7 +485,7 @@ describe('grafanaGraph', function() { }); }); - it('should calculate correct histogram', function() { + it('should calculate correct histogram', () => { expect(ctx.plotData[0].data[0][0]).toBe(100); expect(ctx.plotData[0].data[0][1]).toBe(2); expect(ctx.plotData[1].data[0][0]).toBe(100); @@ -510,7 +510,7 @@ describe('grafanaGraph', function() { }); }); - it('should calculate correct histogram', function() { + it('should calculate correct histogram', () => { expect(ctx.plotData[0].data[0][0]).toBe(100); expect(ctx.plotData[0].data[0][1]).toBe(2); }); diff --git a/public/app/plugins/panel/graph/specs/graph_tooltip.test.ts b/public/app/plugins/panel/graph/specs/graph_tooltip.test.ts index ecc6ce0fb21..00a3cf0dcf1 100644 --- a/public/app/plugins/panel/graph/specs/graph_tooltip.test.ts +++ b/public/app/plugins/panel/graph/specs/graph_tooltip.test.ts @@ -24,12 +24,12 @@ function describeSharedTooltip(desc, fn) { stack: false, }; - ctx.setup = function(setupFn) { + ctx.setup = setupFn => { ctx.setupFn = setupFn; }; - describe(desc, function() { - beforeEach(function() { + describe(desc, () => { + beforeEach(() => { ctx.setupFn(); const tooltip = new GraphTooltip(elem, dashboard, scope, getSeriesFn); ctx.results = tooltip.getMultiSeriesPlotHoverInfo(ctx.data, ctx.pos); @@ -39,35 +39,35 @@ function describeSharedTooltip(desc, fn) { }); } -describe('findHoverIndexFromData', function() { +describe('findHoverIndexFromData', () => { const tooltip = new GraphTooltip(elem, dashboard, scope, getSeriesFn); const series = { data: [[100, 0], [101, 0], [102, 0], [103, 0], [104, 0], [105, 0], [106, 0], [107, 0]], }; - it('should return 0 if posX out of lower bounds', function() { + it('should return 0 if posX out of lower bounds', () => { const posX = 99; expect(tooltip.findHoverIndexFromData(posX, series)).toBe(0); }); - it('should return n - 1 if posX out of upper bounds', function() { + it('should return n - 1 if posX out of upper bounds', () => { const posX = 108; expect(tooltip.findHoverIndexFromData(posX, series)).toBe(series.data.length - 1); }); - it('should return i if posX in series', function() { + it('should return i if posX in series', () => { const posX = 104; expect(tooltip.findHoverIndexFromData(posX, series)).toBe(4); }); - it('should return i if posX not in series and i + 1 > posX', function() { + it('should return i if posX not in series and i + 1 > posX', () => { const posX = 104.9; expect(tooltip.findHoverIndexFromData(posX, series)).toBe(4); }); }); -describeSharedTooltip('steppedLine false, stack false', function(ctx) { - ctx.setup(function() { +describeSharedTooltip('steppedLine false, stack false', ctx => { + ctx.setup(() => { ctx.data = [ { data: [[10, 15], [12, 20]], lines: {}, hideTooltip: false }, { data: [[10, 2], [12, 3]], lines: {}, hideTooltip: false }, @@ -75,30 +75,30 @@ describeSharedTooltip('steppedLine false, stack false', function(ctx) { ctx.pos = { x: 11 }; }); - it('should return 2 series', function() { + it('should return 2 series', () => { expect(ctx.results.length).toBe(2); }); - it('should add time to results array', function() { + it('should add time to results array', () => { expect(ctx.results.time).toBe(10); }); - it('should set value and hoverIndex', function() { + it('should set value and hoverIndex', () => { expect(ctx.results[0].value).toBe(15); expect(ctx.results[1].value).toBe(2); expect(ctx.results[0].hoverIndex).toBe(0); }); }); -describeSharedTooltip('one series is hidden', function(ctx) { - ctx.setup(function() { +describeSharedTooltip('one series is hidden', ctx => { + ctx.setup(() => { ctx.data = [{ data: [[10, 15], [12, 20]] }, { data: [] }]; ctx.pos = { x: 11 }; }); }); -describeSharedTooltip('steppedLine false, stack true, individual false', function(ctx) { - ctx.setup(function() { +describeSharedTooltip('steppedLine false, stack true, individual false', ctx => { + ctx.setup(() => { ctx.data = [ { data: [[10, 15], [12, 20]], @@ -125,13 +125,13 @@ describeSharedTooltip('steppedLine false, stack true, individual false', functio ctx.pos = { x: 11 }; }); - it('should show stacked value', function() { + it('should show stacked value', () => { expect(ctx.results[1].value).toBe(17); }); }); -describeSharedTooltip('steppedLine false, stack true, individual false, series stack false', function(ctx) { - ctx.setup(function() { +describeSharedTooltip('steppedLine false, stack true, individual false, series stack false', ctx => { + ctx.setup(() => { ctx.data = [ { data: [[10, 15], [12, 20]], @@ -158,13 +158,13 @@ describeSharedTooltip('steppedLine false, stack true, individual false, series s ctx.pos = { x: 11 }; }); - it('should not show stacked value', function() { + it('should not show stacked value', () => { expect(ctx.results[1].value).toBe(2); }); }); -describeSharedTooltip('steppedLine false, stack true, individual true', function(ctx) { - ctx.setup(function() { +describeSharedTooltip('steppedLine false, stack true, individual true', ctx => { + ctx.setup(() => { ctx.data = [ { data: [[10, 15], [12, 20]], @@ -192,7 +192,7 @@ describeSharedTooltip('steppedLine false, stack true, individual true', function ctx.pos = { x: 11 }; }); - it('should not show stacked value', function() { + it('should not show stacked value', () => { expect(ctx.results[1].value).toBe(2); }); }); diff --git a/public/app/plugins/panel/graph/specs/histogram.test.ts b/public/app/plugins/panel/graph/specs/histogram.test.ts index adbc0fcba68..d6b8527910b 100644 --- a/public/app/plugins/panel/graph/specs/histogram.test.ts +++ b/public/app/plugins/panel/graph/specs/histogram.test.ts @@ -1,6 +1,6 @@ import { convertValuesToHistogram, getSeriesValues } from '../histogram'; -describe('Graph Histogam Converter', function() { +describe('Graph Histogam Converter', () => { describe('Values to histogram converter', () => { let values; let bucketSize = 10; diff --git a/public/app/plugins/panel/graph/specs/threshold_manager.test.ts b/public/app/plugins/panel/graph/specs/threshold_manager.test.ts index ecbc382923e..bbeaf1b993a 100644 --- a/public/app/plugins/panel/graph/specs/threshold_manager.test.ts +++ b/public/app/plugins/panel/graph/specs/threshold_manager.test.ts @@ -2,9 +2,9 @@ import angular from 'angular'; import TimeSeries from 'app/core/time_series2'; import { ThresholdManager } from '../threshold_manager'; -describe('ThresholdManager', function() { +describe('ThresholdManager', () => { function plotOptionsScenario(desc, func) { - describe(desc, function() { + describe(desc, () => { const ctx: any = { panel: { thresholds: [], @@ -15,7 +15,7 @@ describe('ThresholdManager', function() { panelCtrl: {}, }; - ctx.setup = function(thresholds, data) { + ctx.setup = (thresholds, data) => { ctx.panel.thresholds = thresholds; const manager = new ThresholdManager(ctx.panelCtrl); if (data !== undefined) { @@ -33,7 +33,7 @@ describe('ThresholdManager', function() { plotOptionsScenario('for simple gt threshold', ctx => { ctx.setup([{ op: 'gt', value: 300, fill: true, line: true, colorMode: 'critical' }]); - it('should add fill for threshold with fill: true', function() { + it('should add fill for threshold with fill: true', () => { const markings = ctx.options.grid.markings; expect(markings[0].yaxis.from).toBe(300); @@ -41,7 +41,7 @@ describe('ThresholdManager', function() { expect(markings[0].color).toBe('rgba(234, 112, 112, 0.12)'); }); - it('should add line', function() { + it('should add line', () => { const markings = ctx.options.grid.markings; expect(markings[1].yaxis.from).toBe(300); expect(markings[1].yaxis.to).toBe(300); @@ -55,13 +55,13 @@ describe('ThresholdManager', function() { { op: 'gt', value: 300, fill: true, colorMode: 'critical' }, ]); - it('should add fill for first thresholds to next threshold', function() { + it('should add fill for first thresholds to next threshold', () => { const markings = ctx.options.grid.markings; expect(markings[0].yaxis.from).toBe(200); expect(markings[0].yaxis.to).toBe(300); }); - it('should add fill for last thresholds to infinity', function() { + it('should add fill for last thresholds to infinity', () => { const markings = ctx.options.grid.markings; expect(markings[1].yaxis.from).toBe(300); expect(markings[1].yaxis.to).toBe(Infinity); @@ -74,13 +74,13 @@ describe('ThresholdManager', function() { { op: 'gt', value: 200, fill: true, colorMode: 'critical' }, ]); - it('should add fill for first thresholds to next threshold', function() { + it('should add fill for first thresholds to next threshold', () => { const markings = ctx.options.grid.markings; expect(markings[0].yaxis.from).toBe(300); expect(markings[0].yaxis.to).toBe(200); }); - it('should add fill for last thresholds to itself', function() { + it('should add fill for last thresholds to itself', () => { const markings = ctx.options.grid.markings; expect(markings[1].yaxis.from).toBe(200); expect(markings[1].yaxis.to).toBe(200); @@ -93,13 +93,13 @@ describe('ThresholdManager', function() { { op: 'lt', value: 200, fill: true, colorMode: 'critical' }, ]); - it('should add fill for first thresholds to next threshold', function() { + it('should add fill for first thresholds to next threshold', () => { const markings = ctx.options.grid.markings; expect(markings[0].yaxis.from).toBe(300); expect(markings[0].yaxis.to).toBe(Infinity); }); - it('should add fill for last thresholds to itself', function() { + it('should add fill for last thresholds to itself', () => { const markings = ctx.options.grid.markings; expect(markings[1].yaxis.from).toBe(200); expect(markings[1].yaxis.to).toBe(-Infinity); @@ -126,12 +126,12 @@ describe('ThresholdManager', function() { data ); - it('should add first threshold for left axis', function() { + it('should add first threshold for left axis', () => { const markings = ctx.options.grid.markings; expect(markings[0].yaxis.from).toBe(100); }); - it('should add second threshold for right axis', function() { + it('should add second threshold for right axis', () => { const markings = ctx.options.grid.markings; expect(markings[1].y2axis.from).toBe(200); }); diff --git a/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.test.ts b/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.test.ts index 740d4045013..a51be8eb723 100644 --- a/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.test.ts +++ b/public/app/plugins/panel/heatmap/specs/heatmap_ctrl.test.ts @@ -1,7 +1,7 @@ import moment from 'moment'; import { HeatmapCtrl } from '../heatmap_ctrl'; -describe('HeatmapCtrl', function() { +describe('HeatmapCtrl', () => { const ctx = {} as any; const $injector = { @@ -23,8 +23,8 @@ describe('HeatmapCtrl', function() { ctx.ctrl = new HeatmapCtrl($scope, $injector, {}); }); - describe('when time series are outside range', function() { - beforeEach(function() { + describe('when time series are outside range', () => { + beforeEach(() => { const data = [ { target: 'test.cpu1', @@ -36,13 +36,13 @@ describe('HeatmapCtrl', function() { ctx.ctrl.onDataReceived(data); }); - it('should set datapointsOutside', function() { + it('should set datapointsOutside', () => { expect(ctx.ctrl.dataWarning.title).toBe('Data points outside time range'); }); }); - describe('when time series are inside range', function() { - beforeEach(function() { + describe('when time series are inside range', () => { + beforeEach(() => { const range = { from: moment() .subtract(1, 'days') @@ -61,18 +61,18 @@ describe('HeatmapCtrl', function() { ctx.ctrl.onDataReceived(data); }); - it('should set datapointsOutside', function() { + it('should set datapointsOutside', () => { expect(ctx.ctrl.dataWarning).toBe(null); }); }); - describe('datapointsCount given 2 series', function() { - beforeEach(function() { + describe('datapointsCount given 2 series', () => { + beforeEach(() => { const data = [{ target: 'test.cpu1', datapoints: [] }, { target: 'test.cpu2', datapoints: [] }]; ctx.ctrl.onDataReceived(data); }); - it('should set datapointsCount warning', function() { + it('should set datapointsCount warning', () => { expect(ctx.ctrl.dataWarning.title).toBe('No data points'); }); }); diff --git a/public/app/plugins/panel/singlestat/specs/singlestat.test.ts b/public/app/plugins/panel/singlestat/specs/singlestat.test.ts index bacc972c058..6003acd89a6 100644 --- a/public/app/plugins/panel/singlestat/specs/singlestat.test.ts +++ b/public/app/plugins/panel/singlestat/specs/singlestat.test.ts @@ -1,7 +1,7 @@ import { SingleStatCtrl } from '../module'; import moment from 'moment'; -describe('SingleStatCtrl', function() { +describe('SingleStatCtrl', () => { const ctx = {} as any; const epoch = 1505826363746; Date.now = () => epoch; @@ -28,9 +28,9 @@ describe('SingleStatCtrl', function() { }; function singleStatScenario(desc, func) { - describe(desc, function() { - ctx.setup = function(setupFunc) { - beforeEach(function() { + describe(desc, () => { + ctx.setup = setupFunc => { + beforeEach(() => { ctx.ctrl = new SingleStatCtrl($scope, $injector, {}); setupFunc(); ctx.ctrl.onDataReceived(ctx.data); @@ -42,191 +42,189 @@ describe('SingleStatCtrl', function() { }); } - singleStatScenario('with defaults', function(ctx) { - ctx.setup(function() { + singleStatScenario('with defaults', ctx => { + ctx.setup(() => { ctx.data = [{ target: 'test.cpu1', datapoints: [[10, 1], [20, 2]] }]; }); - it('Should use series avg as default main value', function() { + it('Should use series avg as default main value', () => { expect(ctx.data.value).toBe(15); expect(ctx.data.valueRounded).toBe(15); }); - it('should set formatted falue', function() { + it('should set formatted falue', () => { expect(ctx.data.valueFormatted).toBe('15'); }); }); - singleStatScenario('showing serie name instead of value', function(ctx) { - ctx.setup(function() { + singleStatScenario('showing serie name instead of value', ctx => { + ctx.setup(() => { ctx.data = [{ target: 'test.cpu1', datapoints: [[10, 1], [20, 2]] }]; ctx.ctrl.panel.valueName = 'name'; }); - it('Should use series avg as default main value', function() { + it('Should use series avg as default main value', () => { expect(ctx.data.value).toBe(0); expect(ctx.data.valueRounded).toBe(0); }); - it('should set formatted value', function() { + it('should set formatted value', () => { expect(ctx.data.valueFormatted).toBe('test.cpu1'); }); }); - singleStatScenario('showing last iso time instead of value', function(ctx) { - ctx.setup(function() { + singleStatScenario('showing last iso time instead of value', ctx => { + ctx.setup(() => { ctx.data = [{ target: 'test.cpu1', datapoints: [[10, 12], [20, 1505634997920]] }]; ctx.ctrl.panel.valueName = 'last_time'; ctx.ctrl.panel.format = 'dateTimeAsIso'; ctx.ctrl.dashboard.isTimezoneUtc = () => false; }); - it('Should use time instead of value', function() { + it('Should use time instead of value', () => { expect(ctx.data.value).toBe(1505634997920); expect(ctx.data.valueRounded).toBe(1505634997920); }); - it('should set formatted value', function() { + it('should set formatted value', () => { expect(moment(ctx.data.valueFormatted).valueOf()).toBe(1505634997000); }); }); - singleStatScenario('showing last iso time instead of value (in UTC)', function(ctx) { - ctx.setup(function() { + singleStatScenario('showing last iso time instead of value (in UTC)', ctx => { + ctx.setup(() => { ctx.data = [{ target: 'test.cpu1', datapoints: [[10, 12], [20, 5000]] }]; ctx.ctrl.panel.valueName = 'last_time'; ctx.ctrl.panel.format = 'dateTimeAsIso'; ctx.ctrl.dashboard.isTimezoneUtc = () => true; }); - it('should set value', function() { + it('should set value', () => { expect(ctx.data.valueFormatted).toBe('1970-01-01 00:00:05'); }); }); - singleStatScenario('showing last us time instead of value', function(ctx) { - ctx.setup(function() { + singleStatScenario('showing last us time instead of value', ctx => { + ctx.setup(() => { ctx.data = [{ target: 'test.cpu1', datapoints: [[10, 12], [20, 1505634997920]] }]; ctx.ctrl.panel.valueName = 'last_time'; ctx.ctrl.panel.format = 'dateTimeAsUS'; ctx.ctrl.dashboard.isTimezoneUtc = () => false; }); - it('Should use time instead of value', function() { + it('Should use time instead of value', () => { expect(ctx.data.value).toBe(1505634997920); expect(ctx.data.valueRounded).toBe(1505634997920); }); - it('should set formatted value', function() { + it('should set formatted value', () => { expect(ctx.data.valueFormatted).toBe(moment(1505634997920).format('MM/DD/YYYY h:mm:ss a')); }); }); - singleStatScenario('showing last us time instead of value (in UTC)', function(ctx) { - ctx.setup(function() { + singleStatScenario('showing last us time instead of value (in UTC)', ctx => { + ctx.setup(() => { ctx.data = [{ target: 'test.cpu1', datapoints: [[10, 12], [20, 5000]] }]; ctx.ctrl.panel.valueName = 'last_time'; ctx.ctrl.panel.format = 'dateTimeAsUS'; ctx.ctrl.dashboard.isTimezoneUtc = () => true; }); - it('should set formatted value', function() { + it('should set formatted value', () => { expect(ctx.data.valueFormatted).toBe('01/01/1970 12:00:05 am'); }); }); - singleStatScenario('showing last time from now instead of value', function(ctx) { - ctx.setup(function() { + singleStatScenario('showing last time from now instead of value', ctx => { + ctx.setup(() => { ctx.data = [{ target: 'test.cpu1', datapoints: [[10, 12], [20, 1505634997920]] }]; ctx.ctrl.panel.valueName = 'last_time'; ctx.ctrl.panel.format = 'dateTimeFromNow'; }); - it('Should use time instead of value', function() { + it('Should use time instead of value', () => { expect(ctx.data.value).toBe(1505634997920); expect(ctx.data.valueRounded).toBe(1505634997920); }); - it('should set formatted value', function() { + it('should set formatted value', () => { expect(ctx.data.valueFormatted).toBe('2 days ago'); }); }); - singleStatScenario('showing last time from now instead of value (in UTC)', function(ctx) { - ctx.setup(function() { + singleStatScenario('showing last time from now instead of value (in UTC)', ctx => { + ctx.setup(() => { ctx.data = [{ target: 'test.cpu1', datapoints: [[10, 12], [20, 1505634997920]] }]; ctx.ctrl.panel.valueName = 'last_time'; ctx.ctrl.panel.format = 'dateTimeFromNow'; }); - it('should set formatted value', function() { + it('should set formatted value', () => { expect(ctx.data.valueFormatted).toBe('2 days ago'); }); }); - singleStatScenario('MainValue should use same number for decimals as displayed when checking thresholds', function( - ctx - ) { - ctx.setup(function() { + singleStatScenario('MainValue should use same number for decimals as displayed when checking thresholds', ctx => { + ctx.setup(() => { ctx.data = [{ target: 'test.cpu1', datapoints: [[99.999, 1], [99.99999, 2]] }]; ctx.ctrl.panel.valueName = 'avg'; ctx.ctrl.panel.format = 'none'; }); - it('Should be rounded', function() { + it('Should be rounded', () => { expect(ctx.data.value).toBe(99.999495); expect(ctx.data.valueRounded).toBe(100); }); - it('should set formatted value', function() { + it('should set formatted value', () => { expect(ctx.data.valueFormatted).toBe('100'); }); }); - singleStatScenario('When value to text mapping is specified', function(ctx) { - ctx.setup(function() { + singleStatScenario('When value to text mapping is specified', ctx => { + ctx.setup(() => { ctx.data = [{ target: 'test.cpu1', datapoints: [[9.9, 1]] }]; ctx.ctrl.panel.valueMaps = [{ value: '10', text: 'OK' }]; }); - it('value should remain', function() { + it('value should remain', () => { expect(ctx.data.value).toBe(9.9); }); - it('round should be rounded up', function() { + it('round should be rounded up', () => { expect(ctx.data.valueRounded).toBe(10); }); - it('Should replace value with text', function() { + it('Should replace value with text', () => { expect(ctx.data.valueFormatted).toBe('OK'); }); }); - singleStatScenario('When range to text mapping is specified for first range', function(ctx) { - ctx.setup(function() { + singleStatScenario('When range to text mapping is specified for first range', ctx => { + ctx.setup(() => { ctx.data = [{ target: 'test.cpu1', datapoints: [[41, 50]] }]; ctx.ctrl.panel.mappingType = 2; ctx.ctrl.panel.rangeMaps = [{ from: '10', to: '50', text: 'OK' }, { from: '51', to: '100', text: 'NOT OK' }]; }); - it('Should replace value with text OK', function() { + it('Should replace value with text OK', () => { expect(ctx.data.valueFormatted).toBe('OK'); }); }); - singleStatScenario('When range to text mapping is specified for other ranges', function(ctx) { - ctx.setup(function() { + singleStatScenario('When range to text mapping is specified for other ranges', ctx => { + ctx.setup(() => { ctx.data = [{ target: 'test.cpu1', datapoints: [[65, 75]] }]; ctx.ctrl.panel.mappingType = 2; ctx.ctrl.panel.rangeMaps = [{ from: '10', to: '50', text: 'OK' }, { from: '51', to: '100', text: 'NOT OK' }]; }); - it('Should replace value with text NOT OK', function() { + it('Should replace value with text NOT OK', () => { expect(ctx.data.valueFormatted).toBe('NOT OK'); }); }); - describe('When table data', function() { + describe('When table data', () => { const tableData = [ { columns: [{ text: 'Time', type: 'time' }, { text: 'test1' }, { text: 'mean' }, { text: 'test2' }], @@ -235,8 +233,8 @@ describe('SingleStatCtrl', function() { }, ]; - singleStatScenario('with default values', function(ctx) { - ctx.setup(function() { + singleStatScenario('with default values', ctx => { + ctx.setup(() => { ctx.data = tableData; ctx.ctrl.panel = { emit: () => {}, @@ -245,49 +243,47 @@ describe('SingleStatCtrl', function() { ctx.ctrl.panel.format = 'none'; }); - it('Should use first rows value as default main value', function() { + it('Should use first rows value as default main value', () => { expect(ctx.data.value).toBe(15); expect(ctx.data.valueRounded).toBe(15); }); - it('should set formatted value', function() { + it('should set formatted value', () => { expect(ctx.data.valueFormatted).toBe('15'); }); }); - singleStatScenario('When table data has multiple columns', function(ctx) { - ctx.setup(function() { + singleStatScenario('When table data has multiple columns', ctx => { + ctx.setup(() => { ctx.data = tableData; ctx.ctrl.panel.tableColumn = ''; }); - it('Should set column to first column that is not time', function() { + it('Should set column to first column that is not time', () => { expect(ctx.ctrl.panel.tableColumn).toBe('test1'); }); }); - singleStatScenario('MainValue should use same number for decimals as displayed when checking thresholds', function( - ctx - ) { - ctx.setup(function() { + singleStatScenario('MainValue should use same number for decimals as displayed when checking thresholds', ctx => { + ctx.setup(() => { ctx.data = tableData; ctx.data[0].rows[0] = [1492759673649, 'ignore1', 99.99999, 'ignore2']; ctx.ctrl.panel.mappingType = 0; ctx.ctrl.panel.tableColumn = 'mean'; }); - it('Should be rounded', function() { + it('Should be rounded', () => { expect(ctx.data.value).toBe(99.99999); expect(ctx.data.valueRounded).toBe(100); }); - it('should set formatted falue', function() { + it('should set formatted falue', () => { expect(ctx.data.valueFormatted).toBe('100'); }); }); - singleStatScenario('When value to text mapping is specified', function(ctx) { - ctx.setup(function() { + singleStatScenario('When value to text mapping is specified', ctx => { + ctx.setup(() => { ctx.data = tableData; ctx.data[0].rows[0] = [1492759673649, 'ignore1', 9.9, 'ignore2']; ctx.ctrl.panel.mappingType = 2; @@ -295,21 +291,21 @@ describe('SingleStatCtrl', function() { ctx.ctrl.panel.valueMaps = [{ value: '10', text: 'OK' }]; }); - it('value should remain', function() { + it('value should remain', () => { expect(ctx.data.value).toBe(9.9); }); - it('round should be rounded up', function() { + it('round should be rounded up', () => { expect(ctx.data.valueRounded).toBe(10); }); - it('Should replace value with text', function() { + it('Should replace value with text', () => { expect(ctx.data.valueFormatted).toBe('OK'); }); }); - singleStatScenario('When range to text mapping is specified for first range', function(ctx) { - ctx.setup(function() { + singleStatScenario('When range to text mapping is specified for first range', ctx => { + ctx.setup(() => { ctx.data = tableData; ctx.data[0].rows[0] = [1492759673649, 'ignore1', 41, 'ignore2']; ctx.ctrl.panel.tableColumn = 'mean'; @@ -317,13 +313,13 @@ describe('SingleStatCtrl', function() { ctx.ctrl.panel.rangeMaps = [{ from: '10', to: '50', text: 'OK' }, { from: '51', to: '100', text: 'NOT OK' }]; }); - it('Should replace value with text OK', function() { + it('Should replace value with text OK', () => { expect(ctx.data.valueFormatted).toBe('OK'); }); }); - singleStatScenario('When range to text mapping is specified for other ranges', function(ctx) { - ctx.setup(function() { + singleStatScenario('When range to text mapping is specified for other ranges', ctx => { + ctx.setup(() => { ctx.data = tableData; ctx.data[0].rows[0] = [1492759673649, 'ignore1', 65, 'ignore2']; ctx.ctrl.panel.tableColumn = 'mean'; @@ -331,31 +327,31 @@ describe('SingleStatCtrl', function() { ctx.ctrl.panel.rangeMaps = [{ from: '10', to: '50', text: 'OK' }, { from: '51', to: '100', text: 'NOT OK' }]; }); - it('Should replace value with text NOT OK', function() { + it('Should replace value with text NOT OK', () => { expect(ctx.data.valueFormatted).toBe('NOT OK'); }); }); - singleStatScenario('When value is string', function(ctx) { - ctx.setup(function() { + singleStatScenario('When value is string', ctx => { + ctx.setup(() => { ctx.data = tableData; ctx.data[0].rows[0] = [1492759673649, 'ignore1', 65, 'ignore2']; ctx.ctrl.panel.tableColumn = 'test1'; }); - it('Should replace value with text NOT OK', function() { + it('Should replace value with text NOT OK', () => { expect(ctx.data.valueFormatted).toBe('ignore1'); }); }); - singleStatScenario('When value is zero', function(ctx) { - ctx.setup(function() { + singleStatScenario('When value is zero', ctx => { + ctx.setup(() => { ctx.data = tableData; ctx.data[0].rows[0] = [1492759673649, 'ignore1', 0, 'ignore2']; ctx.ctrl.panel.tableColumn = 'mean'; }); - it('Should return zero', function() { + it('Should return zero', () => { expect(ctx.data.value).toBe(0); }); }); diff --git a/public/app/plugins/panel/singlestat/specs/singlestat_panel.test.ts b/public/app/plugins/panel/singlestat/specs/singlestat_panel.test.ts index 114cdf132e1..1a88c6bb770 100644 --- a/public/app/plugins/panel/singlestat/specs/singlestat_panel.test.ts +++ b/public/app/plugins/panel/singlestat/specs/singlestat_panel.test.ts @@ -1,6 +1,6 @@ import { getColorForValue } from '../module'; -describe('grafanaSingleStat', function() { +describe('grafanaSingleStat', () => { describe('legacy thresholds', () => { describe('positive thresholds', () => { const data: any = { diff --git a/public/app/plugins/panel/table/specs/renderer.test.ts b/public/app/plugins/panel/table/specs/renderer.test.ts index b66984ba223..f29c69e4acd 100644 --- a/public/app/plugins/panel/table/specs/renderer.test.ts +++ b/public/app/plugins/panel/table/specs/renderer.test.ts @@ -163,15 +163,15 @@ describe('when rendering table', () => { ], }; - const sanitize = function(value) { + const sanitize = value => { return 'sanitized'; }; const templateSrv = { - replace: function(value, scopedVars) { + replace: (value, scopedVars) => { if (scopedVars) { // For testing variables replacement in link - _.each(scopedVars, function(val, key) { + _.each(scopedVars, (val, key) => { value = value.replace('$' + key, val.value); }); } diff --git a/public/app/plugins/panel/table/specs/transformers.test.ts b/public/app/plugins/panel/table/specs/transformers.test.ts index 2425d98f26d..8d581b68842 100644 --- a/public/app/plugins/panel/table/specs/transformers.test.ts +++ b/public/app/plugins/panel/table/specs/transformers.test.ts @@ -161,15 +161,15 @@ describe('when transforming time series table', () => { }, ]; - describe('getColumns', function() { - it('should return data columns given a single query', function() { + describe('getColumns', () => { + it('should return data columns given a single query', () => { const columns = transformers[transform].getColumns(singleQueryData); expect(columns[0].text).toBe('Time'); expect(columns[1].text).toBe('Label Key 1'); expect(columns[2].text).toBe('Value'); }); - it('should return the union of data columns given a multiple queries', function() { + it('should return the union of data columns given a multiple queries', () => { const columns = transformers[transform].getColumns(multipleQueriesDataSameLabels); expect(columns[0].text).toBe('Time'); expect(columns[1].text).toBe('Label Key 1'); @@ -178,7 +178,7 @@ describe('when transforming time series table', () => { expect(columns[4].text).toBe('Value #B'); }); - it('should return the union of data columns given a multiple queries with different labels', function() { + it('should return the union of data columns given a multiple queries with different labels', () => { const columns = transformers[transform].getColumns(multipleQueriesDataDifferentLabels); expect(columns[0].text).toBe('Time'); expect(columns[1].text).toBe('Label Key 1'); @@ -189,7 +189,7 @@ describe('when transforming time series table', () => { }); }); - describe('transform', function() { + describe('transform', () => { it('should throw an error with non-table data', () => { expect(() => transformDataToTable(nonTableData, panel)).toThrow(); }); @@ -286,8 +286,8 @@ describe('when transforming time series table', () => { }, ]; - describe('getColumns', function() { - it('should return nested properties', function() { + describe('getColumns', () => { + it('should return nested properties', () => { const columns = transformers['json'].getColumns(rawData); expect(columns[0].text).toBe('timestamp'); expect(columns[1].text).toBe('message'); @@ -295,7 +295,7 @@ describe('when transforming time series table', () => { }); }); - describe('transform', function() { + describe('transform', () => { beforeEach(() => { table = transformDataToTable(rawData, panel); }); diff --git a/public/test/specs/helpers.ts b/public/test/specs/helpers.ts index f585498d247..0345576d96c 100644 --- a/public/test/specs/helpers.ts +++ b/public/test/specs/helpers.ts @@ -15,10 +15,10 @@ export function ControllerTestContext(this: any) { this.timeSrv = new TimeSrvStub(); this.templateSrv = new TemplateSrvStub(); this.datasourceSrv = { - getMetricSources: function() {}, - get: function() { + getMetricSources: () => {}, + get: () => { return { - then: function(callback) { + then: callback => { callback(self.datasource); }, }; @@ -26,8 +26,8 @@ export function ControllerTestContext(this: any) { }; this.isUtc = false; - this.providePhase = function(mocks) { - return angularMocks.module(function($provide) { + this.providePhase = mocks => { + return angularMocks.module($provide => { $provide.value('contextSrv', self.contextSrv); $provide.value('datasourceSrv', self.datasourceSrv); $provide.value('annotationsSrv', self.annotationsSrv); @@ -35,14 +35,14 @@ export function ControllerTestContext(this: any) { $provide.value('templateSrv', self.templateSrv); $provide.value('$element', self.$element); $provide.value('$sanitize', self.$sanitize); - _.each(mocks, function(value, key) { + _.each(mocks, (value, key) => { $provide.value(key, value); }); }); }; - this.createPanelController = function(Ctrl) { - return angularMocks.inject(function($controller, $rootScope, $q, $location, $browser) { + this.createPanelController = Ctrl => { + return angularMocks.inject(($controller, $rootScope, $q, $location, $browser) => { self.scope = $rootScope.$new(); self.$location = $location; self.$browser = $browser; @@ -50,7 +50,7 @@ export function ControllerTestContext(this: any) { self.panel = new PanelModel({ type: 'test' }); self.dashboard = { meta: {} }; self.isUtc = false; - self.dashboard.isTimezoneUtc = function() { + self.dashboard.isTimezoneUtc = () => { return self.isUtc; }; @@ -74,8 +74,8 @@ export function ControllerTestContext(this: any) { }); }; - this.createControllerPhase = function(controllerName) { - return angularMocks.inject(function($controller, $rootScope, $q, $location, $browser) { + this.createControllerPhase = controllerName => { + return angularMocks.inject(($controller, $rootScope, $q, $location, $browser) => { self.scope = $rootScope.$new(); self.$location = $location; self.$browser = $browser; @@ -101,7 +101,7 @@ export function ControllerTestContext(this: any) { }); }; - this.setIsUtc = function(isUtc = false) { + this.setIsUtc = (isUtc = false) => { self.isUtc = isUtc; }; } @@ -114,23 +114,23 @@ export function ServiceTestContext(this: any) { self.backendSrv = {}; self.$routeParams = {}; - this.providePhase = function(mocks) { - return angularMocks.module(function($provide) { - _.each(mocks, function(key) { + this.providePhase = mocks => { + return angularMocks.module($provide => { + _.each(mocks, key => { $provide.value(key, self[key]); }); }); }; - this.createService = function(name) { - return angularMocks.inject(function($q, $rootScope, $httpBackend, $injector, $location, $timeout) { + this.createService = name => { + return angularMocks.inject(($q, $rootScope, $httpBackend, $injector, $location, $timeout) => { self.$q = $q; self.$rootScope = $rootScope; self.$httpBackend = $httpBackend; self.$location = $location; - self.$rootScope.onAppEvent = function() {}; - self.$rootScope.appEvent = function() {}; + self.$rootScope.onAppEvent = () => {}; + self.$rootScope.appEvent = () => {}; self.$timeout = $timeout; self.service = $injector.get(name); @@ -139,7 +139,7 @@ export function ServiceTestContext(this: any) { } export function DashboardViewStateStub(this: any) { - this.registerPanel = function() {}; + this.registerPanel = () => {}; } export function TimeSrvStub(this: any) { @@ -155,7 +155,7 @@ export function TimeSrvStub(this: any) { }; }; - this.replace = function(target) { + this.replace = target => { return target; }; @@ -165,7 +165,7 @@ export function TimeSrvStub(this: any) { } export function ContextSrvStub(this: any) { - this.hasRole = function() { + this.hasRole = () => { return true; }; } @@ -177,17 +177,17 @@ export function TemplateSrvStub(this: any) { this.replace = function(text) { return _.template(text, this.templateSettings)(this.data); }; - this.init = function() {}; - this.getAdhocFilters = function() { + this.init = () => {}; + this.getAdhocFilters = () => { return []; }; - this.fillVariableValuesForUrl = function() {}; - this.updateTemplateData = function() {}; - this.variableExists = function() { + this.fillVariableValuesForUrl = () => {}; + this.updateTemplateData = () => {}; + this.variableExists = () => { return false; }; - this.variableInitialized = function() {}; - this.highlightVariablesAsHtml = function(str) { + this.variableInitialized = () => {}; + this.highlightVariablesAsHtml = str => { return str; }; this.setGrafanaVariable = function(name, value) {