Give interactions a reference to the map
This is in line with what we do for controls and overlays. A follow-up change will add calls to `setMap` when interactions are added to a map.
This commit is contained in:
50
test/spec/ol/interaction/interaction.test.js
Normal file
50
test/spec/ol/interaction/interaction.test.js
Normal file
@@ -0,0 +1,50 @@
|
||||
goog.provide('ol.test.interaction.Interaction');
|
||||
|
||||
describe('ol.interaction.Interaction', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('creates a new interaction', function() {
|
||||
var interaction = new ol.interaction.Interaction();
|
||||
expect(interaction).to.be.a(ol.interaction.Interaction);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getMap()', function() {
|
||||
|
||||
it('retrieves the associated map', function() {
|
||||
var map = new ol.Map({});
|
||||
var interaction = new ol.interaction.Interaction();
|
||||
interaction.setMap(map);
|
||||
expect(interaction.getMap()).to.be(map);
|
||||
});
|
||||
|
||||
it('returns null if no map', function() {
|
||||
var interaction = new ol.interaction.Interaction();
|
||||
expect(interaction.getMap()).to.be(null);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#setMap()', function() {
|
||||
|
||||
it('allows a map to be set', function() {
|
||||
var map = new ol.Map({});
|
||||
var interaction = new ol.interaction.Interaction();
|
||||
interaction.setMap(map);
|
||||
expect(interaction.getMap()).to.be(map);
|
||||
});
|
||||
|
||||
it('accepts null', function() {
|
||||
var interaction = new ol.interaction.Interaction();
|
||||
interaction.setMap(null);
|
||||
expect(interaction.getMap()).to.be(null);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
Reference in New Issue
Block a user