mapwidget.test.js 1.8 KB

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