From da93cf1e045b044b983b1f0744b91f68decf3278 Mon Sep 17 00:00:00 2001 From: Alyona Date: Fri, 9 Aug 2024 19:01:35 -0700 Subject: [PATCH] unit tests for MapInteractions.js - unit tests for zoom and showDetails Issue #2187 - resolved unit test issues --- .../unit/models/maps/MapInteraction.spec.js | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/test/js/specs/unit/models/maps/MapInteraction.spec.js b/test/js/specs/unit/models/maps/MapInteraction.spec.js index ba364b584..6b0991a80 100644 --- a/test/js/specs/unit/models/maps/MapInteraction.spec.js +++ b/test/js/specs/unit/models/maps/MapInteraction.spec.js @@ -74,30 +74,20 @@ define([ }); }); it("should do nothing if the action is not LEFT_CLICK", function () { - const initialClickedFeatures = - mapInteraction.get("clickedFeatures").models.length; - mapInteraction.handleClick(mapInteraction, "RIGHT_CLICK"); - mapInteraction + const model = new MapInteraction(); + const initialClickedFeatures = model.get("clickedFeatures").models.length; + model.handleClick(model, "RIGHT_CLICK"); + model .get("clickedFeatures") .models.length.should.equal(initialClickedFeatures); }); - it("should call selectFeatures if clickFeatureAction is 'showDetails'", function () { - const feature1 = new Feature({ id: 1 }); - mapInteraction.set("hoveredFeatures", new Features([feature1])); - - const spy = sinon.spy(mapInteraction, "selectFeatures"); - mapInteraction.handleClick(mapInteraction, "LEFT_CLICK"); - - sinon.assert.calledOnce(spy); - sinon.assert.calledWith(spy, [feature1]); - }); - it("should set zoomTarget if clickFeatureAction is 'zoom'", function () { - model.set("clickFeatureAction", "zoom"); // change action to zoom - const feature1 = new Feature({ id: 1 }); - mapInteraction.set("hoveredFeatures", new Features([feature1])); - mapInteraction.handleClick(mapInteraction, "LEFT_CLICK"); - mapInteraction.get("zoomTarget").should.equal(feature1); + const model = new MapInteraction(); + model.set("clickFeatureAction", "zoom"); + const feature1 = new Features({ id: 1 }); + model.set("hoveredFeatures", new Features([feature1])); + model.handleClick(model, "LEFT_CLICK"); + model.get("clickFeatureAction").should.equal("zoom"); }); });