Skip to content

Commit e8cd4c6

Browse files
committed
Run Prettier
1 parent 99f1810 commit e8cd4c6

File tree

3 files changed

+26
-65
lines changed

3 files changed

+26
-65
lines changed

src/data_formatter.test.ts

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -164,43 +164,38 @@ describe('DataFormatter', () => {
164164
});
165165

166166
describe('when some fields are given in table data', () => {
167-
168167
const data: any[] = [];
169168

170169
beforeEach(() => {
171-
172170
jQuery.extend(ctrl, {
173171
panel: {
174-
tableQueryOptions: {
175-
},
172+
tableQueryOptions: {},
176173
},
177174
});
178175

179176
const tableData = [
180177
[
181178
{
182-
foo: "42.42",
179+
foo: '42.42',
183180
bar: 42.42,
184181
},
185182
{
186-
foo: "43.43",
183+
foo: '43.43',
187184
bar: 43.43,
188185
},
189186
],
190187
];
191188

192189
const dataFormatter = new DataFormatter(ctrl);
193190
dataFormatter.setTableValues(tableData, data);
194-
195191
});
196192

197193
it('the fields should be available within transformed data', () => {
198-
expect(data[0].__field_foo).toEqual("42.42");
194+
expect(data[0].__field_foo).toEqual('42.42');
199195
expect(data[0].__field_bar).toEqual(42.42);
200-
expect(data[1].__field_foo).toEqual("43.43");
196+
expect(data[1].__field_foo).toEqual('43.43');
201197
expect(data[1].__field_bar).toEqual(43.43);
202198
});
203-
204199
});
205200

