Skip to content

Commit c800ca3

Browse files
committed
Add tests for elasticsearch query results, both for table- and timeseries-data
1 parent 78882ec commit c800ca3

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## development
44
- Improve tests for checking "clickthroughUrl" interpolation
5+
- Add tests for elasticsearch query results, both for table- and timeseries-data
56

67

78
## v0.9.0

src/data_formatter.test.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,97 @@ describe('DataFormatter', () => {
344344
});
345345
});
346346

347+
describe('when elasticsearch geohash query result is in table format', () => {
348+
349+
const data: any[] = [];
350+
351+
beforeEach(() => {
352+
353+
jQuery.extend(ctrl, {
354+
panel: {
355+
esGeoPoint: 'geopoint',
356+
esMetric: 'metric',
357+
//esLocationName: 'location',
358+
//esLink: 'link',
359+
},
360+
});
361+
362+
const esdata = [
363+
{
364+
'type': 'table',
365+
'columns': [
366+
{text: 'geopoint'},
367+
{text: 'metric'},
368+
],
369+
'rows': [
370+
[
371+
'u0wt6pv2qqhz',
372+
123.45,
373+
],
374+
[
375+
'u33dbm6duz90',
376+
67.890,
377+
],
378+
],
379+
},
380+
];
381+
382+
const dataFormatter = new DataFormatter(ctrl);
383+
dataFormatter.setGeohashValues(esdata, data);
384+
385+
});
386+
387+
it('the fields should be available within transformed data', () => {
388+
expect(data[0].value).toEqual(123.45);
389+
expect(data[1].value).toEqual(67.890);
390+
});
391+
392+
});
393+
394+
describe('when elasticsearch geohash query result is in timeseries format', () => {
395+
396+
const data: any[] = [];
397+
398+
beforeEach(() => {
399+
400+
jQuery.extend(ctrl, {
401+
panel: {
402+
esGeoPoint: 'geopoint',
403+
esMetric: 'metric',
404+
//esLocationName: 'location',
405+
//esLink: 'link',
406+
},
407+
});
408+
409+
const esdata = [
410+
{
411+
'datapoints': [
412+
{
413+
geopoint: 'u0wt6pv2qqhz',
414+
metric: 123.45,
415+
},
416+
{
417+
geopoint: 'u33dbm6duz90',
418+
metric: 67.890,
419+
},
420+
],
421+
},
422+
];
423+
424+
const dataFormatter = new DataFormatter(ctrl);
425+
dataFormatter.setGeohashValues(esdata, data);
426+
427+
});
428+
429+
it('the fields should be available within transformed data', () => {
430+
expect(data[0].value).toEqual(123.45);
431+
expect(data[1].value).toEqual(67.890);
432+
});
433+
434+
});
435+
347436
afterEach(() => {
348437
formattedData = [];
349438
});
439+
350440
});

0 commit comments

Comments
 (0)