Commit Graph

130 Commits

Author SHA1 Message Date
4e6ed4c4bc Use explicit imports chai and sinon in the test suite (#9284)
Signed-off-by: Jon Koops <jonkoops@gmail.com>
Co-authored-by: Vladimir Agafonkin <agafonkin@gmail.com>
2024-03-03 14:32:01 +01:00
3d0d4b36cb flyToBounds tests added (#9112) 2023-11-12 21:22:26 +01:00
2592967aa6 user _limitZoom in flyTo, like we do in resetView (#9025)
Co-authored-by: Florian Bischof <design.falke@gmail.com>
2023-07-12 20:52:52 +02:00
a2e0f65e57 Update ui-event-simulator and import as JavaScript module (#8977) 2023-06-03 17:24:35 +02:00
bb048a3eac Import Leaflet in tests using JavaScript modules (#8975) 2023-06-02 12:24:17 +02:00
3a5e472e88 Replace expect.js with Chai (#8952) 2023-05-15 13:55:28 +02:00
fbb9fa8cfe Lint: single quotes in spec 2023-02-20 16:26:28 +01:00
f8fe7f9483 Added two more test cases for the unproject map method (#8637) 2023-02-20 14:45:43 +01:00
bb34482384 Refactor Event handling and happen.js (#8760) 2023-01-01 23:43:51 +01:00
4e77741a66 Remove references to PhantomJS (#8771) 2023-01-01 17:52:26 +01:00
9f35179419 Remove Browser.canvas feature detection (#8754)
Co-authored-by: Iván Sánchez Ortega <ivan@sanchezortega.es>
2022-12-27 12:45:26 +01:00
3f5ea5a271 Remove Browser.any3d (#8748) 2022-12-26 18:52:12 +01:00
2f6aad5d48 Replace DomUtil.remove() with Element.remove() (#8735) 2022-12-22 20:08:18 +01:00
be47f10d5f Enforce quotes ESLint rule for the spec directory (#8686) 2022-11-30 11:59:18 +01:00
9c980d085f Adding tests for 'layerPointToLatLng' method #8375 (#8435)
Co-authored-by: Florian Bischof <design.falke@gmail.com>
2022-10-28 18:26:28 +02:00
97d3542587 Use ResizeObserver for map resizes (#8612)
Co-authored-by: Florian Bischof <design.falke@gmail.com>
2022-10-26 10:34:59 +02:00
119785e3a9 Enable no-var linting rule and fix issues (#8602) 2022-10-20 21:18:26 +02:00
d777c79f7a Enable prefer-arrow-callback linting rule and fix issues (#8594) 2022-10-20 00:10:54 +02:00
5e66c62405 Enable object-shorthand linting rule and fix issues (#8592) 2022-10-19 11:59:15 +02:00
c33a57ca3a Enable prefer-template linting rule and fix issues (#8587) 2022-10-16 23:58:24 +02:00
a939c11d89 test: add test for map stop (#8369) (#8581) 2022-10-16 19:17:22 +02:00
f856bed24c Speed up tests relating to containerPoint / layerPoint methods (#8544) 2022-10-09 11:32:21 +03:00
3836242dd7 closes #8366: panBy() test (#8420)
Co-authored-by: Florian Bischof <design.falke@gmail.com>
2022-10-08 19:04:42 +02:00
2eb6240ae7 Fix intermittent wobble when setMaxBounds(map.getBounds()) (#8534) 2022-10-06 20:01:32 +03:00
bed09ae851 Cover Map Locate with Unit Tests (#8424) 2022-10-02 09:37:22 +02:00
bf43b4b6db Fix: added test cases for Map:mouseEventToContainerPoint method. (#8406)
Co-authored-by: Florian Bischof <design.falke@gmail.com>
2022-10-01 20:20:31 +02:00
46a14df899 Added test cases for Map:addHandler method (#8503) 2022-10-01 20:10:32 +02:00
55929699ed Implement test for 'stopLocate' method of Map (#8505) 2022-10-01 15:29:29 +02:00
fa54a5a2f2 Added testing for mouseEventLatLng (#8403)
Co-authored-by: Florian Bischof <design.falke@gmail.com>
2022-09-30 22:09:33 +02:00
b0acb6114f added tests for panInsideBounds (#8429)
Co-authored-by: Florian Bischof <design.falke@gmail.com>
2022-09-30 19:54:56 +02:00
4372a9fcad Replace Util.bind() with Function.bind() (#8484) 2022-09-29 15:45:16 +02:00
0f0a23e500 Add slow test stats and make some tests faster (#8486) 2022-09-27 12:55:31 +03:00
1b6bae74f0 Added test cases for Map:latLngToLayerPoint method (#8407) 2022-08-30 13:29:41 +02:00
166fb18ada Implemented test for panTo method of Map (#8390) 2022-08-13 12:39:23 +02:00
383619233c Add test for containerPointToLatLng and latLngToContainerPoint methods (#8384) 2022-08-02 11:02:13 +02:00
59c8bf9844 test: add coverage for Layer\_addZoomLimit (#8037)
* test: add coverage for Layer\_addZoomLimit

Resolves #7762

Checks that zoom levels are updated to non-NaN values when
minZoom and maxZoom are set to non-NaN values in one or many
layers that are passed into addZoomLimit.

Checks that min zoom level is updated to NaN when minZoom is
set to NaN in at least one layer that passed into addZoomLimit,
but maxZoom is never set in any layer. Vice versa for when
maxZoom is set to NaN in at least one layer but minZoom is never
set in any layer. Not sure if this is a feature or a bug, so
need to followup with reviewers.

Checks that zoom levels are undefined when minZoom and maxZoom
are both set to NaN in a layer that is passed into addZoomLimit.

* test: add notes to tests showing NaN usage in zoom levels

* Disable test

Co-authored-by: Florian Bischof <design.falke@gmail.com>
2022-07-24 14:44:43 +02:00
40c42e7a17 Additional Map Tests (#8206)
* Initial Commit

- added tests for setZoomAround and setZoom

* Added fitWorld Test

- fitWorld test complete
- Extended setZoomAround tests
- Incorporated lint

* Fixed setZoom Test

- Fixed a unit test in setZoom

* Added setMinZoom and setMaxZoom Tests

- setMinZoom and setMaxZoom tests

* Applied Lint

* Fixed setMaxZoom Test

- Max layer zoom is infinity instead of 0

* Added Getter Tests

- Added tests for getPixelBounds, getSize, getContainer

* Added Getters Tests

- getPixelOrigin and getPixelWorldBounds tests added
- Refactored previous tests

* Fixed getBounds

- Accidently changed test and did not fully convert, changed back to original version

* Added Pane Tests

- Added getPane, getPanes and createPanes tests
- Changed clone test in getSize test

* Added distance Tests

- distance tests added

* Cleaned up Only

- Removed .only

* Added Point Conversion Tests

- Added layerPointToContainerPoint and containerPointToLayerPoint test
- setZoomAround test had demonstrated Point parameter incorrectly

* Fixed Missing Character

- Added # to describe
- Updated condition that can be brittle in setZoomAround

* Removed skips

* Fixed Failing Tests

* Removed .only

Co-authored-by: Florian Bischof <design.falke@gmail.com>
2022-07-18 16:30:28 +02:00
c50688a25f Fix: _isClickDisabled throws error if parent is removed from DOM (#8288)
* disableClickPropagation: does not break if element is not in the DOM

* Update spec/suites/map/MapSpec.js
2022-06-08 11:37:14 +03:00
cd0dcddecc Implemented missing logic for noMoveStart when using panTo function (#6685)
* Implemented missing logic for noMoveStart when using panTo function

* Add test and apply suggestions from johnd0e

Co-authored-by: Tobias Johansson <tobias_johansson@live.se>
Co-authored-by: Florian Bischof <design.falke@gmail.com>
2022-04-22 15:56:02 +03:00
118ca44350 Fix "listener not found" warning when setting maxBounds (#8168)
* fix listener not found warning when setting maxBounds

* fix setMaxBounds invalid bounds early return
2022-04-20 14:57:11 +03:00
5f2b480d3e fix map.getCenter() returning a mutable object (#8167) 2022-04-20 12:50:18 +03:00
7419c9c30e Cleanup all tests (#7852)
* Cleanup Map

* Cleanup Map.BoxZoom

* Cleanup Map.DragSpec

* Add SpecHelper function from commit before

* Cleanup Map.KeyboardSpec

* Cleanup Map.TapHoldSpec

* Cleanup Map.TouchZoomSpec

* Cleanup GeoJSONSpec

* Cleanup ImageOverlaySpec

* Cleanup PopupSpec

* Cleanup TooltipSpec

* Cleanup CanvasSpec

* Cleanup CircleMarkerSpec

* Cleanup CircleSpec

* Cleanup PathSpec

* Cleanup PolygonSpec

* Cleanup PolylineGeometrySpec

* Remove PolylineGeometrySpec

* Remove PolylineGeometrySpec from index.html

* Cleanup PolylineSpec

* Cleanup GridLayerSpec

* Cleanup TileLayerSpec

* Cleanup MarkerSpec

* Cleanup Marker.DragSpec

* Cleanup Icon.DefaultSpec

* Cleanup TransformationSpec

* Cleanup BoundsSpec

* Cleanup LineUtilSpec

* Cleanup PointSpec

* Cleanup PolyUtilSpec

* Cleanup ProjectionSpec

* Cleanup LatLngSpec

* Cleanup LatLngBoundsSpec

* Cleanup CRSSpec

* Cleanup ControlSpec

* Cleanup Control.LayersSpec

* Cleanup Control.AttributionSpec

* Fix some errors - global leaks & map.remove twice

* Fix lint

* Fix error

* Fix noConflict, tabs, createContainer with height & width

* noConflict was not working because rollup already exported the L var

* Replace createMapContainer
2022-03-18 16:04:01 +02:00
e7d5a3725f Locate - locationfound: Add check if map container has leaflet_id / is existing (#7813)
* Add check if map container has the leaflet_id

* Fix lint

* Use private _container

* Add test for _handleGeolocationError

* Update test text

* Change text of test
2021-12-02 19:59:14 +02:00
5b9458e82e Change undefined argument handling in Layer/hasLayer() and LayerGroup/hasLayer() (#6999)
undefined/null/false are not considered as special case anymore,
`layer` argument is always required, as per docs.

Previous excessive tolerance may lead to real errors get masked.
2021-11-05 14:29:35 +02:00
f018e2de2c Fix tests failing in IE (#7461)
* tests: IE<11 does not understand const/let

* tests: specify all required initEvent arguments for (IE)

Otherwise we get: TypeError: Argument not optional

* tests: add profiles to emulate legacy IE versions in IE11

I can confirm that only IE10 profile is working.

Sample commandline:

npm run test-nolint -- --browsers IE,IE10

* tests: consider that style.zIndex is Number type in IE

* tests: set container height explicitly to fix 6 tests failing in IE

in IE when container.style.height is not set, container.clientWidth is always 0, despite container.style.width value.

* tests: fix #preventDefault in IE

Event properties is not preserved across different listeners calls in IE,
so we have to make all checks in the same listener.

Also: control case added.

Note: previously here used to be different implementation that was also reliable,
as it relied on return value of https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent

```
		function dispatchClick(el) { // return: cancelled
			if (document.createEvent) {
				var e = document.createEvent('MouseEvents');
				e.initMouseEvent('click', true, true, window,
					0, 0, 0, 0, 0, false, false, false, false, 0, null);
				return el.dispatchEvent(e);
			} else if (el.fireEvent) { // IE<11
				return el.fireEvent('onclick');
			}
		}

		it('prevents the default action of event', function () {
			expect(dispatchClick(el)).to.be.ok(); // control case

			L.DomEvent.on(el, 'click', L.DomEvent.preventDefault);

			expect(dispatchClick(el)).to.not.be.ok();
		});
```

* tests: skip crossOrigin-related tests in IE<11

https://caniuse.com/mdn-html_elements_img_crossorigin
2021-11-01 11:21:17 +02:00
4c590a2b76 Map: fix contextmenu default-preventing when there are >1 target candidates (#7544)
* Map: fix contextmenu default-preventing when there are >1 target candidates

_fireDOMEvent gets 2 separate targets lists
- from _findEventTargets - has only targets with listeners
- from canvas (passed in argument) - may contain targets without listeners too

Previous code was incorrect as it checked random (first) target, and if happened not to have listeners -
the issue was triggered: preventDefault was not called (despite existing listeners on other targets in list).

* MapSpec.js: fix contextmenu-preventing test in IE
2021-11-01 10:57:42 +02:00
73e13ce3cb Update panInside (#7469)
* Update panInside

Rewrite of panInside to correct issue #7445. Now correctly deals with cases where the padding exceeds half of the display bounds.

* Update panInside tests

Add a test for panInside specifically for issue #7445.

* Clarify last panInside test

Added comments and temp var to clarify the test intention.

* Improve readability of panInside test

Integrated suggested changes from @johnd0e
2021-03-05 11:20:33 +02:00
1653f97dcf Fix map spec (#7451)
* tests: prevent warnings from webserver

Like this:
03 02 2021 08:16:25.848:WARN [web-server]: 404: /000
(also seen as unexpected newlines in progress log)

* MapSpec.js: make quotation marks consistent

* MapSpec.js: minor simplification

* MapSpec.js: fix tests containing expectations in callbacks
2021-02-08 14:34:35 +02:00
38e04e3900 docs: Fix simple typo, somplicity -> simplicity (#7284)
There is a small typo in spec/suites/map/MapSpec.js.

Should read `simplicity` rather than `somplicity`.
2020-09-21 18:42:54 +02:00
e7a5c6ffbf Add more browser profiles and fix some tests (#7115)
* MapSpec.js: fix: mocked function must be restored

Otherwise it will break crs.project test in CRSSpec.js

* MapSpec.js: skip broken test

crsMock.verify() call is mandatory here, but it shows that crs.project is never called,
thus the test is not ever valid.

* MapSpec.js: fix non-valid test

Revert 50a4845a78 and 1b1d96a4c4,
and refactor a bit (rather cosmetical changes)

* MapSpec.js: fix more tests

Refactor before/afterEach hooks for more careful setup/cleanup.

Fix some non-valid tests:
* #remove
  - "undefines container._leaflet"
  - "unbinds events"
* #removeLayer
  - "when the last tile layer on a map is removed"
  - "when a tile layer is removed from a map and it had greater zoom level coverage than the remainding layer"
  - "when a tile layer is removed from a map it and it had lesser or the sa,e zoom level coverage as the remainding layer(s)"

* GridLayerSpec.js: fix some tests

Refactor before/afterEach hooks for more careful setup/cleanup.

Fix some non-valid tests:
* "when a tilelayer is added to a map that already has a tilelayer"

* spec/suites/**: refactor for more careful setup/cleanup

Refactor before/afterEach hooks
Other minor changes

* SpecHelper.js: rename skipIn(non)Phantom to skipIf(No)3d

..to make things more clear

Remove unused helper functions

* Update testing deps

sinon.js: left on 7.5.0 (latest still working on PhantomJS)

karma-rollup-preprocessor: left on 6.1.2 (latest still supporting rollup < 1.0.0)

* CRSSpec.js: workaround round-off error in Chrome

L.CRS.zoom(L.CRS.scale(2.5)) results 2.4999999999999996 in Chrome

Note: comparing floating point numbers properly is hard,
e.g. see https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

* Fix touch tests failing in Chrome

* karma.conf.js: add custom Chrome config to make some tests pass

npm run test-nolint -- --browsers Chrome1280x1024

* spec/.eslintrc: do not forbid no-unused-vars rule

* spec/.eslintrc: do not forbid more rules

no-extend-native
no-irregular-whitespace
no-shadow

* Add karma-edge-launcher

* Add karma-ie-launcher

Some test fails atm, see log:

> karma start ./spec/karma.conf.js "--browsers" "IE"

................................................................................
.....
WARN: 'Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.', undefined
................................................................................
................................................................................
...............................................................
IE 11.0 (Windows 10) ImageOverlay _image when loaded should raise the load event FAILED
	TypeError: Argument not optional
	   at raiseImageEvent (spec/suites/layer/ImageOverlaySpec.js:66:4)
	   at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:74:5)
IE 11.0 (Windows 10) ImageOverlay _image when load fails should raise the error event FAILED
	TypeError: Argument not optional
	   at raiseImageEvent (spec/suites/layer/ImageOverlaySpec.js:66:4)
	   at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:83:5)
IE 11.0 (Windows 10) ImageOverlay _image when load fails should change the image to errorOverlayUrl FAILED
	TypeError: Argument not optional
	   at raiseImageEvent (spec/suites/layer/ImageOverlaySpec.js:66:4)
	   at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:88:5)
..
IE 11.0 (Windows 10) ImageOverlay #setZIndex should update the z-index of the image if it has allready been added to the map FAILED
	Error: expected 1 to equal '1'
	   at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7)
	   at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5)
	   at Anonymous function (node_modules/expect.js/index.js:69:13)
	   at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:111:4)
IE 11.0 (Windows 10) ImageOverlay #setZIndex should set the z-index of the image when it is added to the map FAILED
	Error: expected 10 to equal '10'
	   at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7)
	   at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5)
	   at Anonymous function (node_modules/expect.js/index.js:69:13)
	   at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:121:4)
IE 11.0 (Windows 10) ImageOverlay #setZIndex should use the z-index specified in options FAILED
	Error: expected 20 to equal '20'
	   at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7)
	   at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5)
	   at Anonymous function (node_modules/expect.js/index.js:69:13)
	   at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:127:4)
........................................................................
IE 11.0 (Windows 10) Marker.Drag drag in CSS scaled container drags a marker with mouse, compensating for CSS scale FAILED
	expected 0 to be within -50..-30 (node_modules/expect.js/index.js:102)
................................................................................
...........................................................
WARN: 'Deprecated use of _flat, please use L.LineUtil.isFlat instead.'
.
WARN: 'Deprecated use of _flat, please use L.LineUtil.isFlat instead.'
.......................................................................... 05 2020 15:25:48.917:WARN [web-server]: : /000
 05 2020 15:25:48.938:WARN [web-server]: : /000
......
..
IE 11.0 (Windows 10) Map #invalidateSize pans by the right amount when growing in 1px increments FAILED
	Error: expected 0 to equal 1
	   at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7)
	   at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5)
	   at Anonymous function (node_modules/expect.js/index.js:69:13)
	   at Anonymous function (spec/suites/map/MapSpec.js:649:4)
IE 11.0 (Windows 10) Map #invalidateSize pans by the right amount when shrinking in 1px increments FAILED
	Error: expected 0 to equal -1
	   at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7)
	   at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5)
	   at Anonymous function (node_modules/expect.js/index.js:69:13)
	   at Anonymous function (spec/suites/map/MapSpec.js:667:4)
..
IE 11.0 (Windows 10) Map #invalidateSize emits a move event if the size has changed FAILED
	Error: expected false to be truthy
	   at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7)
	   at Assertion.prototype.ok (node_modules/expect.js/index.js:115:5)
	   at Anonymous function (node_modules/expect.js/index.js:499:7)
	   at Anonymous function (spec/suites/map/MapSpec.js:700:4)
IE 11.0 (Windows 10) Map #invalidateSize emits a moveend event if the size has changed FAILED
	Error: expected false to be truthy
	   at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7)
	   at Assertion.prototype.ok (node_modules/expect.js/index.js:115:5)
	   at Anonymous function (node_modules/expect.js/index.js:499:7)
	   at Anonymous function (spec/suites/map/MapSpec.js:710:4)
IE 11.0 (Windows 10) Map #invalidateSize debounces the moveend event if the debounceMoveend option is given FAILED
	Error: expected false to be truthy
	   at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7)
	   at Assertion.prototype.ok (node_modules/expect.js/index.js:115:5)
	   at Anonymous function (node_modules/expect.js/index.js:499:7)
	   at Anonymous function (spec/suites/map/MapSpec.js:724:4)
IE 11.0 (Windows 10) Map #invalidateSize correctly adjusts for new container size when view is set during map initialization (#6165) FAILED
	Error: expected 0 to equal 100
	   at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7)
	   at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5)
	   at Anonymous function (spec/suites/map/MapSpec.js:745:4)
................
IE 11.0 (Windows 10) Map #fitBounds after layers set Snaps to a number after adding tile layer FAILED
	Error: Access is denied.

	   at createTile (src/Leaflet.js:11698:3)
	   at _addTile (src/Leaflet.js:11433:3)
	   at _update (src/Leaflet.js:11330:5)
	   at _setView (src/Leaflet.js:11191:5)
	   at _resetView (src/Leaflet.js:11146:3)
	   at onAdd (src/Leaflet.js:10784:3)
	   at _layerAdd (src/Leaflet.js:6580:3)
	   at Events.fire (src/Leaflet.js:588:6)
	   at _resetView (src/Leaflet.js:4184:4)
	   at setView (src/Leaflet.js:3181:3)
..............................
IE 11.0 (Windows 10) Map.Drag mouse events in CSS scaled container change the center of the map, compensating for CSS scale FAILED
	expected 31.952162238024975 to be within 21.943..21.9431 (node_modules/expect.js/index.js:102)
IE 11.0 (Windows 10) Map.Drag touch events change the center of the map FAILED
	Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624)
IE 11.0 (Windows 10) Map.Drag touch events does not change the center of the map when finger is moved less than the drag threshold FAILED
	Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624)
IE 11.0 (Windows 10) Map.Drag touch events reset itself after touchend FAILED
	Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624)
.............
IE 11.0 (Windows 10) Map.TouchZoom Increases zoom when pinching out FAILED
	Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624)
IE 11.0 (Windows 10) Map.TouchZoom Decreases zoom when pinching in FAILED
	Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624)
IE 11.0 (Windows 10): Executed 685 of 688 (20 FAILED) (skipped 3) (25.993 secs / 22.211 secs)

* karma.conf.js: additional Firefox configs

- FirefoxPointer
- FirefoxTouch
- FirefoxPointerTouch

* .travis.yml: run CI tests with different Firefox configs

Use FirefoxHeadless

* karma.conf.js: change reporter to default ('progress')

Because 'dots' is confusing when mixed up with different warnings.

But for CI script 'dots' fits better due to travis-ci log qualities.

* .travis.yml: run CI tests with Chrome too
2020-05-04 14:19:14 +03:00