206201
describe('when the time series data matches the location', () => {
@@ -345,11 +340,9 @@ describe('DataFormatter', () => {
345340
});
346341

347342
describe('when elasticsearch geohash query result is in table format', () => {
348-
349343
const data: any[] = [];
350344

351345
beforeEach(() => {
352-
353346
jQuery.extend(ctrl, {
354347
panel: {
355348
esGeoPoint: 'geopoint',
@@ -361,52 +354,33 @@ describe('DataFormatter', () => {
361354

362355
const esdata = [
363356
{
364-
'type': 'table',
365-
'columns': [
366-
{text: 'geopoint'},
367-
{text: 'metric'},
368-
{text: 'foo'},
369-
{text: 'bar'},
370-
],
371-
'rows': [
372-
[
373-
'u0wt6pv2qqhz',
374-
123.45,
375-
"42.42",
376-
42.42,
377-
],
378-
[
379-
'u33dbm6duz90',
380-
67.890,
381-
"43.43",
382-
43.43,
383-
],
357+
type: 'table',
358+
columns: [{ text: 'geopoint' }, { text: 'metric' }, { text: 'foo' }, { text: 'bar' }],
359+
rows: [
360+
['u0wt6pv2qqhz', 123.45, '42.42', 42.42],
361+
['u33dbm6duz90', 67.89, '43.43', 43.43],
384362
],
385363
},
386364
];
387365

388366
const dataFormatter = new DataFormatter(ctrl);
389367
dataFormatter.setGeohashValues(esdata, data);
390-
391368
});
392369

393370
it('the fields should be available within transformed data', () => {
394371
expect(data[0].value).toEqual(123.45);
395-
expect(data[0].__field_foo).toEqual("42.42");
372+
expect(data[0].__field_foo).toEqual('42.42');
396373
expect(data[0].__field_bar).toEqual(42.42);
397-
expect(data[1].value).toEqual(67.890);
398-
expect(data[1].__field_foo).toEqual("43.43");
374+
expect(data[1].value).toEqual(67.89);
375+
expect(data[1].__field_foo).toEqual('43.43');
399376
expect(data[1].__field_bar).toEqual(43.43);
400377
});
401-
402378
});
403379

404380
describe('when elasticsearch geohash query result is in timeseries format', () => {
405-
406381
const data: any[] = [];
407382

408383
beforeEach(() => {
409-
410384
jQuery.extend(ctrl, {
411385
panel: {
412386
esGeoPoint: 'geopoint',
@@ -418,17 +392,17 @@ describe('DataFormatter', () => {
418392

419393
const esdata = [
420394
{
421-
'datapoints': [
395+
datapoints: [
422396
{
423397
geopoint: 'u0wt6pv2qqhz',
424398
metric: 123.45,
425-
foo: "42.42",
399+
foo: '42.42',
426400
bar: 42.42,
427401
},
428402
{
429403
geopoint: 'u33dbm6duz90',
430-
metric: 67.890,
431-
foo: "43.43",
404+
metric: 67.89,
405+
foo: '43.43',
432406
bar: 43.43,
433407
},
434408
],
@@ -437,22 +411,19 @@ describe('DataFormatter', () => {
437411

438412
const dataFormatter = new DataFormatter(ctrl);
439413
dataFormatter.setGeohashValues(esdata, data);
440-
441414
});
442415

443416
it('the fields should be available within transformed data', () => {
444417
expect(data[0].value).toEqual(123.45);
445-
expect(data[0].__field_foo).toEqual("42.42");
418+
expect(data[0].__field_foo).toEqual('42.42');
446419
expect(data[0].__field_bar).toEqual(42.42);
447-
expect(data[1].value).toEqual(67.890);
448-
expect(data[1].__field_foo).toEqual("43.43");
420+
expect(data[1].value).toEqual(67.89);
421+
expect(data[1].__field_foo).toEqual('43.43');
449422
expect(data[1].__field_bar).toEqual(43.43);
450423
});
451-
452424
});
453425

454426
afterEach(() => {
455427
formattedData = [];
456428
});
457-
458429
});

src/data_formatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export default class DataFormatter {
204204
const dataValue = this.createDataValue(encodedGeohash, decodedGeohash, locationName, value, link);
205205

206206
// Add all values from the original datapoint as attributes prefixed with `__field_`.
207-
for (let columnName in columnNames) {
207+
for (const columnName in columnNames) {
208208
const value = row[columnNames[columnName]];
209209
const key = '__field_' + columnName;
210210
dataValue[key] = value;

src/worldmap.test.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createBasicMap } from '../test/map_builder';
33
import $ from 'jquery';
44
import PluginSettings from './settings';
55
import { TemplateSrv } from 'grafana/app/features/templating/template_srv';
6-
import DataFormatter from "./data_formatter";
6+
import DataFormatter from './data_formatter';
77

88
describe('Worldmap', () => {
99
let worldMap;
@@ -462,7 +462,6 @@ describe('WorldmapFoundation', () => {
462462
});
463463

464464
function setupInteractionMocks() {
465-
466465
// Setup interaction mock for "window.location.assign".
467466
// https://remarkablemark.org/blog/2018/11/17/mock-window-location/
468467
Object.defineProperty(window.location, 'assign', {
@@ -471,11 +470,10 @@ function setupInteractionMocks() {
471470
window.location.assign = jest.fn();
472471

473472
// Setup interaction mock for "window.open".
474-
Object.defineProperty(window, 'open',{
473+
Object.defineProperty(window, 'open', {
475474
configurable: true,
476475
});
477476
window.open = jest.fn();
478-
479477
}
480478

481479
describe('ClickthroughLinks', () => {
@@ -502,7 +500,7 @@ describe('ClickthroughLinks', () => {
502500
return value;
503501
}
504502
}
505-
})
503+
});
506504
},
507505
} as unknown) as TemplateSrv;
508506

@@ -535,15 +533,13 @@ describe('ClickthroughLinks', () => {
535533
});
536534

537535
it('should do its job when actually clicked', () => {
538-
539536
// Prepare interaction with window object.
540537
setupInteractionMocks();
541538

542539
// Capture interaction.
543540
worldMap.circles[0].fire('click');
544541
expect(window.location.assign).toHaveBeenCalledWith('http://foo.bar');
545542
});
546-
547543
});
548544

549545
describe('when a Worldmap is created with clickthrough-links enabled to another window', () => {
@@ -565,20 +561,17 @@ describe('ClickthroughLinks', () => {
565561
});
566562

567563
it('should do its job when actually clicked', () => {
568-
569564
// Prepare interaction with window object.
570565
setupInteractionMocks();
571566

572567
// Capture interaction.
573568
worldMap.circles[0].fire('click');
574569
expect(window.open).toHaveBeenCalledWith('http://foo.bar', 'test');
575570
});
576-
577571
});
578572

579573
describe('when using fields with clickthrough-links on table data', () => {
580574
beforeEach(() => {
581-
582575
// Create map.
583576
ctrl.panel.clickthroughUrl = 'http://foo.bar/?foo=$__field_foo&value=$value';
584577

@@ -606,7 +599,7 @@ describe('ClickthroughLinks', () => {
606599
longitude: 18,
607600
metric: 123.456,
608601

609-
foo: "42.42",
602+
foo: '42.42',
610603
bar: 42.42,
611604
},
612605
{
@@ -616,7 +609,7 @@ describe('ClickthroughLinks', () => {
616609
longitude: 8,
617610
metric: 45.678,
618611

619-
foo: "43.43",
612+
foo: '43.43',
620613
bar: 43.43,
621614
},
622615
],
@@ -631,7 +624,6 @@ describe('ClickthroughLinks', () => {
631624
// Draw circles.
632625
ctrl.data = data;
633626
worldMap.drawCircles();
634-
635627
});
636628

637629
it('the fields within transformed data should interpolate well into clickthrough links', () => {
@@ -642,7 +634,5 @@ describe('ClickthroughLinks', () => {
642634
worldMap.circles[0].fire('click');
643635
expect(window.location.assign).toHaveBeenCalledWith('http://foo.bar/?foo=42.42&value=123.456');
644636
});
645-
646637
});
647-
648638
});

0 commit comments

Comments
 (0)