From d993921d02a7c8815cc2fbf0025c216d786e736f Mon Sep 17 00:00:00 2001 From: Anton Serhiienko Date: Tue, 10 Aug 2021 12:43:54 +0300 Subject: [PATCH] fixing undefined lat/long filtering --- src/worldmap.test.ts | 17 +++++++++++++++++ src/worldmap.ts | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/worldmap.test.ts b/src/worldmap.test.ts index c34d688..6c55dee 100644 --- a/src/worldmap.test.ts +++ b/src/worldmap.test.ts @@ -296,6 +296,23 @@ describe('Worldmap', () => { }); }); + describe('when there is not lat/long', () => { + beforeEach(() => { + let data = new DataBuilder().build(); + data.push ({ + "key": "undefined_undefined", + "locationName": "US", + "value": 2535200, + "valueFormatted": 2535200 + }) + ctrl.data = data + }); + + it('should not crash', () => { + expect(() => worldMap.drawCircles()).not.toThrowError(); + }); + }); + describe('when three thresholds are set', () => { beforeEach(() => { ctrl.data = new DataBuilder().withThresholdValues([2, 4, 6]).build(); diff --git a/src/worldmap.ts b/src/worldmap.ts index 341f9a6..e3c98c9 100644 --- a/src/worldmap.ts +++ b/src/worldmap.ts @@ -128,7 +128,7 @@ export default class WorldMap { createCircles(data) { const circles: any[] = []; data.forEach(dataPoint => { - if (!dataPoint.locationName) { + if (!dataPoint.locationName || !dataPoint.locationLatitude || !dataPoint.locationLongitude) { return; } circles.push(this.createCircle(dataPoint));