|
| 1 | +/* global module, test, MapWidget */ |
| 2 | +/* eslint global-strict: 0, strict: 0 */ |
| 3 | +'use strict'; |
| 4 | + |
| 5 | +module('gis.OLMapWidget'); |
| 6 | + |
| 7 | +test('MapWidget.featureAdded', function(assert) { |
| 8 | + var options = {id: 'id_point', map_id: 'id_point_map', geom_name: 'Point'}; |
| 9 | + var widget = new MapWidget(options); |
| 10 | + assert.equal(widget.layers.vector.features.length, 1); |
| 11 | + assert.equal( |
| 12 | + widget.layers.vector.features[0].geometry.toString(), |
| 13 | + 'POINT(7.8177 47.397)', |
| 14 | + 'Point addded to vector layer' |
| 15 | + ); |
| 16 | +}); |
| 17 | + |
| 18 | +test('MapWidget.map_srid', function(assert) { |
| 19 | + var options = {id: 'id_point', map_id: 'id_point_map', geom_name: 'Point'}; |
| 20 | + var widget = new MapWidget(options); |
| 21 | + assert.equal(widget.options.map_srid, 4326, 'SRID 4326'); |
| 22 | +}); |
| 23 | + |
| 24 | +test('MapWidget.defaultCenter', function(assert) { |
| 25 | + var options = {id: 'id_point', map_id: 'id_point_map', geom_name: 'Point'}; |
| 26 | + var widget = new MapWidget(options); |
| 27 | + assert.equal(widget.defaultCenter().toString(), 'lon=0,lat=0', 'Default center at 0, 0'); |
| 28 | + options.default_lat = 47.08; |
| 29 | + options.default_lon = 6.81; |
| 30 | + widget = new MapWidget(options); |
| 31 | + assert.equal( |
| 32 | + widget.defaultCenter().toString(), |
| 33 | + 'lon=6.81,lat=47.08', |
| 34 | + 'Default center at 6.81, 47.08' |
| 35 | + ); |
| 36 | +}); |
| 37 | + |
| 38 | +test('MapWidget.getControls', function(assert) { |
| 39 | + var options = {id: 'id_point', map_id: 'id_point_map', geom_name: 'Point'}; |
| 40 | + var widget = new MapWidget(options); |
| 41 | + widget.getControls(widget.layers.vector); |
| 42 | + assert.equal(widget.controls.length, 3); |
| 43 | + assert.equal(widget.controls[0].displayClass, 'olControlNavigation', 'Navigation control'); |
| 44 | + assert.equal(widget.controls[1].displayClass, 'olControlDrawFeaturePoint', 'Draw control'); |
| 45 | + assert.equal(widget.controls[2].displayClass, 'olControlModifyFeature', 'Modify control'); |
| 46 | +}); |
0 commit comments