Skip to content

Commit 395e92c

Browse files
committed
Satisfy linter
1 parent 1bd2776 commit 395e92c

File tree

2 files changed

+17
-37
lines changed

2 files changed

+17
-37
lines changed

src/worldmap.test.ts

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import DataBuilder from '../test/data_builder';
2-
import {createBasicMap} from '../test/map_builder';
2+
import { createBasicMap } from '../test/map_builder';
33
import $ from 'jquery';
4-
import PluginSettings from "./settings";
4+
import PluginSettings from './settings';
55
import { TemplateSrv } from 'grafana/app/features/templating/template_srv';
66

7-
87
describe('Worldmap', () => {
9-
108
let worldMap;
119
let ctrl;
1210

@@ -398,7 +396,6 @@ describe('Worldmap', () => {
398396
expect(worldMap.circles[0]._popup._content).toBe('Sweden: 1\nSweden: 2');
399397
});
400398
});
401-
402399
});
403400

404401
describe('WorldmapFoundation', () => {
@@ -461,10 +458,8 @@ describe('WorldmapFoundation', () => {
461458
expect(document.getElementsByClassName('leaflet-control-attribution')[0]).toBeUndefined();
462459
});
463460
});
464-
465461
});
466462

467-
468463
describe('ClickthroughLinks', () => {
469464
/*
470465
* These tests proof the clickthrough link works.
@@ -494,18 +489,14 @@ describe('ClickthroughLinks', () => {
494489

495490
describe('when a Worldmap is created with clickthrough-links enabled', () => {
496491
beforeEach(() => {
497-
498492
// Create map.
499493
ctrl.panel.clickthroughUrl = 'http://foo.bar';
500494
ctrl.settings = new PluginSettings(ctrl.panel, templateSrvMock, {});
501495
worldMap.createMap();
502496

503497
// Load data and draw circles.
504-
ctrl.data = new DataBuilder()
505-
.withCountryAndValue('SE', 1)
506-
.build();
498+
ctrl.data = new DataBuilder().withCountryAndValue('SE', 1).build();
507499
worldMap.drawCircles();
508-
509500
});
510501

511502
it('should have registered a second click event', () => {
@@ -514,7 +505,6 @@ describe('ClickthroughLinks', () => {
514505
});
515506

516507
it('should do its job when actually clicked', () => {
517-
518508
// Setup interaction mock for "window.location.assign".
519509
// https://remarkablemark.org/blog/2018/11/17/mock-window-location/
520510
Object.defineProperty(window.location, 'assign', {
@@ -526,24 +516,19 @@ describe('ClickthroughLinks', () => {
526516
worldMap.circles[0].fire('click');
527517
expect(window.location.assign).toHaveBeenCalledWith('http://foo.bar');
528518
});
529-
530519
});
531520

532521
describe('when a Worldmap is created with clickthrough-links enabled to another window', () => {
533522
beforeEach(() => {
534-
535523
// Create map.
536524
ctrl.panel.clickthroughUrl = 'http://foo.bar';
537-
ctrl.panel.clickthroughOptions = {windowName: 'test' };
525+
ctrl.panel.clickthroughOptions = { windowName: 'test' };
538526
ctrl.settings = new PluginSettings(ctrl.panel, templateSrvMock, {});
539527
worldMap.createMap();
540528

541529
// Load data and draw circles.
542-
ctrl.data = new DataBuilder()
543-
.withCountryAndValue('SE', 1)
544-
.build();
530+
ctrl.data = new DataBuilder().withCountryAndValue('SE', 1).build();
545531
worldMap.drawCircles();
546-
547532
});
548533

549534
it('should have registered a second click event', () => {
@@ -552,7 +537,6 @@ describe('ClickthroughLinks', () => {
552537
});
553538

554539
it('should do its job when actually clicked', () => {
555-
556540
// Setup interaction mock for "window.open".
557541
// https://remarkablemark.org/blog/2018/11/17/mock-window-location/
558542
Object.defineProperty(window, 'open', {
@@ -564,7 +548,5 @@ describe('ClickthroughLinks', () => {
564548
worldMap.circles[0].fire('click');
565549
expect(window.open).toHaveBeenCalledWith('http://foo.bar', 'test');
566550
});
567-
568551
});
569-
570552
});

src/worldmap.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export default class WorldMap {
181181
createCircles(data) {
182182
console.log('createCircles: begin');
183183
const circles: any[] = [];
184-
const circles_by_key = {};
184+
const circlesByKey = {};
185185
data.forEach(dataPoint => {
186186
// Todo: Review: Is a "locationName" really required
187187
// just for displaying a circle on a map?
@@ -190,15 +190,14 @@ export default class WorldMap {
190190
}
191191
let circle;
192192

193-
// Create circle.
194-
if (circles_by_key[dataPoint.key] == undefined) {
193+
if (circlesByKey[dataPoint.key] === undefined) {
194+
// Create circle.
195195
circle = this.createCircle(dataPoint);
196196
circles.push(circle);
197-
circles_by_key[dataPoint.key] = circle;
198-
199-
// Amend popup content if circle has been created already.
197+
circlesByKey[dataPoint.key] = circle;
200198
} else {
201-
circle = circles_by_key[dataPoint.key];
199+
// Amend popup content if circle has been created already.
200+
circle = circlesByKey[dataPoint.key];
202201
this.extendPopupContent(circle, dataPoint);
203202
}
204203
});
@@ -208,24 +207,23 @@ export default class WorldMap {
208207
}
209208

210209
updateCircles(data) {
211-
const circles_by_key = {};
210+
const circlesByKey = {};
212211
data.forEach(dataPoint => {
213212
// Todo: Review: Is a "locationName" really required
214213
// just for displaying a circle on a map?
215214
if (!dataPoint.locationName) {
216215
return;
217216
}
218217

219-
// Update circle.
220-
if (circles_by_key[dataPoint.key] == undefined) {
218+
if (circlesByKey[dataPoint.key] === undefined) {
219+
// Update circle.
221220
const circle = this.updateCircle(dataPoint);
222221
if (circle) {
223-
circles_by_key[dataPoint.key] = circle;
222+
circlesByKey[dataPoint.key] = circle;
224223
}
225-
226-
// Amend popup content if circle has been updated already.
227224
} else {
228-
const circle = circles_by_key[dataPoint.key];
225+
// Amend popup content if circle has been updated already.
226+
const circle = circlesByKey[dataPoint.key];
229227
this.extendPopupContent(circle, dataPoint);
230228
}
231229
});

0 commit comments

Comments
 (0)