diff options
| author | Claude Paroz <claude@2xlibre.net> | 2015-10-03 12:04:32 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2015-10-07 08:59:32 +0200 |
| commit | 1e8d48252b83efa31118be07b7e134cf0255237d (patch) | |
| tree | 9af6d33255dc78f69cdd70cdb61559890f5dd8d1 /js_tests | |
| parent | 914167abf19d16ac97c0f1f6ae1b08cb377c8f3a (diff) | |
Added basic JS tests for OLMapWidget.js
Thanks Trey Hunner for cleaning the initial patch and Tim Graham for
the review.
Diffstat (limited to 'js_tests')
| -rw-r--r-- | js_tests/gis/mapwidget.test.js | 46 | ||||
| -rw-r--r-- | js_tests/tests.html | 9 |
2 files changed, 55 insertions, 0 deletions
diff --git a/js_tests/gis/mapwidget.test.js b/js_tests/gis/mapwidget.test.js new file mode 100644 index 0000000000..c46823c9b9 --- /dev/null +++ b/js_tests/gis/mapwidget.test.js @@ -0,0 +1,46 @@ +/* global module, test, MapWidget */ +/* eslint global-strict: 0, strict: 0 */ +'use strict'; + +module('gis.OLMapWidget'); + +test('MapWidget.featureAdded', function(assert) { + var options = {id: 'id_point', map_id: 'id_point_map', geom_name: 'Point'}; + var widget = new MapWidget(options); + assert.equal(widget.layers.vector.features.length, 1); + assert.equal( + widget.layers.vector.features[0].geometry.toString(), + 'POINT(7.8177 47.397)', + 'Point addded to vector layer' + ); +}); + +test('MapWidget.map_srid', function(assert) { + var options = {id: 'id_point', map_id: 'id_point_map', geom_name: 'Point'}; + var widget = new MapWidget(options); + assert.equal(widget.options.map_srid, 4326, 'SRID 4326'); +}); + +test('MapWidget.defaultCenter', function(assert) { + var options = {id: 'id_point', map_id: 'id_point_map', geom_name: 'Point'}; + var widget = new MapWidget(options); + assert.equal(widget.defaultCenter().toString(), 'lon=0,lat=0', 'Default center at 0, 0'); + options.default_lat = 47.08; + options.default_lon = 6.81; + widget = new MapWidget(options); + assert.equal( + widget.defaultCenter().toString(), + 'lon=6.81,lat=47.08', + 'Default center at 6.81, 47.08' + ); +}); + +test('MapWidget.getControls', function(assert) { + var options = {id: 'id_point', map_id: 'id_point_map', geom_name: 'Point'}; + var widget = new MapWidget(options); + widget.getControls(widget.layers.vector); + assert.equal(widget.controls.length, 3); + assert.equal(widget.controls[0].displayClass, 'olControlNavigation', 'Navigation control'); + assert.equal(widget.controls[1].displayClass, 'olControlDrawFeaturePoint', 'Draw control'); + assert.equal(widget.controls[2].displayClass, 'olControlModifyFeature', 'Modify control'); +}); diff --git a/js_tests/tests.html b/js_tests/tests.html index 13c6bcd693..568c2a5bb7 100644 --- a/js_tests/tests.html +++ b/js_tests/tests.html @@ -78,6 +78,15 @@ <script src='../django/contrib/admin/static/admin/js/prepopulate.js' data-cover></script> <script src='../django/contrib/admin/static/admin/js/urlify.js' data-cover></script> + <div id="id_point_map"> + <textarea id="id_point" name="point" + class="vSerializedField required" style="display:none;" + rows="10" cols="150">POINT (7.8177 47.397)</textarea> + </div> + <script src='http://openlayers.org/api/2.13.1/OpenLayers.js'></script> + <script src='../django/contrib/gis/static/gis/js/OLMapWidget.js' data-cover></script> + <script src='./gis/mapwidget.test.js'></script> + <script> if (location.href.match(/(\?|&)gruntReport($|&|=)/)) { blanket.options("reporter", "qunit/grunt-reporter.js"); |
