mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
add tests for tooltipProximity and nearestFeature
This commit is contained in:
parent
4129ae8cf8
commit
d7460c3536
2 changed files with 35 additions and 4 deletions
|
@ -70,7 +70,7 @@ define(function (require) {
|
|||
}
|
||||
|
||||
// find nearest feature to event latlng
|
||||
var feature = this.nearestFeature(latlng);
|
||||
var feature = this._nearestFeature(latlng);
|
||||
|
||||
// show tooltip if close enough to event latlng
|
||||
if (this._tooltipProximity(latlng, feature)) {
|
||||
|
@ -99,11 +99,11 @@ define(function (require) {
|
|||
/**
|
||||
* Finds nearest feature in mapData to event latlng
|
||||
*
|
||||
* @method nearestFeature
|
||||
* @method _nearestFeature
|
||||
* @param point {Leaflet latLng Object}
|
||||
* @return nearestPoint {Leaflet Object}
|
||||
*/
|
||||
HeatmapMarker.prototype.nearestFeature = function (latLng) {
|
||||
HeatmapMarker.prototype._nearestFeature = function (latLng) {
|
||||
var self = this;
|
||||
var nearest;
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ define(function (require) {
|
|||
});
|
||||
|
||||
it('should return an array item with lat, lng, normalized metric for each feature', function () {
|
||||
_.times(3, function () {
|
||||
_.times(5, function () {
|
||||
markerLayer._attr.heatNormalizeData = true;
|
||||
|
||||
var arr = markerLayer._dataToHeatArray(max);
|
||||
|
@ -297,6 +297,37 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('tooltipProximity method', function () {
|
||||
it('should return true if feature is close enough to event latlng', function () {
|
||||
_.times(5, function () {
|
||||
var feature = _.sample(mapData.features);
|
||||
var point = markerLayer._getLatLng(feature);
|
||||
var arr = markerLayer._tooltipProximity(point, feature);
|
||||
expect(arr).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return false if feature is not close enough to event latlng', function () {
|
||||
_.times(5, function () {
|
||||
var feature = _.sample(mapData.features);
|
||||
var point = L.latLng(90, -180);
|
||||
var arr = markerLayer._tooltipProximity(point, feature);
|
||||
expect(arr).to.be(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('nearestFeature method', function () {
|
||||
it('should return nearest geoJson feature object', function () {
|
||||
_.times(5, function () {
|
||||
var feature = _.sample(mapData.features);
|
||||
var point = markerLayer._getLatLng(feature);
|
||||
var nearestPoint = markerLayer.nearestFeature(point);
|
||||
expect(nearestPoint).to.equal(feature);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue