Replace expect.js with Chai (#8952)

This commit is contained in:
Jon Koops 2023-05-15 13:55:28 +02:00 committed by GitHub
parent 0804c8842a
commit 3a5e472e88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 1267 additions and 1240 deletions

View File

@ -124,6 +124,14 @@ jobs:
with:
node-version: ${{ env.NODE_VERSION }}
- name: Set up Google Chrome
uses: browser-actions/setup-chrome@v1
if: contains(matrix.browser, 'Chrome')
- name: Set up Firefox
uses: browser-actions/setup-firefox@v1
if: contains(matrix.browser, 'Firefox')
- name: Run tests on ${{ matrix.browser }}
run: npm test -- --browsers ${{ matrix.browser }} --single-run

187
package-lock.json generated
View File

@ -18,8 +18,8 @@
"http-server": "^14.1.1",
"husky": "^8.0.1",
"karma": "^6.4.1",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.1",
"karma-expect": "^1.1.3",
"karma-firefox-launcher": "^2.1.2",
"karma-mocha": "^2.0.1",
"karma-safarinative-launcher": "^1.1.0",
@ -145,9 +145,9 @@
}
},
"node_modules/@babel/runtime": {
"version": "7.21.0",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.0.tgz",
"integrity": "sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw==",
"version": "7.21.5",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.5.tgz",
"integrity": "sha512-8jI69toZqqcsnqGGqwGS4Qb1VwLOEp4hz+CXPywcvjs60u3B4Pom/U/7rm4W8tMOYEB+E9wgD0mW1l3r8qlI9Q==",
"dev": true,
"dependencies": {
"regenerator-runtime": "^0.13.11"
@ -157,9 +157,9 @@
}
},
"node_modules/@babel/runtime-corejs3": {
"version": "7.21.0",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.21.0.tgz",
"integrity": "sha512-TDD4UJzos3JJtM+tHX+w2Uc+KWj7GV+VKKFdMVd2Rx8sdA19hcc3P3AHFYd5LVOw+pYuSd5lICC3gm52B6Rwxw==",
"version": "7.21.5",
"resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.21.5.tgz",
"integrity": "sha512-FRqFlFKNazWYykft5zvzuEl1YyTDGsIRrjV9rvxvYkUC7W/ueBng1X68Xd6uRMzAaJ0xMKn08/wem5YS1lpX8w==",
"dev": true,
"dependencies": {
"core-js-pure": "^3.25.1",
@ -194,9 +194,9 @@
}
},
"node_modules/@eslint-community/regexpp": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.0.tgz",
"integrity": "sha512-vITaYzIcNmjn5tF5uxcZ/ft7/RXGrMUIS9HalWckEOF6ESiwXKoMzAQf2UW0aVd6rnOeExTJVd5hmWXucBKGXQ==",
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.1.tgz",
"integrity": "sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==",
"dev": true,
"engines": {
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
@ -445,9 +445,9 @@
}
},
"node_modules/@types/estree": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz",
"integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==",
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.1.tgz",
"integrity": "sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==",
"dev": true
},
"node_modules/@types/json5": {
@ -463,9 +463,9 @@
"dev": true
},
"node_modules/@types/node": {
"version": "18.15.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz",
"integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==",
"version": "20.1.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.1.3.tgz",
"integrity": "sha512-NP2yfZpgmf2eDRPmgGq+fjGjSwFgYbihA8/gK+ey23qT9RkxsgNTZvGOEpXgzIGqesTYkElELLgtKoMQTys5vA==",
"dev": true
},
"node_modules/@types/parse-json": {
@ -684,6 +684,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/assertion-error": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz",
"integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==",
"dev": true,
"peer": true,
"engines": {
"node": "*"
}
},
"node_modules/astral-regex": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz",
@ -721,9 +731,9 @@
}
},
"node_modules/axios": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.3.5.tgz",
"integrity": "sha512-glL/PvG/E+xCWwV8S6nCHcrfg1exGx7vxyUIivIA1iL7BIh6bePylCfVHwp6k13ao7SATxB6imau2kqY+I67kw==",
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz",
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
"dev": true,
"dependencies": {
"follow-redirects": "^1.15.0",
@ -939,6 +949,25 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/chai": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz",
"integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==",
"dev": true,
"peer": true,
"dependencies": {
"assertion-error": "^1.1.0",
"check-error": "^1.0.2",
"deep-eql": "^4.1.2",
"get-func-name": "^2.0.0",
"loupe": "^2.3.1",
"pathval": "^1.1.1",
"type-detect": "^4.0.5"
},
"engines": {
"node": ">=4"
}
},
"node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
@ -955,6 +984,16 @@
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/check-error": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
"integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==",
"dev": true,
"peer": true,
"engines": {
"node": "*"
}
},
"node_modules/chokidar": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
@ -1111,9 +1150,9 @@
"dev": true
},
"node_modules/colorette": {
"version": "2.0.19",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz",
"integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==",
"version": "2.0.20",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz",
"integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==",
"dev": true
},
"node_modules/columnify": {
@ -1214,9 +1253,9 @@
}
},
"node_modules/core-js-pure": {
"version": "3.30.1",
"resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.30.1.tgz",
"integrity": "sha512-nXBEVpmUnNRhz83cHd9JRQC52cTMcuXAmR56+9dSMpRdpeA4I1PX6yjmhd71Eyc/wXNsdBdUDIj1QTIeZpU5Tg==",
"version": "3.30.2",
"resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.30.2.tgz",
"integrity": "sha512-p/npFUJXXBkCCTIlEGBdghofn00jWG6ZOtdoIXSJmAu2QBvN0IqpZXWweOytcwE6cfx8ZvVUy1vw8zxhe4Y2vg==",
"dev": true,
"hasInstallScript": true,
"funding": {
@ -1320,6 +1359,19 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/deep-eql": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz",
"integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==",
"dev": true,
"peer": true,
"dependencies": {
"type-detect": "^4.0.0"
},
"engines": {
"node": ">=6"
}
},
"node_modules/deep-is": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
@ -1913,12 +1965,6 @@
"node": ">=8"
}
},
"node_modules/expect.js": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/expect.js/-/expect.js-0.3.1.tgz",
"integrity": "sha512-okDF/FAPEul1ZFLae4hrgpIqAeapoo5TRdcg/lD0iN9S3GWrBFIJwNezGH1DMtIz+RxU4RrFmMq7WUUvDg3J6A==",
"dev": true
},
"node_modules/extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
@ -2184,6 +2230,16 @@
"node": "6.* || 8.* || >= 10.*"
}
},
"node_modules/get-func-name": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",
"integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==",
"dev": true,
"peer": true,
"engines": {
"node": "*"
}
},
"node_modules/get-intrinsic": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz",
@ -3113,6 +3169,16 @@
"node": ">= 10"
}
},
"node_modules/karma-chai": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/karma-chai/-/karma-chai-0.1.0.tgz",
"integrity": "sha512-mqKCkHwzPMhgTYca10S90aCEX9+HjVjjrBFAsw36Zj7BlQNbokXXCAe6Ji04VUMsxcY5RLP7YphpfO06XOubdg==",
"dev": true,
"peerDependencies": {
"chai": "*",
"karma": ">=0.10.9"
}
},
"node_modules/karma-chrome-launcher": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-3.2.0.tgz",
@ -3134,15 +3200,6 @@
"which": "bin/which"
}
},
"node_modules/karma-expect": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/karma-expect/-/karma-expect-1.1.3.tgz",
"integrity": "sha512-a4MvikmSLA+G4ikJY6VVGGX2Pmc8eLL+QUXftR7dGMcIt5+qCIotSj7XWifDI5IQVHDnouZgqnQIjZAiFK8oVg==",
"dev": true,
"dependencies": {
"expect.js": "^0.3.1"
}
},
"node_modules/karma-firefox-launcher": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.2.tgz",
@ -3632,6 +3689,16 @@
"node": ">=8.0"
}
},
"node_modules/loupe": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz",
"integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==",
"dev": true,
"peer": true,
"dependencies": {
"get-func-name": "^2.0.0"
}
},
"node_modules/markdown-it": {
"version": "11.0.1",
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-11.0.1.tgz",
@ -4266,6 +4333,16 @@
"node": ">=8"
}
},
"node_modules/pathval": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",
"integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==",
"dev": true,
"peer": true,
"engines": {
"node": "*"
}
},
"node_modules/picomatch": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
@ -4469,14 +4546,14 @@
"dev": true
},
"node_modules/regexp.prototype.flags": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz",
"integrity": "sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==",
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz",
"integrity": "sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==",
"dev": true,
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3",
"functions-have-names": "^1.2.2"
"define-properties": "^1.2.0",
"functions-have-names": "^1.2.3"
},
"engines": {
"node": ">= 0.4"
@ -4501,12 +4578,12 @@
"dev": true
},
"node_modules/resolve": {
"version": "1.22.3",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.3.tgz",
"integrity": "sha512-P8ur/gp/AmbEzjr729bZnLjXK5Z+4P0zhIJgBgzqRih7hL7BOukHGtSTA3ACMY467GRFz3duQsi0bDZdR7DKdw==",
"version": "1.22.2",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz",
"integrity": "sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==",
"dev": true,
"dependencies": {
"is-core-module": "^2.12.0",
"is-core-module": "^2.11.0",
"path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0"
},
@ -4700,9 +4777,9 @@
}
},
"node_modules/rxjs": {
"version": "7.8.0",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.0.tgz",
"integrity": "sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==",
"version": "7.8.1",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz",
"integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==",
"dev": true,
"dependencies": {
"tslib": "^2.1.0"
@ -4977,9 +5054,9 @@
}
},
"node_modules/string-argv": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz",
"integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==",
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz",
"integrity": "sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==",
"dev": true,
"engines": {
"node": ">=0.6.19"

View File

@ -13,8 +13,8 @@
"http-server": "^14.1.1",
"husky": "^8.0.1",
"karma": "^6.4.1",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.1",
"karma-expect": "^1.1.3",
"karma-firefox-launcher": "^2.1.2",
"karma-mocha": "^2.0.1",
"karma-safarinative-launcher": "^1.1.0",

View File

@ -1,7 +1,8 @@
/** @type {import('eslint').Linter.Config } */
module.exports = {
rules: {
'no-console': 'off'
'no-console': 'off',
'no-unused-expressions': 'off'
},
env: {
mocha: true,
@ -9,6 +10,7 @@ module.exports = {
globals: {
L: true,
expect: false,
chai: false,
sinon: false,
UIEventSimulator: false,
Hand: false,

View File

@ -5,13 +5,13 @@ module.exports = function (/** @type {import('karma').Config} */ config) {
plugins: [
'karma-mocha',
'karma-sinon',
'karma-expect',
'karma-chai',
'karma-chrome-launcher',
'karma-safarinative-launcher',
'karma-firefox-launcher',
'karma-time-stats-reporter'
],
frameworks: ['mocha', 'sinon', 'expect'],
frameworks: ['mocha', 'sinon', 'chai'],
files: [
'spec/before.js',
{pattern: 'dist/leaflet-src.js'},

View File

@ -1,20 +1,16 @@
expect.Assertion.prototype.near = function (expected, delta) {
chai.util.addMethod(chai.Assertion.prototype, 'near', function (expected, delta = 1) {
expected = L.point(expected);
delta = delta || 1;
expect(this.obj.x).to
.be.within(expected.x - delta, expected.x + delta);
expect(this.obj.y).to
.be.within(expected.y - delta, expected.y + delta);
};
expect.Assertion.prototype.nearLatLng = function (expected, delta) {
new chai.Assertion(this._obj.x).to.be.within(expected.x - delta, expected.x + delta);
new chai.Assertion(this._obj.y).to.be.within(expected.y - delta, expected.y + delta);
});
chai.util.addMethod(chai.Assertion.prototype, 'nearLatLng', function (expected, delta = 1e-4) {
expected = L.latLng(expected);
delta = delta || 1e-4;
expect(this.obj.lat).to
.be.within(expected.lat - delta, expected.lat + delta);
expect(this.obj.lng).to
.be.within(expected.lng - delta, expected.lng + delta);
};
new chai.Assertion(this._obj.lat).to.be.within(expected.lat - delta, expected.lat + delta);
new chai.Assertion(this._obj.lng).to.be.within(expected.lng - delta, expected.lng + delta);
});
// A couple of tests need the browser to be touch-capable
it.skipIfNotTouch = L.Browser.touch ? it : it.skip;

View File

@ -20,13 +20,13 @@ describe('Control.Layers', () => {
map.on('baselayerchange', spy);
UIEventSimulator.fire('click', layers._baseLayersList.getElementsByTagName('input')[0]);
expect(spy.called).to.be.ok();
expect(spy.args[0][0].name).to.be('Layer 1');
expect(spy.args[0][0].layer).to.be(baseLayers['Layer 1']);
expect(spy.called).to.be.true;
expect(spy.args[0][0].name).to.equal('Layer 1');
expect(spy.args[0][0].layer).to.equal(baseLayers['Layer 1']);
UIEventSimulator.fire('click', layers._baseLayersList.getElementsByTagName('input')[1]);
expect(spy.calledTwice).to.be.ok();
expect(spy.args[1][0].name).to.be('Layer 2');
expect(spy.args[1][0].layer).to.be(baseLayers['Layer 2']);
expect(spy.calledTwice).to.be.true;
expect(spy.args[1][0].name).to.equal('Layer 2');
expect(spy.args[1][0].layer).to.equal(baseLayers['Layer 2']);
});
it('works after removing and readding the Control.Layers to the map', () => {
@ -40,13 +40,13 @@ describe('Control.Layers', () => {
map.addControl(layers);
UIEventSimulator.fire('click', layers._baseLayersList.getElementsByTagName('input')[0]);
expect(spy.called).to.be.ok();
expect(spy.args[0][0].name).to.be('Layer 1');
expect(spy.args[0][0].layer).to.be(baseLayers['Layer 1']);
expect(spy.called).to.be.true;
expect(spy.args[0][0].name).to.equal('Layer 1');
expect(spy.args[0][0].layer).to.equal(baseLayers['Layer 1']);
UIEventSimulator.fire('click', layers._baseLayersList.getElementsByTagName('input')[1]);
expect(spy.calledTwice).to.be.ok();
expect(spy.args[1][0].name).to.be('Layer 2');
expect(spy.args[1][0].layer).to.be(baseLayers['Layer 2']);
expect(spy.calledTwice).to.be.true;
expect(spy.args[1][0].name).to.equal('Layer 2');
expect(spy.args[1][0].layer).to.equal(baseLayers['Layer 2']);
});
it('is not fired on input that doesn\'t change the base layer', () => {
@ -57,7 +57,7 @@ describe('Control.Layers', () => {
map.on('baselayerchange', spy);
UIEventSimulator.fire('click', layers._overlaysList.getElementsByTagName('input')[0]);
expect(spy.called).to.not.be.ok();
expect(spy.called).to.be.false;
});
});
@ -72,7 +72,7 @@ describe('Control.Layers', () => {
map.addLayer(overlay);
map.removeLayer(overlay);
expect(spy.called).to.be.ok();
expect(spy.called).to.be.true;
expect(spy.callCount).to.eql(2);
});
@ -85,11 +85,11 @@ describe('Control.Layers', () => {
return !!(map._container.querySelector('.leaflet-control-layers-overlays input').checked);
}
expect(isChecked()).to.not.be.ok();
expect(isChecked()).to.be.false;
map.addLayer(overlay);
expect(isChecked()).to.be.ok();
expect(isChecked()).to.be.true;
map.removeLayer(overlay);
expect(isChecked()).to.not.be.ok();
expect(isChecked()).to.be.false;
});
it('not when a non-included layer is added or removed', () => {
@ -102,7 +102,7 @@ describe('Control.Layers', () => {
map.addLayer(overlay);
map.removeLayer(overlay);
expect(spy.called).to.not.be.ok();
expect(spy.called).to.be.false;
});
it('updates when an included layer is removed from the control', () => {
@ -120,7 +120,7 @@ describe('Control.Layers', () => {
expect(() => {
layers.removeLayer(L.marker([0, 0]));
}).to.not.throwException();
}).to.not.throw();
expect(layers._layers.length).to.be.equal(1);
});
@ -133,7 +133,7 @@ describe('Control.Layers', () => {
function checkInputs(idx) {
const inputs = map._container.querySelectorAll('.leaflet-control-layers-base input');
for (let i = 0; i < inputs.length; i++) {
expect(inputs[i].checked === (idx === i)).to.be.ok();
expect(inputs[i].checked === (idx === i)).to.be.true;
}
}
@ -160,7 +160,7 @@ describe('Control.Layers', () => {
expect(() => {
map.removeLayer(baseLayer);
}).to.not.throwException();
}).to.not.throw();
});
it('and layers in the control can still be removed when added after removing control from map', () => {
@ -171,19 +171,19 @@ describe('Control.Layers', () => {
expect(() => {
map.removeLayer(baseLayer);
}).to.not.throwException();
}).to.not.throw();
});
});
describe('is created with an expand link', () => {
it('when collapsed', () => {
L.control.layers(null, null, {collapsed: true}).addTo(map);
expect(map._container.querySelector('.leaflet-control-layers-toggle')).to.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-toggle')).to.be.ok;
});
it('when not collapsed', () => {
L.control.layers(null, null, {collapsed: false}).addTo(map);
expect(map._container.querySelector('.leaflet-control-layers-toggle')).to.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-toggle')).to.be.ok;
});
});
@ -192,59 +192,59 @@ describe('Control.Layers', () => {
const layersCtrl = L.control.layers(null, null, {collapsed: true}).addTo(map);
const toggle = layersCtrl._container.querySelector('.leaflet-control-layers-toggle');
UIEventSimulator.fire('keydown', toggle, {code: 'Enter'});
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok;
});
it('expands on click', () => {
const layersCtrl = L.control.layers(null, null, {collapsed: true}).addTo(map);
const toggle = layersCtrl._container.querySelector('.leaflet-control-layers-toggle');
UIEventSimulator.fire('click', toggle);
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok;
});
it('does not expand on "Enter" keydown when toggle is not focused', () => {
L.control.layers(null, null, {collapsed: true}).addTo(map);
UIEventSimulator.fire('keydown', document, {code:'Enter'});
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.not.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.null;
});
it('expands when mouse is over', () => {
const layersCtrl = L.control.layers(null, null, {collapsed: true}).addTo(map);
UIEventSimulator.fire('mouseover', layersCtrl._container);
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok;
});
it('collapses when mouse is out', () => {
const layersCtrl = L.control.layers(null, null, {collapsed: true}).addTo(map);
UIEventSimulator.fire('mouseover', layersCtrl._container);
UIEventSimulator.fire('mouseout', layersCtrl._container);
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.not.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.null;
});
it('collapses when map is clicked', () => {
const layersCtrl = L.control.layers(null, null, {collapsed: true}).addTo(map);
UIEventSimulator.fire('mouseover', layersCtrl._container);
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok;
UIEventSimulator.fire('click', map._container);
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.not.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.null;
});
});
describe('does not collapse when collapsed: false', () => {
it('does not collapse when mouse enters or leaves', () => {
const layersCtrl = L.control.layers(null, null, {collapsed: false}).addTo(map);
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok;
UIEventSimulator.fire('mouseover', layersCtrl._container);
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok;
UIEventSimulator.fire('mouseout', layersCtrl._container);
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok;
});
it('does not collapse when map is clicked', () => {
L.control.layers(null, null, {collapsed: false}).addTo(map);
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok;
UIEventSimulator.fire('click', map._container);
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok();
expect(map._container.querySelector('.leaflet-control-layers-expanded')).to.be.ok;
});
it('is scrollable if necessary when added on map', () => {
@ -266,7 +266,7 @@ describe('Control.Layers', () => {
expect(container.clientHeight).to.be.greaterThan(0); // Make sure first that the map container has a height, otherwise this test is useless.
expect(container.clientHeight).to.be.greaterThan(layersCtrl._container.clientHeight);
expect(layersCtrl._section.classList.contains('leaflet-control-layers-scrollbar')).to.be(true);
expect(layersCtrl._section.classList.contains('leaflet-control-layers-scrollbar')).to.be.true;
});
it('becomes scrollable if necessary when too many layers are added while it is already on map', () => {
@ -280,7 +280,7 @@ describe('Control.Layers', () => {
map = L.map(container);
layersCtrl.addTo(map);
expect(layersCtrl._section.classList.contains('leaflet-control-layers-scrollbar')).to.be(false);
expect(layersCtrl._section.classList.contains('leaflet-control-layers-scrollbar')).to.be.false;
for (; i < 20; i += 1) {
// Default text size: 12px => 12 * 20 = 240px height (not even considering padding/margin).
@ -288,7 +288,7 @@ describe('Control.Layers', () => {
}
expect(container.clientHeight).to.be.greaterThan(layersCtrl._container.clientHeight);
expect(layersCtrl._section.classList.contains('leaflet-control-layers-scrollbar')).to.be(true);
expect(layersCtrl._section.classList.contains('leaflet-control-layers-scrollbar')).to.be.true;
});
});

View File

@ -42,7 +42,7 @@ describe('Control', () => {
it('calls onRemove if defined', () => {
control.onRemove = sinon.spy();
control.remove();
expect(control.onRemove.called).to.be(true);
expect(control.onRemove.called).to.be.true;
});
it('is a no-op if the control has not been added', () => {

View File

@ -24,12 +24,12 @@ describe('Class', () => {
it('creates a class with the given constructor & properties', () => {
const a = new Klass();
expect(constructor.called).to.be.ok();
expect(constructor.called).to.be.true;
expect(a.foo).to.eql(5);
a.bar();
expect(method.called).to.be.ok();
expect(method.called).to.be.true;
});
it('inherits parent classes\' constructor & properties', () => {
@ -37,15 +37,15 @@ describe('Class', () => {
const b = new Klass2();
expect(b instanceof Klass).to.be.ok();
expect(b instanceof Klass2).to.be.ok();
expect(b instanceof Klass).to.be.true;
expect(b instanceof Klass2).to.be.true;
expect(constructor.called).to.be.ok();
expect(constructor.called).to.be.true;
expect(b.baz).to.eql(2);
b.bar();
expect(method.called).to.be.ok();
expect(method.called).to.be.true;
});
it('does not modify source props object', () => {
@ -64,7 +64,7 @@ describe('Class', () => {
});
it('does not merge \'statics\' property itself', () => {
expect('statics' in Klass.prototype).to.not.be.ok();
expect('statics' in Klass.prototype).to.be.false;
});
it('inherits parent static properties', () => {
@ -81,11 +81,11 @@ describe('Class', () => {
it('includes the given mixin', () => {
const a = new Klass();
expect(a.mixin).to.be.ok();
expect(a.mixin).to.be.true;
});
it('does not merge \'includes\' property itself', () => {
expect('includes' in Klass.prototype).to.not.be.ok();
expect('includes' in Klass.prototype).to.be.false;
});
it('includes multiple mixins', () => {
@ -94,15 +94,15 @@ describe('Class', () => {
});
const a = new Klass2();
expect(a.mixin).to.be.ok();
expect(a.mixin2).to.be.ok();
expect(a.mixin).to.be.true;
expect(a.mixin2).to.be.true;
});
it('grants the ability to include the given mixin', () => {
Klass.include({mixin2: true});
const a = new Klass();
expect(a.mixin2).to.be.ok();
expect(a.mixin2).to.be.true;
});
it('merges options instead of replacing them', () => {
@ -142,7 +142,7 @@ describe('Class', () => {
const props = {options: {}};
const K = L.Class.extend(props);
expect(K.prototype.options).not.to.be(props.options);
expect(K.prototype.options).not.to.equal(props.options);
});
it('does not replace source props.options object', () => {
@ -151,13 +151,13 @@ describe('Class', () => {
const props = {options: opts};
K1.extend(props);
expect(props.options).to.be(opts);
expect(props.options).to.equal(opts);
});
it('prevents change of prototype options', () => {
const Klass = L.Class.extend({options: {}});
const instance = new Klass();
expect(Klass.prototype.options).to.not.be(instance.options);
expect(Klass.prototype.options).to.not.equal(instance.options);
});
it('adds constructor hooks correctly', () => {
@ -168,7 +168,7 @@ describe('Class', () => {
new Klass();
expect(spy1.called).to.be.ok();
expect(spy1.called).to.be.true;
expect(method.calledWith(1, 2, 3));
});
@ -183,8 +183,8 @@ describe('Class', () => {
new Klass2();
expect(spy1.called).to.be.ok();
expect(spy2.called).to.be.ok();
expect(spy1.called).to.be.true;
expect(spy2.called).to.be.true;
});
it('does not call child constructor hooks', () => {
@ -198,7 +198,7 @@ describe('Class', () => {
new Klass();
expect(spy1.called).to.be.ok();
expect(spy1.called).to.be.true;
expect(spy2.called).to.eql(false);
});
@ -210,7 +210,7 @@ describe('Class', () => {
const Klass2 = Klass.extend({});
new Klass2();
expect(spy1.called).to.be.ok();
expect(spy1.called).to.be.true;
});
});
@ -231,10 +231,10 @@ describe('Class', () => {
const b = new Qlass();
a.quux();
expect(q.called).to.be.ok();
expect(q.called).to.be.true;
b.quux();
expect(q.called).to.be.ok();
expect(q.called).to.be.true;
});
it('keeps parent options', () => { // #6070
@ -256,7 +256,7 @@ describe('Class', () => {
const props = {options: {}};
const K = Klass.include(props);
expect(K.prototype.options).not.to.be(props.options);
expect(K.prototype.options).not.to.equal(props.options);
});
it('does not replace source props.options object', () => {
@ -265,7 +265,7 @@ describe('Class', () => {
const props = {options: opts};
K1.extend(props);
expect(props.options).to.be(opts);
expect(props.options).to.equal(opts);
});
});

View File

@ -15,22 +15,22 @@ describe('Events', () => {
obj.addEventListener({test: spy4, other: spy5});
// obj.addEventListener({'test other': spy6 });
expect(spy1.called).to.be(false);
expect(spy2.called).to.be(false);
expect(spy3.called).to.be(false);
expect(spy4.called).to.be(false);
expect(spy5.called).to.be(false);
// expect(spy6.called).to.be(false);
expect(spy1.called).to.be.false;
expect(spy2.called).to.be.false;
expect(spy3.called).to.be.false;
expect(spy4.called).to.be.false;
expect(spy5.called).to.be.false;
// expect(spy6.called).to.be.false;
obj.fireEvent('test');
expect(spy1.called).to.be(true);
expect(spy2.called).to.be(true);
expect(spy3.called).to.be(false);
expect(spy4.called).to.be(true);
expect(spy5.called).to.be(false);
// expect(spy6.called).to.be(true);
// expect(spy6.callCount).to.be(1);
expect(spy1.called).to.be.true;
expect(spy2.called).to.be.true;
expect(spy3.called).to.be.false;
expect(spy4.called).to.be.true;
expect(spy5.called).to.be.false;
// expect(spy6.called).to.be.true;
// expect(spy6.callCount).to.equal(1);
});
it('fires all listeners in the order they are added', () => {
@ -83,10 +83,10 @@ describe('Events', () => {
obj.fireEvent('test');
expect(count.one).to.be(1);
expect(count.two).to.be(3);
expect(count.three).to.be(2);
expect(count.four).to.be(1);
expect(count.one).to.equal(1);
expect(count.two).to.equal(3);
expect(count.three).to.equal(2);
expect(count.four).to.equal(1);
});
it('provides event object to listeners and executes them in the right context', () => {
@ -148,7 +148,7 @@ describe('Events', () => {
obj.fireEvent('test');
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
obj.addEventListener('test2', spy2);
obj.addEventListener('test2', spy3);
@ -156,8 +156,8 @@ describe('Events', () => {
obj.fireEvent('test2');
expect(spy2.called).to.be(false);
expect(spy3.called).to.be(false);
expect(spy2.called).to.be.false;
expect(spy3.called).to.be.false;
obj.addEventListener('test3', spy4);
obj.addEventListener('test4', spy5);
@ -169,8 +169,8 @@ describe('Events', () => {
obj.fireEvent('test3');
obj.fireEvent('test4');
expect(spy4.called).to.be(false);
expect(spy5.called).to.be(false);
expect(spy4.called).to.be.false;
expect(spy5.called).to.be.false;
});
it('can handle calls to #removeEventListener on objects with no registered event listeners', () => {
@ -178,7 +178,7 @@ describe('Events', () => {
const removeNonExistentListener = function () {
obj.removeEventListener('test');
};
expect(removeNonExistentListener).to.not.throwException();
expect(removeNonExistentListener).to.not.throw();
});
// added due to context-sensitive removeListener optimization
@ -195,8 +195,8 @@ describe('Events', () => {
obj.fireEvent('test');
expect(spy1.called).to.be(true);
expect(spy2.called).to.be(true);
expect(spy1.called).to.be.true;
expect(spy2.called).to.be.true;
});
it('removes listeners with stamped contexts', () => {
@ -214,8 +214,8 @@ describe('Events', () => {
obj.fireEvent('test');
expect(spy1.called).to.be(false);
expect(spy2.called).to.be(true);
expect(spy1.called).to.be.false;
expect(spy2.called).to.be.true;
});
it('removes listeners with a stamp originally added without one', () => {
@ -233,8 +233,8 @@ describe('Events', () => {
obj.fireEvent('test');
expect(spy1.called).to.be(false);
expect(spy2.called).to.be(false);
expect(spy1.called).to.be.false;
expect(spy2.called).to.be.false;
});
it('removes listeners with context == this and a stamp originally added without one', () => {
@ -255,9 +255,9 @@ describe('Events', () => {
obj.fireEvent('test');
expect(spy1.called).to.be(false);
expect(spy2.called).to.be(false);
expect(spy3.called).to.be(false);
expect(spy1.called).to.be.false;
expect(spy2.called).to.be.false;
expect(spy3.called).to.be.false;
});
it('doesnt lose track of listeners when removing non existent ones', () => {
@ -279,7 +279,7 @@ describe('Events', () => {
obj.fireEvent('test');
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
});
it('correctly removes all listeners if given no fn', () => {
@ -293,19 +293,19 @@ describe('Events', () => {
obj.removeEventListener('test'); // Removes both of the above listeners
expect(obj.listens('test')).to.be(false);
expect(obj.listens('test')).to.be.false;
// Add and remove a listener
obj.addEventListener('test', spy, foo2);
obj.removeEventListener('test', spy, foo2);
expect(obj.listens('test')).to.be(false);
expect(obj.listens('test')).to.be.false;
// Add and remove a listener without context
obj.addEventListener('test', spy);
obj.removeEventListener('test', spy);
expect(obj.listens('test')).to.be(false);
expect(obj.listens('test')).to.be.false;
});
it('makes sure an event is not triggered if a listener is removed during dispatch', () => {
@ -319,7 +319,7 @@ describe('Events', () => {
obj.addEventListener('test', spy);
obj.fireEvent('test');
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
/* with context */
obj.addEventListener('test2', () => { obj.removeEventListener('test2', spy2, foo); }, foo);
@ -335,7 +335,7 @@ describe('Events', () => {
obj.addEventListener('test', spy);
obj.fire('test');
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
});
it('handles reentrant event firing', () => {
@ -354,8 +354,8 @@ describe('Events', () => {
.addEventListener('test1', spy2);
obj.fireEvent('test1');
expect(spy1.called).to.be(true);
expect(spy2.called).to.be(false);
expect(spy1.called).to.be.true;
expect(spy2.called).to.be.false;
});
it('can remove an event listener while firing', () => {
@ -373,7 +373,7 @@ describe('Events', () => {
obj.removeEventListener('test', removeSpy);
expect(obj.listens('test')).to.be(false);
expect(obj.listens('test')).to.be.false;
});
});
@ -384,7 +384,7 @@ describe('Events', () => {
obj.off('test', undefined);
obj.off({test: undefined});
expect(obj.listens('test')).to.be(true);
expect(obj.listens('test')).to.be.true;
});
it('ignores non-function listeners passed', () => {
@ -392,8 +392,8 @@ describe('Events', () => {
const off = obj.off.bind(obj);
['string', {}, [], true, false, undefined].forEach((fn) => {
obj.on('test', fn);
expect(obj.listens('test')).to.be(false);
expect(off).withArgs('test', fn).to.not.throwException();
expect(obj.listens('test')).to.be.false;
expect(() => off('test', fn)).to.not.throw();
});
});
@ -403,8 +403,8 @@ describe('Events', () => {
const off = obj.off.bind(obj);
// todo? make it throw with []
[true, false, undefined, 1].forEach((type) => {
expect(on).withArgs(type, L.Util.falseFn).to.throwException();
expect(off).withArgs(type, L.Util.falseFn).to.throwException();
expect(() => on(type, L.Util.falseFn)).to.throw();
expect(() => off(type, L.Util.falseFn)).to.throw();
});
// todo? make `fire` and `listen` to throw with wrong type
@ -417,7 +417,7 @@ describe('Events', () => {
obj.on('test', spy);
obj.fire('test');
expect(spy.called).to.be(true);
expect(spy.called).to.be.true;
obj.off('test', spy);
obj.fireEvent('test');
@ -439,13 +439,13 @@ describe('Events', () => {
const obj = new Klass();
obj.on();
expect(spy1.called).to.be(true);
expect(spy1.called).to.be.true;
obj.off();
expect(spy2.called).to.be(true);
expect(spy2.called).to.be.true;
obj.fire();
expect(spy3.called).to.be(true);
expect(spy3.called).to.be.true;
});
it('does not add twice the same function', () => {
@ -476,7 +476,7 @@ describe('Events', () => {
obj.fire('test');
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
});
});
@ -488,7 +488,7 @@ describe('Events', () => {
obj.once('test', spy, obj);
obj.fire('test');
expect(spy.called).to.be(true);
expect(spy.called).to.be.true;
obj.fire('test');
@ -508,8 +508,8 @@ describe('Events', () => {
obj.fire('test');
obj.fire('otherTest');
expect(spy.called).to.be(true);
expect(otherSpy.called).to.be(true);
expect(spy.called).to.be.true;
expect(otherSpy.called).to.be.true;
obj.fire('test');
obj.fire('otherTest');
@ -527,7 +527,7 @@ describe('Events', () => {
obj.fire('test');
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
});
it('doesn\'t call once twice', () => {
@ -540,7 +540,7 @@ describe('Events', () => {
obj.fire('test');
expect(spy.calledOnce).to.be(true);
expect(spy.calledOnce).to.be.true;
});
@ -553,7 +553,7 @@ describe('Events', () => {
obj.fire('test');
expect(spy.called).to.be(true);
expect(spy.called).to.be.true;
});
});
@ -572,20 +572,20 @@ describe('Events', () => {
obj.fire('test');
expect(spy1.called).to.be(false);
expect(spy2.called).to.be(false);
expect(spy1.called).to.be.false;
expect(spy2.called).to.be.false;
obj.fire('test', null, true);
expect(spy1.called).to.be(true);
expect(spy2.called).to.be(true);
expect(spy1.called).to.be.true;
expect(spy2.called).to.be.true;
obj.removeEventParent(parent1);
obj.fire('test', null, true);
expect(spy1.callCount).to.be(1);
expect(spy2.callCount).to.be(2);
expect(spy1.callCount).to.equal(1);
expect(spy2.callCount).to.equal(2);
});
it('can fire event where child has no listeners', () => {
@ -626,7 +626,7 @@ describe('Events', () => {
type: 'test2',
target: obj,
sourceTarget: obj
})).to.be.ok();
})).to.be.true;
expect(spy2.calledWith({
type: 'test2',
target: parent,
@ -635,7 +635,7 @@ describe('Events', () => {
layer: obj,
sourceTarget: obj,
propagatedFrom: obj
})).to.be.ok();
})).to.be.true;
});
});
@ -643,7 +643,7 @@ describe('Events', () => {
it('is false if there is no event handler', () => {
const obj = new L.Evented();
expect(obj.listens('test')).to.be(false);
expect(obj.listens('test')).to.be.false;
});
it('is true if there is an event handler', () => {
@ -651,7 +651,7 @@ describe('Events', () => {
spy = sinon.spy();
obj.on('test', spy);
expect(obj.listens('test')).to.be(true);
expect(obj.listens('test')).to.be.true;
});
it('is false if event handler has been removed', () => {
@ -660,7 +660,7 @@ describe('Events', () => {
obj.on('test', spy);
obj.off('test', spy);
expect(obj.listens('test')).to.be(false);
expect(obj.listens('test')).to.be.false;
});
it('changes for a "once" handler', () => {
@ -668,10 +668,10 @@ describe('Events', () => {
spy = sinon.spy();
obj.once('test', spy);
expect(obj.listens('test')).to.be(true);
expect(obj.listens('test')).to.be.true;
obj.fire('test');
expect(obj.listens('test')).to.be(false);
expect(obj.listens('test')).to.be.false;
});
it('returns true if event handler with specific function and context is existing', () => {
@ -683,17 +683,17 @@ describe('Events', () => {
obj.on('test', spy);
// event handler 'test' is existing
expect(obj.listens('test')).to.be(true);
expect(obj.listens('test')).to.be.true;
// event handler with specific function is existing
expect(obj.listens('test', spy)).to.be(true); // context arg: undefined === this
expect(obj.listens('test', spy, obj)).to.be(true);
expect(obj.listens('test', spy)).to.be.true; // context arg: undefined === this
expect(obj.listens('test', spy, obj)).to.be.true;
// event handler with specific function and other context is not existing
expect(obj.listens('test', spy, differentContext)).to.be(false);
expect(obj.listens('test', spy, differentContext)).to.be.false;
// event handler with specific function is not existing
expect(obj.listens('test', diffentFnc)).to.be(false);
expect(obj.listens('test', diffentFnc)).to.be.false;
});
it('is true if there is an event handler on parent', () => {
@ -702,8 +702,8 @@ describe('Events', () => {
spy = sinon.spy();
fg.on('test', spy);
expect(marker.listens('test', false)).to.be(false);
expect(marker.listens('test', true)).to.be(true);
expect(marker.listens('test', false)).to.be.false;
expect(marker.listens('test', true)).to.be.true;
});
it('is true if there is an event handler on parent parent', () => {
@ -713,8 +713,8 @@ describe('Events', () => {
spy = sinon.spy();
fgP.on('test', spy);
expect(marker.listens('test', false)).to.be(false);
expect(marker.listens('test', true)).to.be(true);
expect(marker.listens('test', false)).to.be.false;
expect(marker.listens('test', true)).to.be.true;
});
it('is true if there is an event handler with specific function on parent', () => {
@ -723,10 +723,10 @@ describe('Events', () => {
spy = sinon.spy();
fg.on('test', spy);
expect(marker.listens('test', spy, marker, false)).to.be(false);
expect(marker.listens('test', spy, marker, true)).to.be(false);
expect(marker.listens('test', spy, fg, false)).to.be(false);
expect(marker.listens('test', spy, fg, true)).to.be(true);
expect(marker.listens('test', spy, marker, false)).to.be.false;
expect(marker.listens('test', spy, marker, true)).to.be.false;
expect(marker.listens('test', spy, fg, false)).to.be.false;
expect(marker.listens('test', spy, fg, true)).to.be.true;
});
});
});

View File

@ -50,7 +50,7 @@ describe('Util', () => {
describe('#falseFn', () => {
it('returns false', () => {
expect(L.Util.falseFn()).to.be(false);
expect(L.Util.falseFn()).to.be.false;
});
});
@ -201,7 +201,7 @@ describe('Util', () => {
it('throws when a template token is not given', () => {
expect(() => {
L.Util.template(undefined, {foo: 'bar'});
}).to.throwError();
}).to.throw();
});
it('allows underscores, dashes and spaces in placeholders', () => {

View File

@ -20,8 +20,8 @@ describe('DomEvent.DoubleTapSpec.js', () => {
clock.tick(100);
UIEventSimulator.fire('click', container, {detail: 1});
expect(spy.called).to.be.ok();
expect(spy.calledOnce).to.be.ok();
expect(spy.called).to.be.true;
expect(spy.calledOnce).to.be.true;
expect(spy.lastCall.args[0] instanceof MouseEvent).to.equal(true);
expect(spy.lastCall.args[0].isTrusted).to.equal(false);
});
@ -31,7 +31,7 @@ describe('DomEvent.DoubleTapSpec.js', () => {
clock.tick(300);
UIEventSimulator.fire('click', container, {detail: 1});
expect(spy.notCalled).to.be.ok();
expect(spy.notCalled).to.be.true;
});
it('does not fire dblclick when detail !== 1', () => {
@ -40,7 +40,7 @@ describe('DomEvent.DoubleTapSpec.js', () => {
UIEventSimulator.fire('click', container, {detail: 0});
clock.tick(100);
expect(spy.notCalled).to.be.ok();
expect(spy.notCalled).to.be.true;
});
it('does not fire dblclick after removeListener', () => {
@ -51,7 +51,7 @@ describe('DomEvent.DoubleTapSpec.js', () => {
UIEventSimulator.fire('click', container, {detail: 1});
clock.tick(100);
expect(spy.notCalled).to.be.ok();
expect(spy.notCalled).to.be.true;
});
it('does not conflict with native dblclick', () => {
@ -59,8 +59,8 @@ describe('DomEvent.DoubleTapSpec.js', () => {
clock.tick(100);
UIEventSimulator.fire('click', container, {detail: 2}); // native dblclick expected
UIEventSimulator.fire('dblclick', container); // native dblclick expected
expect(spy.called).to.be.ok();
expect(spy.calledOnce).to.be.ok();
expect(spy.called).to.be.true;
expect(spy.calledOnce).to.be.true;
});
it('synthetic dblclick event has expected properties', () => {
@ -84,9 +84,9 @@ describe('DomEvent.DoubleTapSpec.js', () => {
target: container
});
for (const [prop, expectedValue] of Object.entries(expectedProps)) {
expect(event[prop]).to.be(expectedValue);
expect(event[prop]).to.equal(expectedValue);
}
expect(event.isTrusted).not.to.be.ok();
expect(event.isTrusted).not.to.be.true;
});
it('respects disableClickPropagation', () => {
@ -109,8 +109,8 @@ describe('DomEvent.DoubleTapSpec.js', () => {
clock.tick(100);
UIEventSimulator.fire('click', ctrl, {detail: 1});
expect(spyCtrl.called).to.be.ok();
expect(spyMap.notCalled).to.be.ok();
expect(spyCtrl.called).to.be.true;
expect(spyMap.notCalled).to.be.true;
});
it('doesn\'t fire double-click while clicking on a label with `for` attribute', () => {
@ -131,7 +131,7 @@ describe('DomEvent.DoubleTapSpec.js', () => {
// click on the label
UIEventSimulator.fire('click', div.children[1], {detail: 1});
clock.tick(100);
expect(spyMap.notCalled).to.be.ok();
expect(spyMap.notCalled).to.be.true;
map.remove();
});
});

View File

@ -29,8 +29,8 @@ describe('DomEvent.Pointer', () => {
UIEventSimulator.fire(type, el);
});
touchEvents.forEach((type) => {
expect(listeners[type].called).to.be.ok();
expect(listeners[type].calledOnce).to.be.ok();
expect(listeners[type].called).to.be.true;
expect(listeners[type].calledOnce).to.be.true;
});
});
@ -42,7 +42,7 @@ describe('DomEvent.Pointer', () => {
UIEventSimulator.fire(type, el);
});
touchEvents.forEach((type) => {
expect(listeners[type].notCalled).to.be.ok();
expect(listeners[type].notCalled).to.be.true;
});
});
@ -51,7 +51,7 @@ describe('DomEvent.Pointer', () => {
UIEventSimulator.fire(type, el, {pointerType: 'mouse'});
});
touchEvents.forEach((type) => {
expect(listeners[type].notCalled).to.be.ok();
expect(listeners[type].notCalled).to.be.true;
});
});
@ -60,7 +60,7 @@ describe('DomEvent.Pointer', () => {
UIEventSimulator.fire(type, el);
});
touchEvents.forEach((type) => {
expect(listeners[type].notCalled).to.be.ok();
expect(listeners[type].notCalled).to.be.true;
});
});
@ -89,72 +89,77 @@ describe('DomEvent.Pointer', () => {
return res;
}
// test helper function
expect(containIn(undefined, {a:1})).not.to.be.ok();
expect(containIn({}, {a:1})).not.to.be.ok();
expect(containIn({a:1}, {a:2})).not.to.be.ok();
expect(containIn({a:1}, {a:1, b:2})).to.be.ok();
expect(containIn({a:1, b:2}, {a:1})).not.to.be.ok();
expect(containIn({a:1}, [{a:1}, {b:2}])).to.be.ok();
expect(containIn({a:1}, [{a:0}, {b:2}])).not.to.be.ok();
expect(containIn([{a:1}, {b:2}], [{a:1}, {b:2}, {c:3}])).to.be.ok();
expect(containIn([{a:1}, {b:2}], [{a:0}, {b:2}])).not.to.be.ok();
expect(containIn(undefined, {a:1})).not.to.be.true;
expect(containIn({}, {a:1})).not.to.be.true;
expect(containIn({a:1}, {a:2})).not.to.be.true;
expect(containIn({a:1}, {a:1, b:2})).to.be.true;
expect(containIn({a:1, b:2}, {a:1})).not.to.be.true;
expect(containIn({a:1}, [{a:1}, {b:2}])).to.be.true;
expect(containIn({a:1}, [{a:0}, {b:2}])).not.to.be.true;
expect(containIn([{a:1}, {b:2}], [{a:1}, {b:2}, {c:3}])).to.be.true;
expect(containIn([{a:1}, {b:2}], [{a:0}, {b:2}])).not.to.be.true;
// pointerdown/touchstart
const pointer1 = {clientX:1, clientY:1, pointerId: 1};
UIEventSimulator.fire('pointerdown', el, pointer1);
let evt = listeners.touchstart.lastCall.args[0];
expect(evt.type).to.be('pointerdown');
expect(evt).to.have.keys('touches', 'changedTouches');
expect(evt.type).to.equal('pointerdown');
expect(evt).to.have.property('touches');
expect(evt).to.have.property('changedTouches');
expect(evt.changedTouches).to.have.length(1);
expect(containIn(pointer1, evt.changedTouches[0])).to.be.ok();
expect(containIn(pointer1, evt.changedTouches[0])).to.be.true;
expect(evt.touches).to.have.length(1);
expect(containIn(pointer1, evt.touches[0])).to.be.ok();
expect(containIn(pointer1, evt.touches[0])).to.be.true;
// another pointerdown/touchstart (multitouch)
const pointer2 = {clientX:2, clientY:2, pointerId: 2};
UIEventSimulator.fire('pointerdown', el, pointer2);
evt = listeners.touchstart.lastCall.args[0];
expect(evt.type).to.be('pointerdown');
expect(evt).to.have.keys('touches', 'changedTouches');
expect(evt.type).to.equal('pointerdown');
expect(evt).to.have.property('touches');
expect(evt).to.have.property('changedTouches');
expect(evt.changedTouches).to.have.length(1);
expect(containIn(pointer2, evt.changedTouches[0])).to.be.ok();
expect(containIn(pointer2, evt.changedTouches[0])).to.be.true;
expect(evt.touches).to.have.length(2);
expect(containIn([pointer1, pointer2], evt.touches)).to.be.ok();
expect(containIn([pointer1, pointer2], evt.touches)).to.be.true;
// pointermove/touchmove (multitouch)
L.extend(pointer1, {clientX:11, clientY:11});
UIEventSimulator.fire('pointermove', el, pointer1);
evt = listeners.touchmove.lastCall.args[0];
expect(evt.type).to.be('pointermove');
expect(evt).to.have.keys('touches', 'changedTouches');
expect(evt.type).to.equal('pointermove');
expect(evt).to.have.property('touches');
expect(evt).to.have.property('changedTouches');
expect(evt.changedTouches).to.have.length(1);
expect(containIn(pointer1, evt.changedTouches[0])).to.be.ok();
expect(containIn(pointer1, evt.changedTouches[0])).to.be.true;
expect(evt.touches).to.have.length(2);
expect(containIn([pointer1, pointer2], evt.touches)).to.be.ok();
expect(containIn([pointer1, pointer2], evt.touches)).to.be.true;
// pointerup/touchend (multitouch)
UIEventSimulator.fire('pointerup', el, pointer2);
evt = listeners.touchend.lastCall.args[0];
expect(evt.type).to.be('pointerup');
expect(evt).to.have.keys('touches', 'changedTouches');
expect(evt.type).to.equal('pointerup');
expect(evt).to.have.property('touches');
expect(evt).to.have.property('changedTouches');
expect(evt.changedTouches).to.have.length(1);
expect(containIn(pointer2, evt.changedTouches[0])).to.be.ok();
expect(containIn(pointer2, evt.changedTouches[0])).to.be.true;
expect(evt.touches).to.have.length(1);
expect(containIn(pointer1, evt.touches[0])).to.be.ok();
expect(containIn(pointer1, evt.touches[0])).to.be.true;
// pointercancel/touchcancel
UIEventSimulator.fire('pointercancel', el, pointer1);
evt = listeners.touchcancel.lastCall.args[0];
expect(evt.type).to.be('pointercancel');
expect(evt).to.have.keys('touches', 'changedTouches');
expect(evt.type).to.equal('pointercancel');
expect(evt).to.have.property('touches');
expect(evt).to.have.property('changedTouches');
expect(evt.changedTouches).to.have.length(1);
expect(containIn(pointer1, evt.changedTouches[0])).to.be.ok();
expect(evt.touches).to.be.empty();
expect(containIn(pointer1, evt.changedTouches[0])).to.be.true;
expect(evt.touches).to.be.empty;
expect(listeners.touchstart.calledTwice).to.be.ok();
expect(listeners.touchmove.calledOnce).to.be.ok();
expect(listeners.touchend.calledOnce).to.be.ok();
expect(listeners.touchcancel.calledOnce).to.be.ok();
expect(listeners.touchstart.calledTwice).to.be.true;
expect(listeners.touchmove.calledOnce).to.be.true;
expect(listeners.touchend.calledOnce).to.be.true;
expect(listeners.touchcancel.calledOnce).to.be.true;
});
});
@ -164,7 +169,7 @@ describe('DomEvent.Pointer', () => {
UIEventSimulator.fire(type, el);
});
touchEvents.forEach((type) => {
expect(listeners[type].calledOnce).to.be.ok();
expect(listeners[type].calledOnce).to.be.true;
});
});
@ -173,7 +178,7 @@ describe('DomEvent.Pointer', () => {
UIEventSimulator.fire(type, el);
});
touchEvents.forEach((type) => {
expect(listeners[type].notCalled).to.be.ok();
expect(listeners[type].notCalled).to.be.true;
});
});
});

View File

@ -13,217 +13,173 @@ describe('DomEvent', () => {
describe('#arguments check', () => {
it('throws when el is not HTMLElement', () => {
expect(L.DomEvent.on).withArgs({}, 'click', L.Util.falseFn)
.to.throwException();
expect(L.DomEvent.disableScrollPropagation).withArgs({})
.to.throwException();
expect(L.DomEvent.disableClickPropagation).withArgs({})
.to.throwException();
expect(L.DomEvent.getMousePosition).withArgs({clientX: 0, clientY: 0}, {})
.to.throwException();
expect(() => L.DomEvent.on({}, 'click', L.Util.falseFn)).to.throw();
expect(() => L.DomEvent.disableScrollPropagation({})).to.throw();
expect(() => L.DomEvent.disableClickPropagation({})).to.throw();
expect(() => L.DomEvent.getMousePosition({clientX: 0, clientY: 0}, {})).to.throw();
// .off and .isExternalTarget do not throw atm
});
});
describe('#on (addListener)', () => {
it('throws when type is undefined and context is falseFn', () => {
expect(L.DomEvent.on).withArgs(el, undefined, L.Util.falseFn)
.to.throwException();
expect(() => L.DomEvent.on(el, undefined, L.Util.falseFn)).to.throw();
});
it('throws when type is null and context is falseFn', () => {
expect(L.DomEvent.on).withArgs(el, null, L.Util.falseFn)
.to.throwException();
expect(() => L.DomEvent.on(el, null, L.Util.falseFn)).to.throw();
});
it('throws when type is false and context is falseFn', () => {
expect(L.DomEvent.on).withArgs(el, false, L.Util.falseFn)
.to.throwException();
expect(() => L.DomEvent.on((el, false, L.Util.falseFn))).to.throw();
});
it('throws when type is "click" and context is undefined', () => {
expect(L.DomEvent.on).withArgs(el, 'click', undefined)
.to.throwException();
expect(() => L.DomEvent.on(el, 'click', undefined)).to.throw();
});
it('throws when type is "click" and context is null', () => {
expect(L.DomEvent.on).withArgs(el, 'click', null)
.to.throwException();
expect(() => L.DomEvent.on(el, 'click', null)).to.throw();
});
it('throws when type is "click" and context is false', () => {
expect(L.DomEvent.on).withArgs(el, 'click', false)
.to.throwException();
expect(() => L.DomEvent.on(el, 'click', false)).to.throw();
});
it('throws when type is "click" and context is undefined', () => {
expect(L.DomEvent.on).withArgs(el, 'click', undefined)
.to.throwException();
expect(() => L.DomEvent.on(el, 'click', undefined)).to.throw();
});
it('throws when type is "dblclick" and context is null', () => {
expect(L.DomEvent.on).withArgs(el, 'dblclick', null)
.to.throwException();
expect(() => L.DomEvent.on(el, 'dblclick', null)).to.throw();
});
it('throws when type is "dblclick" and context is false', () => {
expect(L.DomEvent.on).withArgs(el, 'dblclick', false)
.to.throwException();
expect(() => L.DomEvent.on(el, 'dblclick', false)).to.throw();
});
it('throws when type is "dblclick" and context is undefined', () => {
expect(L.DomEvent.on).withArgs(el, 'dblclick', undefined)
.to.throwException();
expect(() => L.DomEvent.on(el, 'dblclick', undefined)).to.throw();
});
it('throws when type is "mousedown" and context is null', () => {
expect(L.DomEvent.on).withArgs(el, 'mousedown', null)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mousedown', null)).to.throw();
});
it('throws when type is "mousedown" and context is false', () => {
expect(L.DomEvent.on).withArgs(el, 'mousedown', false)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mousedown', false)).to.throw();
});
it('throws when type is "mousedown" and context is undefined', () => {
expect(L.DomEvent.on).withArgs(el, 'mousedown', undefined)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mousedown', undefined)).to.throw();
});
it('throws when type is "mouseup" and context is null', () => {
expect(L.DomEvent.on).withArgs(el, 'mouseup', null)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mouseup', null)).to.throw();
});
it('throws when type is "mouseup" and context is false', () => {
expect(L.DomEvent.on).withArgs(el, 'mouseup', false)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mouseup', false)).to.throw();
});
it('throws when type is "mouseup" and context is undefined', () => {
expect(L.DomEvent.on).withArgs(el, 'mouseup', undefined)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mouseup', undefined)).to.throw();
});
it('throws when type is "mouseover" and context is null', () => {
expect(L.DomEvent.on).withArgs(el, 'mouseover', null)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mouseover', null)).to.throw();
});
it('throws when type is "mouseover" and context is false', () => {
expect(L.DomEvent.on).withArgs(el, 'mouseover', false)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mouseover', false)).to.throw();
});
it('throws when type is "mouseover" and context is undefined', () => {
expect(L.DomEvent.on).withArgs(el, 'mouseover', undefined)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mouseover', undefined)).to.throw();
});
it('throws when type is "mouseout" and context is null', () => {
expect(L.DomEvent.on).withArgs(el, 'mouseout', null)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mouseout', null)).to.throw();
});
it('throws when type is "mouseout" and context is false', () => {
expect(L.DomEvent.on).withArgs(el, 'mouseout', false)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mouseout', false)).to.throw();
});
it('throws when type is "mouseout" and context is undefined', () => {
expect(L.DomEvent.on).withArgs(el, 'mouseout', undefined)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mouseout', undefined)).to.throw();
});
it('throws when type is "mousemove" and context is null', () => {
expect(L.DomEvent.on).withArgs(el, 'mousemove', null)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mousemove', null)).to.throw();
});
it('throws when type is "mousemove" and context is false', () => {
expect(L.DomEvent.on).withArgs(el, 'mousemove', false)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mousemove', false)).to.throw();
});
it('throws when type is "mousemove" and context is undefined', () => {
expect(L.DomEvent.on).withArgs(el, 'mousemove', undefined)
.to.throwException();
expect(() => L.DomEvent.on(el, 'mousemove', undefined)).to.throw();
});
it('throws when type is "contextmenu" and context is null', () => {
expect(L.DomEvent.on).withArgs(el, 'contextmenu', null)
.to.throwException();
expect(() => L.DomEvent.on(el, 'contextmenu', null)).to.throw();
});
it('throws when type is "contextmenu" and context is false', () => {
expect(L.DomEvent.on).withArgs(el, 'contextmenu', false)
.to.throwException();
expect(() => L.DomEvent.on(el, 'contextmenu', false)).to.throw();
});
it('throws when type is "contextmenu" and context is undefined', () => {
expect(L.DomEvent.on).withArgs(el, 'contextmenu', undefined)
.to.throwException();
expect(() => L.DomEvent.on(el, 'contextmenu', undefined)).to.throw();
});
it('throws when type is "keyup" and context is null', () => {
expect(L.DomEvent.on).withArgs(el, 'keyup', null)
.to.throwException();
expect(() => L.DomEvent.on(el, 'keyup', null)).to.throw();
});
it('throws when type is "keyup" and context is false', () => {
expect(L.DomEvent.on).withArgs(el, 'keyup', false)
.to.throwException();
expect(() => L.DomEvent.on(el, 'keyup', false)).to.throw();
});
it('throws when type is "keyup" and context is undefined', () => {
expect(L.DomEvent.on).withArgs(el, 'keyup', undefined)
.to.throwException();
expect(() => L.DomEvent.on(el, 'keyup', undefined)).to.throw();
});
it('throws when type is "keypress" and context is null', () => {
expect(L.DomEvent.on).withArgs(el, 'keypress', null)
.to.throwException();
expect(() => L.DomEvent.on(el, 'keypress', null)).to.throw();
});
it('throws when type is "keypress" and context is false', () => {
expect(L.DomEvent.on).withArgs(el, 'keypress', false)
.to.throwException();
expect(() => L.DomEvent.on(el, 'keypress', false)).to.throw();
});
it('throws when type is "keypress" and context is undefined', () => {
expect(L.DomEvent.on).withArgs(el, 'keypress', undefined)
.to.throwException();
expect(() => L.DomEvent.on(el, 'keypress', undefined)).to.throw();
});
it('throws when type is "keydown" and context is null', () => {
expect(L.DomEvent.on).withArgs(el, 'keydown', null)
.to.throwException();
expect(() => L.DomEvent.on(el, 'keydown', null)).to.throw();
});
it('throws when type is "keydown" and context is false', () => {
expect(L.DomEvent.on).withArgs(el, 'keydown', false)
.to.throwException();
expect(() => L.DomEvent.on(el, 'keydown', false)).to.throw();
});
it('throws when type is "keydown" and context is undefined', () => {
expect(L.DomEvent.on).withArgs(el, 'keydown', undefined)
.to.throwException();
expect(() => L.DomEvent.on(el, 'keydown', undefined)).to.throw();
});
it('throws when type is "keydown and click" and context is null', () => {
expect(L.DomEvent.on).withArgs(el, 'keydown click', null)
.to.throwException();
expect(() => L.DomEvent.on(el, 'keydown click', null)).to.throw();
});
it('throws when type is "keydown and click" and context is false', () => {
expect(L.DomEvent.on).withArgs(el, 'keydown click', false)
.to.throwException();
expect(() => L.DomEvent.on(el, 'keydown click', false)).to.throw();
});
it('throws when type is "keydown and click" and context is undefined', () => {
expect(L.DomEvent.on).withArgs(el, 'keydown click', undefined)
.to.throwException();
expect(() => L.DomEvent.on(el, 'keydown click', undefined)).to.throw();
});
it('adds a listener and calls it on event with click', () => {
@ -233,8 +189,8 @@ describe('DomEvent', () => {
UIEventSimulator.fire('click', el);
expect(listener.called).to.be.ok();
expect(listener2.called).to.be.ok();
expect(listener.called).to.be.true;
expect(listener2.called).to.be.true;
});
it('adds a listener and calls it on event with click and keypress', () => {
@ -245,8 +201,8 @@ describe('DomEvent', () => {
UIEventSimulator.fire('click', el);
UIEventSimulator.fire('keypress', el);
expect(listener.called).to.be.ok();
expect(listener2.called).to.be.ok();
expect(listener.called).to.be.true;
expect(listener2.called).to.be.true;
});
it('adds a listener when passed an event map', () => {
@ -277,7 +233,7 @@ describe('DomEvent', () => {
UIEventSimulator.fire('click', el);
expect(listener.calledOn(obj)).to.be.ok();
expect(listener.calledOn(obj)).to.be.true;
});
it('binds "this" to the given context with multiple types', () => {
@ -287,7 +243,7 @@ describe('DomEvent', () => {
UIEventSimulator.fire('click', el);
UIEventSimulator.fire('keypress', el);
expect(listener.calledOn(obj)).to.be.ok();
expect(listener.calledOn(obj)).to.be.true;
});
it('binds "this" to the given context when passed an event map', () => {
@ -335,11 +291,11 @@ describe('DomEvent', () => {
it('is chainable', () => {
const res = L.DomEvent.on(el, 'click', () => {});
expect(res).to.be(L.DomEvent);
expect(res).to.equal(L.DomEvent);
});
it('is aliased to addListener ', () => {
expect(L.DomEvent.on).to.be(L.DomEvent.addListener);
expect(L.DomEvent.on).to.equal(L.DomEvent.addListener);
});
});
@ -350,7 +306,7 @@ describe('DomEvent', () => {
UIEventSimulator.fire('click', el);
expect(listener.notCalled).to.be.ok();
expect(listener.notCalled).to.be.true;
});
it('removes a previously added event', () => {
@ -373,8 +329,8 @@ describe('DomEvent', () => {
UIEventSimulator.fire('click', el);
expect(listenerA.called).to.not.be.ok();
expect(listenerB.called).to.be.ok();
expect(listenerA.called).to.be.false;
expect(listenerB.called).to.be.true;
});
it('removes a previously added listener when passed an event map', () => {
@ -514,8 +470,8 @@ describe('DomEvent', () => {
UIEventSimulator.fire('click', el);
expect(listenerA.called).to.not.be.ok();
expect(listenerB.called).to.not.be.ok();
expect(listenerA.called).to.be.false;
expect(listenerB.called).to.be.false;
});
it('only removes specified listeners type', () => {
@ -533,19 +489,13 @@ describe('DomEvent', () => {
});
it('throws when types/fn are undefined/null/false', () => {
expect(L.DomEvent.off).withArgs(el, undefined)
.to.throwException();
expect(L.DomEvent.off).withArgs(el, null)
.to.throwException();
expect(L.DomEvent.off).withArgs(el, false)
.to.throwException();
expect(() => L.DomEvent.off(el, undefined)).to.throw();
expect(() => L.DomEvent.off(el, null)).to.throw();
expect(() => L.DomEvent.off(el, false)).to.throw();
expect(L.DomEvent.off).withArgs(el, 'click', undefined)
.to.throwException();
expect(L.DomEvent.off).withArgs(el, 'click', null)
.to.throwException();
expect(L.DomEvent.off).withArgs(el, 'click', false)
.to.throwException();
expect(() => L.DomEvent.off(el, 'click', undefined)).to.throw();
expect(() => L.DomEvent.off(el, 'click', null)).to.throw();
expect(() => L.DomEvent.off(el, 'click', false)).to.throw();
});
it('removes listener when passed an event map', () => {
@ -556,17 +506,17 @@ describe('DomEvent', () => {
UIEventSimulator.fire('click', el);
expect(listener.called).to.not.be.ok();
expect(listener.called).to.be.false;
});
it('is chainable', () => {
const res = L.DomEvent.off(el, 'click', () => {});
expect(res).to.be(L.DomEvent);
expect(res).to.equal(L.DomEvent);
});
it('is aliased to removeListener ', () => {
expect(L.DomEvent.off).to.be(L.DomEvent.removeListener);
expect(L.DomEvent.off).to.equal(L.DomEvent.removeListener);
});
});
@ -579,7 +529,7 @@ describe('DomEvent', () => {
UIEventSimulator.fire('click', child);
expect(listener.notCalled).to.be.ok();
expect(listener.notCalled).to.be.true;
});
});
@ -593,7 +543,7 @@ describe('DomEvent', () => {
L.DomEvent.disableScrollPropagation(child);
UIEventSimulator.fire(wheel, child);
expect(listener.notCalled).to.be.ok();
expect(listener.notCalled).to.be.true;
});
});
@ -609,7 +559,7 @@ describe('DomEvent', () => {
UIEventSimulator.fire('mousedown', child);
UIEventSimulator.fire('touchstart', child, {touches: []});
expect(listener.notCalled).to.be.ok();
expect(listener.notCalled).to.be.true;
});
it('prevents click event on map object, but propagates to DOM elements', () => { // to solve #301
@ -629,15 +579,15 @@ describe('DomEvent', () => {
UIEventSimulator.fire('click', grandChild);
UIEventSimulator.fire('keypress', grandChild);
expect(mapOtherListener.called).to.be.ok(); // control case
expect(listener.called).to.be.ok();
expect(mapClickListener.notCalled).to.be.ok();
expect(mapOtherListener.called).to.be.true; // control case
expect(listener.called).to.be.true;
expect(mapClickListener.notCalled).to.be.true;
UIEventSimulator.fire('click', child);
UIEventSimulator.fire('keypress', child);
expect(listener.calledTwice).to.be.ok();
expect(mapClickListener.notCalled).to.be.ok();
expect(listener.calledTwice).to.be.true;
expect(mapClickListener.notCalled).to.be.true;
map.remove();
});
@ -654,11 +604,11 @@ describe('DomEvent', () => {
it('prevents the default action of event', (done) => {
L.DomEvent.on(el, 'click', (e) => {
expect(isPrevented(e)).not.to.be.ok(); // control case
expect(isPrevented(e)).not.to.be.true; // control case
L.DomEvent.preventDefault(e);
expect(isPrevented(e)).to.be.ok();
expect(isPrevented(e)).to.be.true;
done();
});

View File

@ -40,7 +40,7 @@ describe('DomUtil', () => {
const parent = L.DomUtil.create('div');
expect(parent.children.length).to.equal(0);
const child = L.DomUtil.create('p', 'test', parent);
expect(child.parentNode === parent).to.be(true);
expect(child.parentNode === parent).to.be.true;
expect(parent.children.length).to.equal(1);
});
});
@ -51,9 +51,9 @@ describe('DomUtil', () => {
L.DomUtil.create('div', 'test', el);
L.DomUtil.create('div', 'test1', el);
expect(el.children.length).to.equal(3);
expect(Array.from(el.children).indexOf(elm)).to.be(0);
expect(Array.from(el.children).indexOf(elm)).to.equal(0);
L.DomUtil.toFront(elm);
expect(Array.from(el.children).indexOf(elm)).to.be(2);
expect(Array.from(el.children).indexOf(elm)).to.equal(2);
});
it('doesn\'t move an element if he\'s already in the front', () => {
@ -77,18 +77,18 @@ describe('DomUtil', () => {
L.DomUtil.create('div', 'test1', el);
const elm = L.DomUtil.create('div', 'childContainer', el);
expect(el.children.length).to.equal(3);
expect(Array.from(el.children).indexOf(elm)).to.be(2);
expect(Array.from(el.children).indexOf(elm)).to.equal(2);
L.DomUtil.toBack(elm);
expect(Array.from(el.children).indexOf(elm)).to.be(0);
expect(Array.from(el.children).indexOf(elm)).to.equal(0);
});
it('doesn\'t move an element if it is already in the back', () => {
const e1 = L.DomUtil.create('div', 'test', el);
L.DomUtil.create('div', 'test1', el);
L.DomUtil.create('div', 'test2', el);
expect(el.firstChild).to.be(e1);
expect(el.firstChild).to.equal(e1);
L.DomUtil.toBack(el);
expect(el.firstChild).to.be(e1);
expect(el.firstChild).to.equal(e1);
});
it('doesn\'t crash if an element doesn\'t have a parent', () => {
@ -115,22 +115,22 @@ describe('DomUtil', () => {
it('reset the 3d CSS transform when offset and scale aren\'t specified', () => {
L.DomUtil.setTransform(el);
expect(el.style.transform).to.be('translate3d(0px, 0px, 0px)');
expect(el.style.transform).to.equal('translate3d(0px, 0px, 0px)');
});
it('set the 3d CSS transform with just the specified point if scale isn\'t specified', () => {
L.DomUtil.setTransform(el, new L.Point(1, 1));
expect(el.style.transform).to.be('translate3d(1px, 1px, 0px)');
expect(el.style.transform).to.equal('translate3d(1px, 1px, 0px)');
});
it('set 3d CSS transform to translate3d(0px, 0px, 0) and add to it scale(${scalevalue}) if only scale is specified', () => {
L.DomUtil.setTransform(el, undefined, 5);
expect(el.style.transform).to.be('translate3d(0px, 0px, 0px) scale(5)');
expect(el.style.transform).to.equal('translate3d(0px, 0px, 0px) scale(5)');
});
it('set the 3d CSS transform with the specified point ant the corresponding scale', () => {
L.DomUtil.setTransform(el, new L.Point(1, 1), 5);
expect(el.style.transform).to.be('translate3d(1px, 1px, 0px) scale(5)');
expect(el.style.transform).to.equal('translate3d(1px, 1px, 0px) scale(5)');
});
});
@ -143,22 +143,22 @@ describe('DomUtil', () => {
const y = 55;
const position = L.point(x, y);
L.DomUtil.setPosition(el, position);
expect(L.DomUtil.getPosition(el)).to.be.eql({x, y});
expect(L.DomUtil.getPosition(el).equals(position)).to.be.true;
const newX = 333;
const newY = 666;
const newPosition = L.point(newX, newY);
L.DomUtil.setPosition(el, newPosition);
expect(L.DomUtil.getPosition(el)).to.be.eql({x: newX, y: newY});
expect(L.DomUtil.getPosition(el).equals(newPosition)).to.be.true;
});
it('returns position of an element positioned with setPosition.', () => {
const coordinates = {x: 333, y: 666};
const position = L.point(coordinates);
expect(L.DomUtil.getPosition(el)).to.not.eql(coordinates);
expect(L.DomUtil.getPosition(el).equals(position)).to.be.false;
L.DomUtil.setPosition(el, position);
expect(L.DomUtil.getPosition(el)).to.be.an('object');
expect(L.DomUtil.getPosition(el)).to.eql(coordinates);
expect(L.DomUtil.getPosition(el).equals(position)).to.be.true;
});
it('returns [0, 0] point if the HTML element wasn\'t positioned before', () => {
@ -179,7 +179,7 @@ describe('DomUtil', () => {
it('throws an error if the element hasn\'t a parent', () => {
expect(() => {
L.DomUtil.getSizedParentNode(document.createElement('div'));
}).to.throwException();
}).to.throw();
});
});
@ -236,28 +236,28 @@ describe('DomUtil', () => {
// Safari still needs a vendor prefix, we need to detect with property name is supported.
const userSelectProp = ['userSelect', 'WebkitUserSelect'].find(prop => prop in documentStyle);
beforeEach(() => expect(documentStyle[userSelectProp]).to.be(''));
beforeEach(() => expect(documentStyle[userSelectProp]).to.equal(''));
afterEach(() => { documentStyle[userSelectProp] = ''; });
it('disables and enables text selection', () => {
L.DomUtil.disableTextSelection();
expect(documentStyle[userSelectProp]).to.be('none');
expect(documentStyle[userSelectProp]).to.equal('none');
L.DomUtil.enableTextSelection();
expect(documentStyle[userSelectProp]).to.be('');
expect(documentStyle[userSelectProp]).to.equal('');
});
it('restores the text selection previously set', () => {
documentStyle[userSelectProp] = 'text';
L.DomUtil.disableTextSelection();
L.DomUtil.enableTextSelection();
expect(documentStyle[userSelectProp]).to.be('text');
expect(documentStyle[userSelectProp]).to.equal('text');
});
it('restores the text selection previously set when disabling multiple times', () => {
L.DomUtil.disableTextSelection();
L.DomUtil.disableTextSelection();
L.DomUtil.enableTextSelection();
expect(documentStyle[userSelectProp]).to.be('');
expect(documentStyle[userSelectProp]).to.equal('');
});
});
@ -277,11 +277,11 @@ describe('DomUtil', () => {
L.DomUtil.disableImageDrag();
window.addEventListener('dragstart', checkPrevented);
UIEventSimulator.fire('dragstart', child);
expect(selectionPrevented).to.be.ok();
expect(selectionPrevented).to.be.true;
L.DomUtil.enableImageDrag();
UIEventSimulator.fire('dragstart', child);
expect(selectionPrevented).to.not.be.ok();
expect(selectionPrevented).to.be.false;
});
});

View File

@ -20,12 +20,12 @@ describe('LatLngBounds', () => {
it('returns an empty bounds when not argument is given', () => {
const bounds = L.latLngBounds();
expect(bounds instanceof L.LatLngBounds).to.be.ok(a);
expect(bounds instanceof L.LatLngBounds).to.be.true;
});
it('returns an empty bounds when not argument is given to factory', () => {
const bounds = L.latLngBounds();
expect(bounds instanceof L.LatLngBounds).to.be.ok(a);
expect(bounds instanceof L.LatLngBounds).to.be.true;
});
});
@ -87,16 +87,16 @@ describe('LatLngBounds', () => {
describe('#isValid', () => {
it('returns true if properly set up', () => {
expect(a.isValid()).to.be.ok();
expect(a.isValid()).to.be.true;
});
it('returns false if is invalid', () => {
expect(c.isValid()).to.not.be.ok();
expect(c.isValid()).to.be.false;
});
it('returns true if extended', () => {
c.extend([0, 0]);
expect(c.isValid()).to.be.ok();
expect(c.isValid()).to.be.true;
});
});

View File

@ -13,7 +13,7 @@ describe('LatLng', () => {
it('throws an error if invalid lat or lng', () => {
expect(() => {
L.latLng(NaN, NaN);
}).to.throwError();
}).to.throw();
});
it('does not set altitude if undefined', () => {
@ -104,7 +104,7 @@ describe('LatLng', () => {
});
it('returns null if lng not specified', () => {
expect(L.latLng(50)).to.be(null);
expect(L.latLng(50)).to.equal(null);
});
it('accepts altitude as third parameter', () => {
@ -131,7 +131,7 @@ describe('LatLng', () => {
const a = L.latLng(50.5, 30.5, 100);
const b = a.clone();
expect(a === b).to.be(false);
expect(a === b).to.be.false;
});
});
});

View File

@ -204,13 +204,13 @@ describe('CRS.Simple', () => {
describe('getProjectedBounds', () => {
it('returns nothing', () => {
expect(crs.getProjectedBounds(5)).to.be(null);
expect(crs.getProjectedBounds(5)).to.equal(null);
});
});
describe('wrapLatLng', () => {
it('returns coords as is', () => {
expect(crs.wrapLatLng(L.latLng(270, 400)).equals(L.latLng(270, 400))).to.be(true);
expect(crs.wrapLatLng(L.latLng(270, 400)).equals(L.latLng(270, 400))).to.be.true;
});
it('wraps coords if configured', () => {

View File

@ -76,25 +76,25 @@ describe('Bounds', () => {
describe('#contains', () => {
it('contains other bounds or point', () => {
a.extend([50, 10]);
expect(a.contains(b)).to.be.ok();
expect(b.contains(a)).to.not.be.ok();
expect(a.contains([24, 25])).to.be.ok();
expect(a.contains([54, 65])).to.not.be.ok();
expect(a.contains(b)).to.be.true;
expect(b.contains(a)).to.be.false;
expect(a.contains([24, 25])).to.be.true;
expect(a.contains([54, 65])).to.be.false;
});
});
describe('#isValid', () => {
it('returns true if properly set up', () => {
expect(a.isValid()).to.be.ok();
expect(a.isValid()).to.be.true;
});
it('returns false if is invalid', () => {
expect(c.isValid()).to.not.be.ok();
expect(c.isValid()).to.be.false;
});
it('returns true if extended', () => {
c.extend([0, 0]);
expect(c.isValid()).to.be.ok();
expect(c.isValid()).to.be.true;
});
});
@ -106,11 +106,11 @@ describe('Bounds', () => {
describe('#intersects', () => {
it('returns true if bounds intersect', () => {
expect(a.intersects(b)).to.be(true);
expect(a.intersects(b)).to.be.true;
});
it('two bounds intersect if they have at least one point in common', () => {
expect(a.intersects([[14, 12], [6, 5]])).to.be(true);
expect(a.intersects([[14, 12], [6, 5]])).to.be.true;
});
it('returns false if bounds not intersect', () => {
@ -120,14 +120,14 @@ describe('Bounds', () => {
describe('#overlaps', () => {
it('returns true if bounds overlaps', () => {
expect(a.overlaps(b)).to.be(true);
expect(a.overlaps(b)).to.be.true;
});
it('two bounds overlaps if their intersection is an area', () => {
// point in common
expect(a.overlaps([[14, 12], [6, 5]])).to.be(false);
expect(a.overlaps([[14, 12], [6, 5]])).to.be.false;
// matching boundary
expect(a.overlaps([[30, 12], [35, 25]])).to.be(false);
expect(a.overlaps([[30, 12], [35, 25]])).to.be.false;
});
it('returns false if bounds not overlaps', () => {

View File

@ -29,7 +29,7 @@ describe('LineUtil', () => {
const b = L.point(25, 20);
const segment = L.LineUtil.clipSegment(a, b, bounds, true);
expect(segment).to.be(false);
expect(segment).to.be.false;
});
it('can round numbers in clipped bounds', () => {
@ -86,23 +86,23 @@ describe('LineUtil', () => {
describe('#isFlat', () => {
it('should return true for an array of LatLngs', () => {
expect(L.LineUtil.isFlat([L.latLng([0, 0])])).to.be(true);
expect(L.LineUtil.isFlat([L.latLng([0, 0])])).to.be.true;
});
it('should return true for an array of LatLngs arrays', () => {
expect(L.LineUtil.isFlat([[0, 0]])).to.be(true);
expect(L.LineUtil.isFlat([[0, 0]])).to.be.true;
});
it('should return true for an empty array', () => {
expect(L.LineUtil.isFlat([])).to.be(true);
expect(L.LineUtil.isFlat([])).to.be.true;
});
it('should return false for a nested array of LatLngs', () => {
expect(L.LineUtil.isFlat([[L.latLng([0, 0])]])).to.be(false);
expect(L.LineUtil.isFlat([[L.latLng([0, 0])]])).to.be.false;
});
it('should return false for a nested empty array', () => {
expect(L.LineUtil.isFlat([[]])).to.be(false);
expect(L.LineUtil.isFlat([[]])).to.be.false;
});
});
@ -134,33 +134,26 @@ describe('LineUtil', () => {
it('throws error if latlngs not passed', () => {
expect(() => {
L.LineUtil.polylineCenter(null, crs);
}).to.throwException('latlngs not passed');
}).to.throw('latlngs not passed');
});
it('throws error if latlng array is empty', () => {
expect(() => {
L.LineUtil.polylineCenter([], crs);
}).to.throwException('latlngs not passed');
}).to.throw('latlngs not passed');
});
it('throws error if latlngs not passed', () => {
expect(() => {
L.LineUtil.polylineCenter(null, crs, zoom);
}).to.throwException('latlngs not passed');
}).to.throw('latlngs not passed');
});
it('throws error if latlng array is empty', () => {
expect(() => {
L.LineUtil.polylineCenter([], crs, zoom);
}).to.throwException('latlngs not passed');
});
it('throws error if map not passed', () => {
const latlngs = [[80, 0], [80, 90]];
expect(() => {
L.LineUtil.polylineCenter(latlngs, null);
}).to.throwException('map not passed');
}).to.throw('latlngs not passed');
});
it('shows warning if latlngs is not flat', () => {
@ -170,7 +163,7 @@ describe('LineUtil', () => {
const spy = sinon.spy(console, 'warn');
const center = L.LineUtil.polylineCenter(latlngs, crs);
console.warn.restore();
expect(spy.calledOnce).to.be.ok();
expect(spy.calledOnce).to.be.true;
expect(center).to.be.nearLatLng([80, 45]);
});

View File

@ -67,8 +67,8 @@ describe('Point', () => {
const p2 = L.point(20.4, 50.12);
const p3 = L.point(20.5, 50.13);
expect(p1.equals(p2)).to.be(true);
expect(p1.equals(p3)).to.be(false);
expect(p1.equals(p2)).to.be.true;
expect(p1.equals(p3)).to.be.false;
});
});
@ -79,9 +79,9 @@ describe('Point', () => {
p3 = L.point(60, -20),
p4 = L.point(-40, -40);
expect(p1.contains(p2)).to.be(true);
expect(p1.contains(p3)).to.be(false);
expect(p1.contains(p4)).to.be(false);
expect(p1.contains(p2)).to.be.true;
expect(p1.contains(p3)).to.be.false;
expect(p1.contains(p4)).to.be.false;
});
});
@ -95,7 +95,7 @@ describe('Point', () => {
describe('L.point factory', () => {
it('leaves L.Point instances as is', () => {
const p = L.point(50, 30);
expect(L.point(p)).to.be(p);
expect(L.point(p)).to.equal(p);
});
it('creates a point out of three arguments', () => {
@ -111,8 +111,8 @@ describe('Point', () => {
});
it('does not fail on invalid arguments', () => {
expect(L.point(undefined)).to.be(undefined);
expect(L.point(null)).to.be(null);
expect(L.point(undefined)).to.equal(undefined);
expect(L.point(null)).to.equal(null);
});
});
});

View File

@ -74,13 +74,13 @@ describe('PolyUtil', () => {
it('throws error if latlngs not passed', () => {
expect(() => {
L.PolyUtil.polygonCenter(null, crs);
}).to.throwException('latlngs not passed');
}).to.throw('latlngs not passed');
});
it('throws error if latlng array is empty', () => {
expect(() => {
L.PolyUtil.polygonCenter([], crs);
}).to.throwException('latlngs not passed');
}).to.throw('latlngs not passed');
});
it('shows warning if latlngs is not flat', () => {
@ -90,17 +90,10 @@ describe('PolyUtil', () => {
const spy = sinon.spy(console, 'warn');
const center = L.PolyUtil.polygonCenter(latlngs, crs);
console.warn.restore();
expect(spy.calledOnce).to.be.ok();
expect(spy.calledOnce).to.be.true;
expect(center).to.be.nearLatLng([5.019148099025293, 5]);
});
it('throws error if map not passed', () => {
const latlngs = [[80, 0], [80, 90]];
expect(() => {
L.PolyUtil.polygonCenter(latlngs, null);
}).to.throwException('map not passed');
});
it('iterates only over the array values', () => {
// eslint-disable-next-line
Array.prototype.foo = 'ABC';

View File

@ -18,21 +18,21 @@
wasClicked2;
fg2.on('click', (e) => {
expect(e.propagatedFrom).to.be(marker);
expect(e.target).to.be(fg2);
expect(e.propagatedFrom).to.equal(marker);
expect(e.target).to.equal(fg2);
wasClicked2 = true;
});
fg1.on('click', (e) => {
expect(e.propagatedFrom).to.be(marker);
expect(e.target).to.be(fg1);
expect(e.propagatedFrom).to.equal(marker);
expect(e.target).to.equal(fg1);
wasClicked1 = true;
});
marker.fire('click', {type: 'click'}, true);
expect(wasClicked1).to.be(true);
expect(wasClicked2).to.be(true);
expect(wasClicked1).to.be.true;
expect(wasClicked2).to.be.true;
});
});
});
@ -42,22 +42,22 @@
const fg = L.featureGroup(),
marker = L.marker([0, 0]);
expect(fg.hasLayer(marker)).to.be(false);
expect(fg.hasLayer(marker)).to.be.false;
fg.addLayer(marker);
expect(fg.hasLayer(marker)).to.be(true);
expect(fg.hasLayer(marker)).to.be.true;
});
it('supports non-evented layers', () => {
const fg = L.featureGroup(),
g = L.layerGroup();
expect(fg.hasLayer(g)).to.be(false);
expect(fg.hasLayer(g)).to.be.false;
fg.addLayer(g);
expect(fg.hasLayer(g)).to.be(true);
expect(fg.hasLayer(g)).to.be.true;
});
});
@ -67,10 +67,10 @@
marker = L.marker([0, 0]);
fg.addLayer(marker);
expect(fg.hasLayer(marker)).to.be(true);
expect(fg.hasLayer(marker)).to.be.true;
fg.removeLayer(marker);
expect(fg.hasLayer(marker)).to.be(false);
expect(fg.hasLayer(marker)).to.be.false;
});
it('removes the layer passed to it by id', () => {
@ -78,10 +78,10 @@
marker = L.marker([0, 0]);
fg.addLayer(marker);
expect(fg.hasLayer(marker)).to.be(true);
expect(fg.hasLayer(marker)).to.be.true;
fg.removeLayer(L.stamp(marker));
expect(fg.hasLayer(marker)).to.be(false);
expect(fg.hasLayer(marker)).to.be.false;
});
});
});

View File

@ -59,11 +59,11 @@ describe('L.GeoJSON', () => {
const geojson = L.geoJSON(feature, {weight: 7, color: 'chocolate'});
geojson.setStyle({weight: 22, color: 'coral'});
const layer = geojson.getLayers()[0];
expect(layer.options.weight).to.be(22);
expect(layer.options.color).to.be('coral');
expect(layer.options.weight).to.equal(22);
expect(layer.options.color).to.equal('coral');
geojson.resetStyle(layer);
expect(layer.options.weight).to.be(7);
expect(layer.options.color).to.be('chocolate');
expect(layer.options.weight).to.equal(7);
expect(layer.options.color).to.equal('chocolate');
});
it('should reset init options of all child layers', () => {
@ -84,16 +84,16 @@ describe('L.GeoJSON', () => {
const geojson = L.geoJSON([feature, feature2], {weight: 7, color: 'chocolate'});
geojson.setStyle({weight: 22, color: 'coral'});
const layer = geojson.getLayers()[0];
expect(layer.options.weight).to.be(22);
expect(layer.options.color).to.be('coral');
expect(layer.options.weight).to.equal(22);
expect(layer.options.color).to.equal('coral');
const layer2 = geojson.getLayers()[1];
expect(layer2.options.weight).to.be(22);
expect(layer2.options.color).to.be('coral');
expect(layer2.options.weight).to.equal(22);
expect(layer2.options.color).to.equal('coral');
geojson.resetStyle(); // Should apply to all layers
expect(layer.options.weight).to.be(7);
expect(layer.options.color).to.be('chocolate');
expect(layer2.options.weight).to.be(7);
expect(layer2.options.color).to.be('chocolate');
expect(layer.options.weight).to.equal(7);
expect(layer.options.color).to.equal('chocolate');
expect(layer2.options.weight).to.equal(7);
expect(layer2.options.color).to.equal('chocolate');
});
});
});
@ -611,28 +611,28 @@ describe('L.GeoJSON functions', () => {
type: 'Feature',
geometry
});
expect(layer).to.be.a(expectedType);
expect(layer).to.be.instanceOf(expectedType);
});
it(`creates a Layer from a GeoJSON geometry (type='${geometry.type}')`, () => {
const layer = L.GeoJSON.geometryToLayer(geometry);
expect(layer).to.be.a(expectedType);
expect(layer).to.be.instanceOf(expectedType);
});
});
it('throws an error if feature is an invalid GeoJSON object', () => {
expect(L.GeoJSON.geometryToLayer).withArgs({
expect(() => L.GeoJSON.geometryToLayer({
type: 'Feature',
geometry: {
type: 'invalid',
coordinates: [0, 0]
}
}).to.throwError('Invalid GeoJSON object.');
})).to.throw('Invalid GeoJSON object.');
});
it('returns nothing if feature does not have a geometry property', () => {
const ret = L.GeoJSON.geometryToLayer({type: 'Feature'});
expect(ret).not.to.be.ok();
expect(ret).not.to.be.true;
});
it('creates a Layer using pointToLayer option (Point)', () => {
@ -643,8 +643,8 @@ describe('L.GeoJSON functions', () => {
}, {
pointToLayer: customPointToLayer
});
expect(layer).to.be.a(L.Circle);
expect(layer.options.radius).to.be(100);
expect(layer).to.be.instanceOf(L.Circle);
expect(layer.options.radius).to.equal(100);
});
it('creates a Layer using pointToLayer option (MultiPoint)', () => {
@ -656,8 +656,8 @@ describe('L.GeoJSON functions', () => {
pointToLayer: customPointToLayer
});
layer.eachLayer((lyr) => {
expect(lyr).to.be.a(L.Circle);
expect(lyr.options.radius).to.be(100);
expect(lyr).to.be.instanceOf(L.Circle);
expect(lyr.options.radius).to.equal(100);
});
});
@ -671,7 +671,7 @@ describe('L.GeoJSON functions', () => {
}, {
coordsToLatLng: customCoordstoLatLng
});
expect(layer.getLatLng()).to.eql({lat: 3, lng: 2, alt: 4});
expect(layer.getLatLng().equals(L.latLng({lat: 3, lng: 2, alt: 4}))).to.be.true;
});
it('creates a Layer using coordsToLatLng option (MultiPoint)', () => {
@ -686,10 +686,9 @@ describe('L.GeoJSON functions', () => {
}, {
coordsToLatLng: customCoordstoLatLng
});
expect(layer.getLayers().map(lyr => lyr.getLatLng())).to.eql([
{lat: 3, lng: 2, alt: 4},
{lat: 6, lng: 5, alt: 7}
]);
expect(layer.getLayers()[0].getLatLng().equals(L.latLng({lat: 3, lng: 2, alt: 4}))).to.be.true;
expect(layer.getLayers()[1].getLatLng().equals(L.latLng({lat: 6, lng: 5, alt: 7}))).to.be.true;
});
});
@ -697,10 +696,10 @@ describe('L.GeoJSON functions', () => {
it('creates a LatLng object with given coordinates', () => {
const latLng = L.GeoJSON.coordsToLatLng([1, 2]);
const latLngWithAlt = L.GeoJSON.coordsToLatLng([3, 4, 5]);
expect(latLng).to.be.a(L.LatLng);
expect(latLngWithAlt).to.be.a(L.LatLng);
expect(latLng).to.eql({lng: 1, lat: 2});
expect(latLngWithAlt).to.eql({lng: 3, lat: 4, alt: 5});
expect(latLng).to.be.instanceOf(L.LatLng);
expect(latLngWithAlt).to.be.instanceOf(L.LatLng);
expect(latLng.equals(L.latLng({lng: 1, lat: 2}))).to.be.true;
expect(latLngWithAlt.equals(L.latLng({lng: 3, lat: 4, alt: 5})));
});
});
@ -712,9 +711,13 @@ describe('L.GeoJSON functions', () => {
it('creates a multidimensional array of LatLngs', () => {
const latLngs = L.GeoJSON.coordsToLatLngs([[1, 2], [3, 4], [5, 6]]);
expect(latLngs).to.eql([{lng: 1, lat: 2}, {lng: 3, lat: 4}, {lng: 5, lat: 6}]);
expect(latLngs[0].equals(L.latLng({lng: 1, lat: 2})));
expect(latLngs[1].equals(L.latLng({lng: 3, lat: 4})));
expect(latLngs[2].equals(L.latLng({lng: 5, lat: 6})));
latLngs.forEach((latLng) => {
expect(latLng).to.be.a(L.LatLng);
expect(latLng).to.be.instanceOf(L.LatLng);
});
});
@ -723,13 +726,18 @@ describe('L.GeoJSON functions', () => {
[[1, 2], [3, 4], [5, 6]],
[[5, 6], [7, 8], [9, 10]]
], 1);
expect(latLngs).to.eql([
[{lng: 1, lat: 2}, {lng: 3, lat: 4}, {lng: 5, lat: 6}],
[{lng: 5, lat: 6}, {lng: 7, lat: 8}, {lng: 9, lat: 10}]
]);
expect(latLngs[0][0].equals(L.latLng({lng: 1, lat: 2})));
expect(latLngs[0][1].equals(L.latLng({lng: 3, lat: 4})));
expect(latLngs[0][2].equals(L.latLng({lng: 5, lat: 6})));
expect(latLngs[1][0].equals(L.latLng({lng: 5, lat: 6})));
expect(latLngs[1][1].equals(L.latLng({lng: 7, lat: 8})));
expect(latLngs[1][2].equals(L.latLng({lng: 9, lat: 10})));
latLngs.forEach((arr) => {
arr.forEach((latlng) => {
expect(latlng).to.be.a(L.LatLng);
expect(latlng).to.be.instanceOf(L.LatLng);
});
});
});
@ -737,11 +745,10 @@ describe('L.GeoJSON functions', () => {
it('creates a multidimensional array of LatLngs with custom coordsToLatLng', () => {
const coords = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
const latLngs = L.GeoJSON.coordsToLatLngs(coords, 0, customCoordsToLatLng);
expect(latLngs).to.eql([
{lat: 3, lng: 2, alt: 4},
{lat: 6, lng: 5, alt: 7},
{lat: 9, lng: 8, alt: 10}
]);
expect(latLngs[0].equals(L.latLng({lat: 3, lng: 2, alt: 4})));
expect(latLngs[1].equals(L.latLng({lat: 6, lng: 5, alt: 7})));
expect(latLngs[2].equals(L.latLng({lat: 9, lng: 8, alt: 10})));
});
it('creates a multidimensional array of LatLngs with custom coordsToLatLng (levelDeep=1)', () => {
@ -750,16 +757,12 @@ describe('L.GeoJSON functions', () => {
[[12, 13, 14], [15, 16, 17]]
];
const latLngs = L.GeoJSON.coordsToLatLngs(coords, 1, customCoordsToLatLng);
expect(latLngs).to.eql([
[
{lat: 3, lng: 2, alt: 4},
{lat: 6, lng: 5, alt: 7}
],
[
{lat: 14, lng: 13, alt: 15},
{lat: 17, lng: 16, alt: 18}
]
]);
expect(latLngs[0][0].equals(L.latLng({lat: 3, lng: 2, alt: 4})));
expect(latLngs[0][1].equals(L.latLng({lat: 6, lng: 5, alt: 7})));
expect(latLngs[1][0].equals(L.latLng({lat: 14, lng: 13, alt: 15})));
expect(latLngs[1][1].equals(L.latLng({lat: 17, lng: 16, alt: 18})));
});
});
@ -885,12 +888,12 @@ describe('L.GeoJSON functions', () => {
it('has no reference between first and last coordinates', () => {
const coords = L.GeoJSON.latLngsToCoords([[2, 1, 3], [5, 4, 6]], null, true);
expect(coords).to.eql([[1, 2, 3], [4, 5, 6], [1, 2, 3]]);
expect(coords[0] === coords[2]).to.not.ok();
expect(coords[0] === coords[2]).to.be.false;
});
it('still works if no values in coords array', () => {
expect(() => {
L.GeoJSON.latLngsToCoords([[]], 1, true);
}).to.not.throwException();
}).to.not.throw();
});
});

View File

@ -69,7 +69,7 @@ describe('ImageOverlay', () => {
const loadRaised = sinon.spy();
overlay.once('load', loadRaised);
raiseImageEvent('load');
expect(loadRaised.called).to.be(true);
expect(loadRaised.called).to.be.true;
});
});
@ -78,19 +78,19 @@ describe('ImageOverlay', () => {
const errorRaised = sinon.spy();
overlay.once('error', errorRaised);
raiseImageEvent('error');
expect(errorRaised.called).to.be(true);
expect(errorRaised.called).to.be.true;
});
it('should change the image to errorOverlayUrl', () => {
raiseImageEvent('error');
expect(overlay._url).to.be(errorUrl);
expect(overlay._image.src).to.be(errorUrl);
expect(overlay._url).to.equal(errorUrl);
expect(overlay._image.src).to.equal(errorUrl);
});
});
describe('className', () => {
it('should set image\'s class', () => {
expect(overlay._image.classList.contains('my-custom-image-class')).to.be(true);
expect(overlay._image.classList.contains('my-custom-image-class')).to.be.true;
});
});
});
@ -160,7 +160,7 @@ describe('ImageOverlay', () => {
});
map.addLayer(overlay);
expect(overlay._image.getAttribute('crossorigin')).to.be(expectedValue);
expect(overlay._image.getAttribute('crossorigin')).to.equal(expectedValue);
});
}
});

View File

@ -3,12 +3,12 @@
it('throws when called without proper argument', () => {
const lg = L.layerGroup();
const hasLayer = lg.hasLayer.bind(lg);
expect(hasLayer).withArgs(new L.Layer()).to.not.throwException(); // control case
expect(() => hasLayer(new L.Layer())).to.not.throw(); // control case
expect(hasLayer).withArgs(undefined).to.throwException();
expect(hasLayer).withArgs(null).to.throwException();
expect(hasLayer).withArgs(false).to.throwException();
expect(hasLayer).to.throwException();
expect(() => hasLayer(undefined)).to.throw();
expect(() => hasLayer(null)).to.throw();
expect(() => hasLayer(false)).to.throw();
expect(() => hasLayer()).to.throw();
});
});
@ -19,7 +19,7 @@
expect(lg.addLayer(marker)).to.eql(lg);
expect(lg.hasLayer(marker)).to.be(true);
expect(lg.hasLayer(marker)).to.be.true;
});
});
@ -31,7 +31,7 @@
lg.addLayer(marker);
expect(lg.removeLayer(marker)).to.eql(lg);
expect(lg.hasLayer(marker)).to.be(false);
expect(lg.hasLayer(marker)).to.be.false;
});
});
@ -43,7 +43,7 @@
lg.addLayer(marker);
expect(lg.clearLayers()).to.eql(lg);
expect(lg.hasLayer(marker)).to.be(false);
expect(lg.hasLayer(marker)).to.be.false;
});
});

View File

@ -22,7 +22,7 @@ describe('Popup', () => {
UIEventSimulator.fire('click', container);
expect(map.hasLayer(popup)).to.be(false);
expect(map.hasLayer(popup)).to.be.false;
});
it('closes on map click when popup has closeOnClick option', () => {
@ -34,7 +34,7 @@ describe('Popup', () => {
UIEventSimulator.fire('click', container);
expect(map.hasLayer(popup)).to.be(false);
expect(map.hasLayer(popup)).to.be.false;
});
it('does not close on map click when popup has closeOnClick: false option', () => {
@ -46,7 +46,7 @@ describe('Popup', () => {
UIEventSimulator.fire('click', container);
expect(map.hasLayer(popup)).to.be(true);
expect(map.hasLayer(popup)).to.be.true;
});
it('sets the default \'closeButtonLabel\' on the close button', () => {
@ -54,7 +54,7 @@ describe('Popup', () => {
.setLatLng(center)
.openOn(map);
expect(popup.getElement().querySelector('[aria-label="Close popup"]')).not.to.be(null);
expect(popup.getElement().querySelector('[aria-label="Close popup"]')).not.to.equal(null);
});
it('sets a custom \'closeButtonLabel\' on the close button', () => {
@ -63,7 +63,7 @@ describe('Popup', () => {
.setLatLng(center)
.openOn(map);
expect(popup.getElement().querySelector(`[aria-label="${closeButtonLabel}"]`)).not.to.be(null);
expect(popup.getElement().querySelector(`[aria-label="${closeButtonLabel}"]`)).not.to.equal(null);
});
it('toggles its visibility when marker is clicked', () => {
@ -71,15 +71,15 @@ describe('Popup', () => {
map.addLayer(marker);
marker.bindPopup('Popup1');
expect(map.hasLayer(marker._popup)).to.be(false);
expect(map.hasLayer(marker._popup)).to.be.false;
// toggle open popup
UIEventSimulator.fire('click', marker._icon);
expect(map.hasLayer(marker._popup)).to.be(true);
expect(map.hasLayer(marker._popup)).to.be.true;
// toggle close popup
UIEventSimulator.fire('click', marker._icon);
expect(map.hasLayer(marker._popup)).to.be(false);
expect(map.hasLayer(marker._popup)).to.be.false;
});
it('it should use a popup with a function as content with a FeatureGroup', () => {
@ -98,16 +98,16 @@ describe('Popup', () => {
latlng: center,
layer: marker1
});
expect(map.hasLayer(group._popup)).to.be(true);
expect(group._popup._contentNode.innerHTML).to.be('I\'m marker 1.');
expect(map.hasLayer(group._popup)).to.be.true;
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 1.');
// toggle popup on marker2
group.fire('click', {
latlng: [54.6, 38.2],
layer: marker2
});
expect(map.hasLayer(group._popup)).to.be(true);
expect(group._popup._contentNode.innerHTML).to.be('I\'m marker 2.');
expect(map.hasLayer(group._popup)).to.be.true;
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 2.');
});
it('it should function for popup content after bindPopup is called', () => {
@ -128,16 +128,16 @@ describe('Popup', () => {
latlng: center,
layer: marker1
});
expect(map.hasLayer(group._popup)).to.be(true);
expect(group._popup._contentNode.innerHTML).to.be('I\'m marker 1.');
expect(map.hasLayer(group._popup)).to.be.true;
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 1.');
// toggle popup on marker2
group.fire('click', {
latlng: [54.6, 38.2],
layer: marker2
});
expect(map.hasLayer(group._popup)).to.be(true);
expect(group._popup._contentNode.innerHTML).to.be('I\'m marker 2.');
expect(map.hasLayer(group._popup)).to.be.true;
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 2.');
});
it('should use a function for popup content when a source is passed to Popup', () => {
@ -152,8 +152,8 @@ describe('Popup', () => {
latlng: center
});
expect(map.hasLayer(marker._popup)).to.be(true);
expect(marker._popup._contentNode.innerHTML).to.be('I am a marker.');
expect(map.hasLayer(marker._popup)).to.be.true;
expect(marker._popup._contentNode.innerHTML).to.equal('I am a marker.');
});
it('triggers popupopen on marker when popup opens', () => {
@ -170,11 +170,11 @@ describe('Popup', () => {
marker1.on('popupopen', spy);
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
marker2.openPopup();
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
marker1.openPopup();
expect(spy.called).to.be(true);
expect(spy.called).to.be.true;
});
// Related to #8558
@ -202,12 +202,12 @@ describe('Popup', () => {
expect(e.target.options.testId).to.eql('markerB');
});
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
marker2.openPopup();
expect(spy.called).to.be(false);
expect(spy2.called).to.be(true);
expect(spy.called).to.be.false;
expect(spy2.called).to.be.true;
marker1.closePopup().openPopup();
expect(spy.called).to.be(true);
expect(spy.called).to.be.true;
});
it('triggers popupclose on marker when popup closes', () => {
@ -224,16 +224,16 @@ describe('Popup', () => {
marker1.on('popupclose', spy);
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
marker2.openPopup();
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
marker1.openPopup();
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
marker2.openPopup();
expect(spy.called).to.be(true);
expect(spy.called).to.be.true;
marker1.openPopup();
marker1.closePopup();
expect(spy.callCount).to.be(2);
expect(spy.callCount).to.equal(2);
});
it('should take into account icon popupAnchor option', () => {
@ -285,10 +285,10 @@ describe('Popup', () => {
.openOn(map);
});
expect(map.hasLayer(layer._popup)).to.be(false);
expect(map.hasLayer(layer._popup)).to.be.false;
UIEventSimulator.fire('click', layer._path);
expect(mapClicked).to.be(false);
expect(map.hasLayer(layer._popup)).to.be(true);
expect(mapClicked).to.be.false;
expect(map.hasLayer(layer._popup)).to.be.true;
});
@ -300,7 +300,7 @@ describe('Popup', () => {
code: 'Enter'
});
expect(map.hasLayer(layer._popup)).to.be(true);
expect(map.hasLayer(layer._popup)).to.be.true;
});
describe('autoPan option should pan popup into visibility', () => {
@ -325,7 +325,7 @@ describe('Popup', () => {
it('should pan map to show popup content if autoPan is enabled', (done) => {
map.on('popupopen', (e) => {
const popupTopOffset = getPopupOffset(map, e.popup);
expect(popupTopOffset).to.be(10, 'The upper edge of the popup have a padding of 10');
expect(popupTopOffset).to.equal(10, 'The upper edge of the popup have a padding of 10');
done();
});
map.openPopup('<div style="height: 400px;"></div>', [58.4, 37.6], {
@ -337,7 +337,7 @@ describe('Popup', () => {
it('should pan map to show popup content if autoPan is enabled even when animating', (done) => {
map.on('popupopen', (e) => {
const popupTopOffset = getPopupOffset(map, e.popup);
expect(popupTopOffset).to.be(10);
expect(popupTopOffset).to.equal(10);
done();
});
@ -356,21 +356,21 @@ describe('Popup', () => {
it('opens popup with passed latlng position while initializing', () => {
const popup = new L.Popup(center)
.openOn(map);
expect(map.hasLayer(popup)).to.be(true);
expect(map.hasLayer(popup)).to.be.true;
});
it('opens popup with passed latlng and options position while initializing', () => {
const popup = new L.Popup(center, {className: 'testClass'})
.addTo(map);
expect(map.hasLayer(popup)).to.be(true);
expect(popup.getElement().classList.contains('testClass')).to.be(true);
expect(map.hasLayer(popup)).to.be.true;
expect(popup.getElement().classList.contains('testClass')).to.be.true;
});
it('adds popup with passed content in options while initializing', () => {
const popup = new L.Popup(center, {content: 'Test'})
.addTo(map);
expect(map.hasLayer(popup)).to.be(true);
expect(popup.getContent()).to.be('Test');
expect(map.hasLayer(popup)).to.be.true;
expect(popup.getContent()).to.equal('Test');
});
describe('L.Map#openPopup', () => {
@ -378,7 +378,7 @@ describe('Popup', () => {
const popup = L.popup()
.setLatLng(center);
map.openPopup(popup);
expect(map.hasLayer(popup)).to.be(true);
expect(map.hasLayer(popup)).to.be.true;
});
it('sets popup location', () => {
@ -389,7 +389,7 @@ describe('Popup', () => {
it('creates a popup from content', () => {
map.openPopup('<h2>Hello World</h2>', center);
expect(map._popup).to.be.an(L.Popup);
expect(map._popup).to.be.instanceOf(L.Popup);
expect(map._popup.getContent()).to.eql('<h2>Hello World</h2>');
});
@ -398,7 +398,7 @@ describe('Popup', () => {
const p2 = L.popup().setLatLng(center);
map.openPopup(p1);
map.openPopup(p2);
expect(map.hasLayer(p1)).to.be(false);
expect(map.hasLayer(p1)).to.be.false;
});
it('does not close existing popup with autoClose: false option', () => {
@ -406,8 +406,8 @@ describe('Popup', () => {
const p2 = L.popup().setLatLng(center);
map.openPopup(p1);
map.openPopup(p2);
expect(map.hasLayer(p1)).to.be(true);
expect(map.hasLayer(p2)).to.be(true);
expect(map.hasLayer(p1)).to.be.true;
expect(map.hasLayer(p2)).to.be.true;
});
it('should not be closen when dragging map', (done) => {
@ -420,13 +420,13 @@ describe('Popup', () => {
const spy = sinon.spy();
const p = L.popup().setLatLng(center);
map.openPopup(p);
expect(map.hasLayer(p)).to.be(true);
expect(map.hasLayer(p)).to.be.true;
map.on('drag', spy);
const hand = new Hand({
timing: 'fastframe',
onStop() {
expect(spy.called).to.be(true);
expect(map.hasLayer(p)).to.be(true);
expect(spy.called).to.be.true;
expect(map.hasLayer(p)).to.be.true;
done();
}});
const mouse = hand.growFinger('mouse');
@ -449,8 +449,8 @@ describe('Popup', () => {
// Short hop to the edge of the map (at time of writing, will trigger an animated pan)
const p = L.popup({keepInView: true}).setContent('Popup').setLatLng(map.getBounds()._northEast);
map.once('moveend', () => {
expect(spy.callCount).to.be(1);
expect(map.getBounds().contains(p.getLatLng())).to.be(true);
expect(spy.callCount).to.equal(1);
expect(map.getBounds().contains(p.getLatLng())).to.be.true;
done();
});
map.openPopup(p);
@ -471,8 +471,8 @@ describe('Popup', () => {
// Long hop (at time of writing, will trigger a view reset)
const p = L.popup({keepInView: true}).setContent('Popup').setLatLng([center[0], center[1] + 50]);
map.once('moveend', () => {
expect(spy.callCount).to.be(1);
expect(map.getBounds().contains(p.getLatLng())).to.be(true);
expect(spy.callCount).to.equal(1);
expect(map.getBounds().contains(p.getLatLng())).to.be.true;
done();
});
map.openPopup(p);
@ -483,7 +483,7 @@ describe('Popup', () => {
map.once('moveend', () => {
map.once('moveend', () => {
expect(map.getBounds().contains(p.getLatLng())).to.be(true);
expect(map.getBounds().contains(p.getLatLng())).to.be.true;
done();
});
@ -498,7 +498,7 @@ describe('Popup', () => {
const marker1 = L.marker([86, 32]).bindPopup(popup).addTo(map);
const marker2 = L.marker([26.3, 83.9]).bindPopup(popup).addTo(map);
expect(popup.getLatLng()).to.be(undefined);
expect(popup.getLatLng()).to.equal(undefined);
marker1.openPopup();
expect(popup.getLatLng()).to.be.nearLatLng([86, 32]);
@ -517,46 +517,46 @@ describe('Popup', () => {
it('only adds a popup to the map when opened', () => {
marker.bindPopup('new layer');
expect(map.hasLayer(marker.getPopup())).to.be(false);
expect(map.hasLayer(marker.getPopup())).to.be.false;
marker.openPopup();
expect(map.hasLayer(marker.getPopup())).to.be(true);
expect(map.hasLayer(marker.getPopup())).to.be.true;
});
it('keeps an open popup on the map when it\'s unbound from the layer', () => {
marker.bindPopup('new layer').openPopup();
const popup = marker.getPopup();
marker.unbindPopup();
expect(map.hasLayer(popup)).to.be(true);
expect(map.hasLayer(popup)).to.be.true;
});
it('should not give an error when the marker has no popup', () => {
expect(() => {
marker.isPopupOpen();
}).to.not.throwException();
expect(marker.isPopupOpen()).to.be(false);
}).to.not.throw();
expect(marker.isPopupOpen()).to.be.false;
});
it('should show a popup as closed if it\'s never opened', () => {
marker.bindPopup('new layer');
expect(marker.isPopupOpen()).to.be(false);
expect(marker.isPopupOpen()).to.be.false;
});
it('should show a popup as opend if it\'s opened', () => {
marker.bindPopup('new layer').openPopup();
expect(marker.isPopupOpen()).to.be(true);
expect(marker.isPopupOpen()).to.be.true;
});
it('should show a popup as closed if it\'s opened and closed', () => {
marker.bindPopup('new layer').openPopup().closePopup();
expect(marker.isPopupOpen()).to.be(false);
expect(marker.isPopupOpen()).to.be.false;
});
it('should show the popup as closed if it\'s unbound', () => {
marker.bindPopup('new layer').openPopup().unbindPopup();
expect(() => {
marker.isPopupOpen();
}).to.not.throwException();
expect(marker.isPopupOpen()).to.be(false);
}).to.not.throw();
expect(marker.isPopupOpen()).to.be.false;
});
it('does not throw is popup is inmediately closed', (done) => {
@ -567,7 +567,7 @@ describe('Popup', () => {
expect(() => {
marker.bindPopup('new layer').openPopup();
done();
}).to.not.throwException();
}).to.not.throw();
});
it('does not close popup when clicking on it\'s tip', () => {
@ -580,13 +580,13 @@ describe('Popup', () => {
const point = map.latLngToContainerPoint(map.getCenter());
point.y -= 2; // move mouse into the popup-tip
const el = document.elementFromPoint(point.x, point.y);
expect(el).to.be(popup._tip);
expect(el).to.equal(popup._tip);
UIEventSimulator.fire('click', el, {
clientX: point.x,
clientY: point.y
});
expect(popup.isOpen()).to.be.ok();
expect(popup.isOpen()).to.be.true;
});
it('does not open for empty FeatureGroup', () => {
@ -596,7 +596,7 @@ describe('Popup', () => {
.bindPopup(popup)
.openPopup();
expect(map.hasLayer(popup)).to.not.be.ok();
expect(map.hasLayer(popup)).to.be.false;
});
it('uses only visible layers of FeatureGroup for popup content source', () => {
@ -612,8 +612,8 @@ describe('Popup', () => {
marker3.remove();
group.openPopup();
expect(map.hasLayer(popup)).to.be.ok();
expect(popup._source).to.be(marker2);
expect(map.hasLayer(popup)).to.be.true;
expect(popup._source).to.equal(marker2);
});
});
});

View File

@ -19,10 +19,10 @@ describe('Tooltip', () => {
UIEventSimulator.fire('mouseover', layer._icon, {relatedTarget: map._container});
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
UIEventSimulator.fire('mouseout', layer._icon, {relatedTarget: map._container});
expect(map.hasLayer(layer._tooltip)).to.be(false);
expect(map.hasLayer(layer._tooltip)).to.be.false;
});
it('opens on marker focus and closes on blur', () => {
@ -34,10 +34,10 @@ describe('Tooltip', () => {
UIEventSimulator.fire('focus', element);
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
UIEventSimulator.fire('blur', element);
expect(map.hasLayer(layer._tooltip)).to.be(false);
expect(map.hasLayer(layer._tooltip)).to.be.false;
});
it('opens on marker focus and closes on blur when first bound, then added to map', () => {
@ -49,10 +49,10 @@ describe('Tooltip', () => {
UIEventSimulator.fire('focus', element);
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
UIEventSimulator.fire('blur', element);
expect(map.hasLayer(layer._tooltip)).to.be(false);
expect(map.hasLayer(layer._tooltip)).to.be.false;
});
it('opens on marker focus and closes on blur in layer group', () => {
@ -66,19 +66,19 @@ describe('Tooltip', () => {
UIEventSimulator.fire('focus', element1);
expect(map.hasLayer(group._tooltip)).to.be(true);
expect(group._tooltip._container.innerHTML).to.be('Group tooltip: Marker 1');
expect(map.hasLayer(group._tooltip)).to.be.true;
expect(group._tooltip._container.innerHTML).to.equal('Group tooltip: Marker 1');
UIEventSimulator.fire('blur', element1);
expect(map.hasLayer(group._tooltip)).to.be(false);
expect(map.hasLayer(group._tooltip)).to.be.false;
UIEventSimulator.fire('focus', element2);
expect(map.hasLayer(group._tooltip)).to.be(true);
expect(group._tooltip._container.innerHTML).to.be('Group tooltip: Marker 2');
expect(map.hasLayer(group._tooltip)).to.be.true;
expect(group._tooltip._container.innerHTML).to.equal('Group tooltip: Marker 2');
UIEventSimulator.fire('blur', element2);
expect(map.hasLayer(group._tooltip)).to.be(false);
expect(map.hasLayer(group._tooltip)).to.be.false;
});
it('is mentioned in aria-describedby of a bound layer', () => {
@ -112,25 +112,25 @@ describe('Tooltip', () => {
const layer = L.marker(center).addTo(map);
layer.bindTooltip('Tooltip', {permanent: true});
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
});
it('can be added with bindTooltip before added to the map', () => {
const layer = L.marker(center);
layer.bindTooltip('Tooltip', {permanent: true});
expect(map.hasLayer(layer._tooltip)).to.be(false);
expect(map.hasLayer(layer._tooltip)).to.be.false;
layer.addTo(map);
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
});
it('is removed when removing marker', () => {
const layer = L.marker(center).addTo(map);
layer.bindTooltip('Tooltip', {permanent: true});
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
layer.remove();
expect(map.hasLayer(layer._tooltip)).to.be(false);
expect(map.hasLayer(layer._tooltip)).to.be.false;
});
it('is not interactive by default', () => {
@ -140,7 +140,7 @@ describe('Tooltip', () => {
layer.bindTooltip('Tooltip', {permanent: true});
layer._tooltip.on('click', spy);
UIEventSimulator.fire('click', layer._tooltip._container);
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
});
it('can be made interactive', () => {
@ -150,7 +150,7 @@ describe('Tooltip', () => {
layer.bindTooltip('Tooltip', {permanent: true, interactive: true});
layer._tooltip.on('click', spy);
UIEventSimulator.fire('click', layer._tooltip._container);
expect(spy.calledOnce).to.be(true);
expect(spy.calledOnce).to.be.true;
});
it('events are propagated to bound layer', () => {
@ -160,19 +160,19 @@ describe('Tooltip', () => {
layer.bindTooltip('Tooltip', {permanent: true, interactive: true});
UIEventSimulator.fire('click', layer._tooltip._container);
expect(spy.calledOnce).to.be(true);
expect(spy.calledOnce).to.be.true;
});
it('has class leaflet-interactive', () => {
const layer = L.marker(center).addTo(map);
layer.bindTooltip('Tooltip', {permanent: true, interactive: true});
expect(layer._tooltip._container.classList.contains('leaflet-interactive')).to.be(true);
expect(layer._tooltip._container.classList.contains('leaflet-interactive')).to.be.true;
});
it('has not class leaflet-interactive', () => {
const layer = L.marker(center).addTo(map);
layer.bindTooltip('Tooltip', {permanent: true});
expect(layer._tooltip._container.classList.contains('leaflet-interactive')).to.be(false);
expect(layer._tooltip._container.classList.contains('leaflet-interactive')).to.be.false;
});
it('can be forced on left direction', () => {
@ -181,9 +181,9 @@ describe('Tooltip', () => {
layer.on('click', spy);
layer.bindTooltip('A long tooltip that should be displayed on the left', {permanent: true, direction: 'left', interactive: true});
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
UIEventSimulator.fireAt('click', 150, 180); // Marker is on the map center, which is 400px large.
expect(spy.calledOnce).to.be(true);
expect(spy.calledOnce).to.be.true;
});
it('honours offset on left direction', () => {
@ -192,11 +192,11 @@ describe('Tooltip', () => {
layer.on('click', spy);
layer.bindTooltip('A long tooltip that should be displayed on the left', {permanent: true, direction: 'left', interactive: true, offset: [-20, -20]});
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
UIEventSimulator.fireAt('click', 150, 180);
expect(spy.calledOnce).to.be(false);
expect(spy.calledOnce).to.be.false;
UIEventSimulator.fireAt('click', 130, 160);
expect(spy.calledOnce).to.be(true);
expect(spy.calledOnce).to.be.true;
});
it('can be forced on top direction', () => {
@ -205,9 +205,9 @@ describe('Tooltip', () => {
layer.on('click', spy);
layer.bindTooltip('A tooltip that should be displayed on the top', {permanent: true, direction: 'top', interactive: true});
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
UIEventSimulator.fireAt('click', 200, 180); // Marker is on the map center, which is 400px large.
expect(spy.calledOnce).to.be(true);
expect(spy.calledOnce).to.be.true;
});
it('honours offset on top direction', () => {
@ -217,9 +217,9 @@ describe('Tooltip', () => {
layer.bindTooltip('A tooltip that should be displayed on the top', {permanent: true, direction: 'top', interactive: true, offset: [-20, -20]});
UIEventSimulator.fireAt('click', 200, 180);
expect(spy.calledOnce).to.be(false);
expect(spy.calledOnce).to.be.false;
UIEventSimulator.fireAt('click', 180, 150);
expect(spy.calledOnce).to.be(true);
expect(spy.calledOnce).to.be.true;
});
it('can be forced on bottom direction', () => {
@ -228,9 +228,9 @@ describe('Tooltip', () => {
layer.on('click', spy);
layer.bindTooltip('A tooltip that should be displayed on the top', {permanent: true, direction: 'bottom', interactive: true});
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
UIEventSimulator.fireAt('click', 200, 220); // Marker is on the map center, which is 400px large.
expect(spy.calledOnce).to.be(true);
expect(spy.calledOnce).to.be.true;
});
it('honours offset on bottom direction', () => {
@ -239,11 +239,11 @@ describe('Tooltip', () => {
layer.on('click', spy);
layer.bindTooltip('A tooltip that should be displayed on the top', {permanent: true, direction: 'bottom', interactive: true, offset: [20, 20]});
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
UIEventSimulator.fireAt('click', 200, 220);
expect(spy.calledOnce).to.be(false);
expect(spy.calledOnce).to.be.false;
UIEventSimulator.fireAt('click', 220, 230);
expect(spy.calledOnce).to.be(true);
expect(spy.calledOnce).to.be.true;
});
it('can be forced on center', () => {
@ -252,23 +252,23 @@ describe('Tooltip', () => {
layer.on('click', spy);
layer.bindTooltip('A tooltip that should be displayed on the center', {permanent: true, direction: 'center', interactive: true});
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
UIEventSimulator.fireAt('click', 150, 180); // Marker is on the map center, which is 400px large.
expect(spy.calledOnce).to.be(true);
expect(spy.calledOnce).to.be.true;
});
it('honours opacity option', () => {
const layer = L.marker(center).addTo(map);
layer.bindTooltip('Tooltip', {permanent: true, opacity: 0.57});
expect(layer._tooltip._container.style.opacity).to.eql(0.57);
expect(layer._tooltip._container.style.opacity).to.eql('0.57');
});
it('can change opacity with setOpacity', () => {
const layer = L.marker(center).addTo(map);
layer.bindTooltip('Tooltip', {permanent: true});
expect(layer._tooltip._container.style.opacity).to.eql(0.9);
expect(layer._tooltip._container.style.opacity).to.eql('0.9');
layer._tooltip.setOpacity(0.57);
expect(layer._tooltip._container.style.opacity).to.eql(0.57);
expect(layer._tooltip._container.style.opacity).to.eql('0.57');
});
it('it should use a tooltip with a function as content with a FeatureGroup', () => {
@ -280,13 +280,13 @@ describe('Tooltip', () => {
// toggle popup on marker1
UIEventSimulator.fire('mouseover', marker1._icon, {relatedTarget: map._container});
expect(map.hasLayer(group._tooltip)).to.be(true);
expect(group._tooltip._container.innerHTML).to.be('I\'m marker 1.');
expect(map.hasLayer(group._tooltip)).to.be.true;
expect(group._tooltip._container.innerHTML).to.equal('I\'m marker 1.');
// toggle popup on marker2
UIEventSimulator.fire('mouseover', marker2._icon, {relatedTarget: map._container});
expect(map.hasLayer(group._tooltip)).to.be(true);
expect(group._tooltip._container.innerHTML).to.be('I\'m marker 2.');
expect(map.hasLayer(group._tooltip)).to.be.true;
expect(group._tooltip._container.innerHTML).to.equal('I\'m marker 2.');
});
it('opens on polygon mouseover and close on mouseout', () => {
@ -296,30 +296,30 @@ describe('Tooltip', () => {
UIEventSimulator.fire('mouseover', layer._path, {relatedTarget: map._container});
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
UIEventSimulator.fire('mouseout', layer._path, {relatedTarget: map._container});
expect(map.hasLayer(layer._tooltip)).to.be(false);
expect(map.hasLayer(layer._tooltip)).to.be.false;
});
it('stays open on polygon when permanent', () => {
const layer = L.polygon([[55.8, 37.6], [55.9, 37.6], [55.8, 37.5]]).addTo(map);
layer.bindTooltip('Tooltip', {permanent: true});
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
});
it('can be added on polygon with bindTooltip before beind added to the map', () => {
const layer = L.polygon([[55.8, 37.6], [55.9, 37.6], [55.8, 37.5]]);
layer.bindTooltip('Tooltip', {permanent: true});
expect(map.hasLayer(layer._tooltip)).to.be(false);
expect(map.hasLayer(layer._tooltip)).to.be.false;
layer.addTo(map);
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
layer.remove();
expect(map.hasLayer(layer._tooltip)).to.be(false);
expect(map.hasLayer(layer._tooltip)).to.be.false;
layer.addTo(map);
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
});
it('opens on polyline mouseover and close on mouseout', () => {
@ -329,39 +329,39 @@ describe('Tooltip', () => {
UIEventSimulator.fire('mouseover', layer._path, {relatedTarget: map._container});
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
UIEventSimulator.fire('mouseout', layer._path, {relatedTarget: map._container});
expect(map.hasLayer(layer._tooltip)).to.be(false);
expect(map.hasLayer(layer._tooltip)).to.be.false;
});
it('stays open on polyline when permanent', () => {
const layer = L.polyline([[55.8, 37.6], [55.9, 37.6], [55.8, 37.5]]).addTo(map);
layer.bindTooltip('Tooltip', {permanent: true});
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
});
it('can be added on polyline with bindTooltip before added to the map', () => {
const layer = L.polyline([[55.8, 37.6], [55.9, 37.6], [55.8, 37.5]]);
layer.bindTooltip('Tooltip', {permanent: true});
expect(map.hasLayer(layer._tooltip)).to.be(false);
expect(map.hasLayer(layer._tooltip)).to.be.false;
layer.addTo(map);
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
layer.remove();
expect(map.hasLayer(layer._tooltip)).to.be(false);
expect(map.hasLayer(layer._tooltip)).to.be.false;
layer.addTo(map);
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
});
it.skipIfNotTouch('is opened when tapping on touch', () => {
const layer = L.marker(center).addTo(map);
layer.bindTooltip('Tooltip');
expect(map.hasLayer(layer._tooltip)).to.be(false);
expect(map.hasLayer(layer._tooltip)).to.be.false;
UIEventSimulator.fire('click', layer._icon);
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
});
it.skipIfNotTouch('is closed if not permanent when clicking on the map elsewhere on touch', () => {
@ -369,15 +369,15 @@ describe('Tooltip', () => {
layer.bindTooltip('Tooltip');
UIEventSimulator.fire('click', layer._icon);
expect(map.hasLayer(layer._tooltip)).to.be(true);
expect(map.hasLayer(layer._tooltip)).to.be.true;
UIEventSimulator.fire('click', map._container);
expect(map.hasLayer(layer._tooltip)).to.be(false);
expect(map.hasLayer(layer._tooltip)).to.be.false;
});
it('opens with map.openTooltip', (done) => {
map.on('tooltipopen', (e) => {
expect(map.hasLayer(e.tooltip)).to.be(true);
expect(map.hasLayer(e.tooltip)).to.be.true;
done();
});
map.openTooltip('Tooltip', center);
@ -391,7 +391,7 @@ describe('Tooltip', () => {
map.openTooltip(tooltip, center);
UIEventSimulator.fire('click', tooltip._container);
expect(spy.calledOnce).to.be(true);
expect(spy.calledOnce).to.be.true;
});
it('can call closeTooltip while not on the map', () => {
@ -404,24 +404,24 @@ describe('Tooltip', () => {
const layer = L.rectangle([[58, 39.7], [54, 35.3]]).addTo(map);
layer.bindTooltip('Sticky', {sticky: true}).openTooltip();
const tooltip = layer.getTooltip();
expect(tooltip.getLatLng().equals(layer.getCenter())).to.be(true);
expect(tooltip.getLatLng().equals(layer.getCenter())).to.be.true;
UIEventSimulator.fireAt('click', 120, 120);
const latlng = map.containerPointToLatLng([120, 120]);
expect(tooltip.getLatLng().equals(latlng)).to.be(true);
expect(tooltip.getLatLng().equals(latlng)).to.be.true;
});
it('opens a permanent tooltip and follow the mouse (sticky)', (done) => {
const layer = L.rectangle([[58, 39.7], [54, 35.3]]).addTo(map);
layer.bindTooltip('Sticky', {sticky: true, permanent: true}).openTooltip();
const tooltip = layer.getTooltip();
expect(tooltip.getLatLng().equals(layer.getCenter())).to.be(true);
expect(tooltip.getLatLng().equals(layer.getCenter())).to.be.true;
const hand = new Hand({
timing: 'fastframe',
onStop() {
const latlng = map.containerPointToLatLng([120, 120]);
expect(tooltip.getLatLng().equals(latlng)).to.be(true);
expect(tooltip.getLatLng().equals(latlng)).to.be.true;
done();
}
});
@ -436,8 +436,8 @@ describe('Tooltip', () => {
const tooltip1 = layer.getTooltip();
layer.bindTooltip('Tooltip2').openTooltip();
layer.unbindTooltip.restore(); // unwrap the spy
expect(map.hasLayer(tooltip1)).to.not.be.ok();
expect(eventSpy.calledOnce).to.be.ok();
expect(map.hasLayer(tooltip1)).to.be.false;
expect(eventSpy.calledOnce).to.be.true;
});
it('don\'t opens the tooltip on marker mouseover while dragging map', () => {
@ -451,14 +451,14 @@ describe('Tooltip', () => {
return true;
};
UIEventSimulator.fireAt('mouseover', 210, 195);
expect(tooltip.isOpen()).to.be(false);
expect(tooltip.isOpen()).to.be.false;
// simulate map not dragging anymore
map.dragging.moving = function () {
return false;
};
UIEventSimulator.fireAt('mouseover', 210, 195);
expect(tooltip.isOpen()).to.be.ok();
expect(tooltip.isOpen()).to.be.true;
});
it('closes the tooltip on marker mouseout while dragging map and don\'t open it again', () => {
@ -469,38 +469,38 @@ describe('Tooltip', () => {
// open tooltip before "dragging map"
UIEventSimulator.fireAt('mouseover', 210, 195);
expect(tooltip.isOpen()).to.be.ok();
expect(tooltip.isOpen()).to.be.true;
// simulate map dragging
map.dragging.moving = function () {
return true;
};
UIEventSimulator.fire('mouseout', layer._icon, {relatedTarget: map._container});
expect(tooltip.isOpen()).to.be(false);
expect(tooltip.isOpen()).to.be.false;
// tooltip should not open again while dragging
UIEventSimulator.fireAt('mouseover', 210, 195);
expect(tooltip.isOpen()).to.be(false);
expect(tooltip.isOpen()).to.be.false;
});
it('opens tooltip with passed latlng position while initializing', () => {
const tooltip = new L.Tooltip(center)
.addTo(map);
expect(map.hasLayer(tooltip)).to.be(true);
expect(map.hasLayer(tooltip)).to.be.true;
});
it('opens tooltip with passed latlng and options position while initializing', () => {
const tooltip = new L.Tooltip(center, {className: 'testClass'})
.addTo(map);
expect(map.hasLayer(tooltip)).to.be(true);
expect(tooltip.getElement().classList.contains('testClass')).to.be(true);
expect(map.hasLayer(tooltip)).to.be.true;
expect(tooltip.getElement().classList.contains('testClass')).to.be.true;
});
it('adds tooltip with passed content in options while initializing', () => {
const tooltip = new L.Tooltip(center, {content: 'Test'})
.addTo(map);
expect(map.hasLayer(tooltip)).to.be(true);
expect(tooltip.getContent()).to.be('Test');
expect(map.hasLayer(tooltip)).to.be.true;
expect(tooltip.getContent()).to.equal('Test');
});
// Related to #8558
@ -528,11 +528,11 @@ describe('Tooltip', () => {
expect(e.target.options.testId).to.eql('markerB');
});
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
layer1.openTooltip().closeTooltip();
expect(spy.called).to.be(true);
expect(spy2.called).to.be(false);
expect(spy.called).to.be.true;
expect(spy2.called).to.be.false;
layer2.openTooltip();
expect(spy2.called).to.be(true);
expect(spy2.called).to.be.true;
});
});

View File

@ -23,6 +23,6 @@ describe('VideoOverlay', () => {
const videoOverlay = L.videoOverlay(videoUrls, videoBounds).addTo(map);
expect(map.hasLayer(videoOverlay)).to.be.ok();
expect(map.hasLayer(videoOverlay)).to.be.true;
});
});

View File

@ -15,11 +15,11 @@ describe('Icon.Default', () => {
it('detect icon images path', () => {
const origPath = L.Icon.Default.imagePath; // set in after.js
expect(origPath).to.be.ok();
expect(origPath).to.be.ok;
delete L.Icon.Default.imagePath;
const marker = L.marker([0, 0]);
expect(L.Icon.Default.imagePath).to.not.be.ok();
expect(L.Icon.Default.imagePath).to.be.undefined;
marker.addTo(map);
expect(L.Icon.Default.imagePath).to.equal(location.origin + origPath);
@ -30,23 +30,23 @@ describe('Icon.Default', () => {
'url("http://localhost:8000/base/dist/images/marker-icon.png")', // Firefox
'url(\'http://localhost:8000/base/dist/images/marker-icon.png\')',
'url(http://localhost:8000/base/dist/images/marker-icon.png)', // IE, Edge
].map(stripUrl).forEach((str) => { expect(str).to.be(properPath); });
].map(stripUrl).forEach((str) => { expect(str).to.equal(properPath); });
[ // invalid
'url("http://localhost:8000/base/dist/images/marker-icon.png?2x)"',
'url("data:image/png;base64,iVBORw...")', // inline image (bundlers)
].map(stripUrl).forEach((str) => { expect(str).not.to.be.ok(); });
].map(stripUrl).forEach((str) => { expect(str).not.to.be.true; });
});
it('icon measures 25x41px', () => {
const img = map.getPane('markerPane').querySelector('img');
expect(img.clientHeight).to.be(41);
expect(img.clientWidth).to.be(25);
expect(img.clientHeight).to.equal(41);
expect(img.clientWidth).to.equal(25);
});
it('shadow measures 41x41px', () => {
const img = map.getPane('shadowPane').querySelector('img');
expect(img.clientHeight).to.be(41);
expect(img.clientWidth).to.be(41);
expect(img.clientHeight).to.equal(41);
expect(img.clientWidth).to.equal(41);
});
});

View File

@ -36,7 +36,7 @@ describe('Marker.Drag', () => {
const hand = new Hand({
timing: 'fastframe',
onStop() {
expect(marker.getOffset()).to.eql(offset);
expect(marker.getOffset().equals(offset)).to.be.true;
expect(map.getCenter()).to.be.nearLatLng([0, 0]);
expect(marker.getLatLng()).to.be.nearLatLng([-40.979898069620134, 360]);

View File

@ -35,8 +35,8 @@ describe('Marker', () => {
const icon = marker._icon;
expect(icon.style.width).to.be(`${expectedX}px`);
expect(icon.style.height).to.be(`${expectedY}px`);
expect(icon.style.width).to.equal(`${expectedX}px`);
expect(icon.style.height).to.equal(`${expectedY}px`);
});
it('set the correct x and y size attributes passing only one value', () => {
@ -51,8 +51,8 @@ describe('Marker', () => {
const icon = marker._icon;
expect(icon.style.width).to.be(`${expectedXY}px`);
expect(icon.style.height).to.be(`${expectedXY}px`);
expect(icon.style.width).to.equal(`${expectedXY}px`);
expect(icon.style.height).to.equal(`${expectedXY}px`);
});
it('set the correct x and y size attributes passing a L.Point instance', () => {
@ -67,8 +67,8 @@ describe('Marker', () => {
const icon = marker._icon;
expect(icon.style.width).to.be(`${expectedXY}px`);
expect(icon.style.height).to.be(`${expectedXY}px`);
expect(icon.style.width).to.equal(`${expectedXY}px`);
expect(icon.style.height).to.equal(`${expectedXY}px`);
});
it('changes the icon to another image while re-using the IMG element', () => {
@ -79,7 +79,7 @@ describe('Marker', () => {
marker.setIcon(icon2);
const afterIcon = marker._icon;
expect(beforeIcon).to.be(afterIcon); // Check that the <IMG> element is re-used
expect(beforeIcon).to.equal(afterIcon); // Check that the <IMG> element is re-used
expect(afterIcon.src).to.contain(icon2._getIconUrl('icon'));
});
@ -90,34 +90,34 @@ describe('Marker', () => {
marker.dragging.disable();
marker.setIcon(icon2);
expect(marker.dragging.enabled()).to.be(false);
expect(marker.dragging.enabled()).to.be.false;
marker.dragging.enable();
marker.setIcon(icon1);
expect(marker.dragging.enabled()).to.be(true);
expect(marker.dragging.enabled()).to.be.true;
map.removeLayer(marker);
map.addLayer(marker);
expect(marker.dragging.enabled()).to.be(true);
expect(marker.dragging.enabled()).to.be.true;
map.removeLayer(marker);
// Dragging is still enabled, we should be able to disable it,
// even if marker is off the map.
expect(marker.dragging).to.be(undefined);
expect(marker.dragging).to.equal(undefined);
marker.options.draggable = false;
map.addLayer(marker);
map.removeLayer(marker);
// We should also be able to enable dragging while off the map
expect(marker.dragging).to.be(undefined);
expect(marker.dragging).to.equal(undefined);
marker.options.draggable = true;
map.addLayer(marker);
expect(marker.dragging.enabled()).to.be(true);
expect(marker.dragging.enabled()).to.be.true;
});
it('changes the DivIcon to another DivIcon, while re-using the DIV element', () => {
@ -128,7 +128,7 @@ describe('Marker', () => {
marker.setIcon(L.divIcon({html: 'Inner2Text'}));
const afterIcon = marker._icon;
expect(beforeIcon).to.be(afterIcon); // Check that the <DIV> element is re-used
expect(beforeIcon).to.equal(afterIcon); // Check that the <DIV> element is re-used
expect(afterIcon.innerHTML).to.contain('Inner2Text');
});
@ -148,15 +148,15 @@ describe('Marker', () => {
marker.setIcon(icon1);
expect(oldIcon).to.not.be(marker._icon); // Check that the _icon is NOT re-used
expect(oldIcon.parentNode).to.be(null);
expect(oldIcon).to.not.equal(marker._icon); // Check that the _icon is NOT re-used
expect(oldIcon.parentNode).to.equal(null);
if (L.Browser.retina) {
expect(marker._icon.src).to.contain('marker-icon-2x.png');
} else {
expect(marker._icon.src).to.contain('marker-icon.png');
}
expect(marker._icon.parentNode).to.be(map._panes.markerPane);
expect(marker._icon.parentNode).to.equal(map._panes.markerPane);
});
it('changes an image to a DivIcon', () => {
@ -166,11 +166,11 @@ describe('Marker', () => {
marker.setIcon(L.divIcon({html: 'Inner1Text'}));
expect(oldIcon).to.not.be(marker._icon); // Check that the _icon is NOT re-used
expect(oldIcon.parentNode).to.be(null);
expect(oldIcon).to.not.equal(marker._icon); // Check that the _icon is NOT re-used
expect(oldIcon.parentNode).to.equal(null);
expect(marker._icon.innerHTML).to.contain('Inner1Text');
expect(marker._icon.parentNode).to.be(map._panes.markerPane);
expect(marker._icon.parentNode).to.equal(map._panes.markerPane);
});
it('reuses the icon/shadow when changing icon', () => {
@ -181,26 +181,26 @@ describe('Marker', () => {
marker.setIcon(icon2);
expect(oldIcon).to.be(marker._icon);
expect(oldShadow).to.be(marker._shadow);
expect(oldIcon).to.equal(marker._icon);
expect(oldShadow).to.equal(marker._shadow);
expect(marker._icon.parentNode).to.be(map._panes.markerPane);
expect(marker._shadow.parentNode).to.be(map._panes.shadowPane);
expect(marker._icon.parentNode).to.equal(map._panes.markerPane);
expect(marker._shadow.parentNode).to.equal(map._panes.shadowPane);
});
it('sets the alt attribute to a default value when no alt text is passed', () => {
const marker = L.marker([0, 0], {icon: icon1});
map.addLayer(marker);
const icon = marker._icon;
expect(icon.hasAttribute('alt')).to.be(true);
expect(icon.alt).to.be('Marker');
expect(icon.hasAttribute('alt')).to.be.true;
expect(icon.alt).to.equal('Marker');
});
it('doesn\'t set the alt attribute for DivIcons', () => {
const marker = L.marker([0, 0], {icon: L.divIcon(), alt: 'test'});
map.addLayer(marker);
const icon = marker._icon;
expect(icon.hasAttribute('alt')).to.be(false);
expect(icon.hasAttribute('alt')).to.be.false;
});
it('pan map to focus marker', () => {
@ -209,7 +209,7 @@ describe('Marker', () => {
expect(() => {
marker._icon.focus();
}).to.not.throwException();
}).to.not.throw();
});
it('pan map to focus marker with no iconSize', () => {
@ -218,7 +218,7 @@ describe('Marker', () => {
expect(() => {
marker._panOnFocus();
}).to.not.throwException();
}).to.not.throw();
});
});
@ -238,10 +238,10 @@ describe('Marker', () => {
marker.setLatLng(afterLatLng);
expect(eventArgs).to.not.be(null);
expect(eventArgs.oldLatLng).to.be(beforeLatLng);
expect(eventArgs.latlng).to.be(afterLatLng);
expect(marker.getLatLng()).to.be(afterLatLng);
expect(eventArgs).to.not.equal(null);
expect(eventArgs.oldLatLng).to.equal(beforeLatLng);
expect(eventArgs.latlng).to.equal(afterLatLng);
expect(marker.getLatLng()).to.equal(afterLatLng);
});
});
@ -254,7 +254,7 @@ describe('Marker', () => {
marker.on('click', spy);
UIEventSimulator.fire('click', marker._icon);
expect(spy.called).to.be.ok();
expect(spy.called).to.be.true;
});
it('fires click event when clicked with DivIcon', () => {
@ -265,7 +265,7 @@ describe('Marker', () => {
marker.on('click', spy);
UIEventSimulator.fire('click', marker._icon);
expect(spy.called).to.be.ok();
expect(spy.called).to.be.true;
});
it('fires click event when clicked on DivIcon child element', () => {
@ -276,10 +276,10 @@ describe('Marker', () => {
marker.on('click', spy);
UIEventSimulator.fire('click', marker._icon);
expect(spy.called).to.be.ok();
expect(spy.called).to.be.true;
UIEventSimulator.fire('click', marker._icon.querySelector('img'));
expect(spy.calledTwice).to.be.ok();
expect(spy.calledTwice).to.be.true;
});
it('fires click event when clicked on DivIcon child element set using setIcon', () => {
@ -291,10 +291,10 @@ describe('Marker', () => {
marker.on('click', spy);
UIEventSimulator.fire('click', marker._icon);
expect(spy.called).to.be.ok();
expect(spy.called).to.be.true;
UIEventSimulator.fire('click', marker._icon.querySelector('img'));
expect(spy.calledTwice).to.be.ok();
expect(spy.calledTwice).to.be.true;
});
it('do not propagate click event', () => {
@ -307,9 +307,9 @@ describe('Marker', () => {
marker.on('click', spy2);
map.on('click', mapSpy);
UIEventSimulator.fire('click', marker._icon);
expect(spy.called).to.be.ok();
expect(spy2.called).to.be.ok();
expect(mapSpy.called).not.to.be.ok();
expect(spy.called).to.be.true;
expect(spy2.called).to.be.true;
expect(mapSpy.called).not.to.be.true;
});
it('do not propagate dblclick event', () => {
@ -322,9 +322,9 @@ describe('Marker', () => {
marker.on('dblclick', spy2);
map.on('dblclick', mapSpy);
UIEventSimulator.fire('dblclick', marker._icon);
expect(spy.called).to.be.ok();
expect(spy2.called).to.be.ok();
expect(mapSpy.called).not.to.be.ok();
expect(spy.called).to.be.true;
expect(spy2.called).to.be.true;
expect(mapSpy.called).not.to.be.true;
});
it('do not catch event if it does not listen to it', (done) => {

View File

@ -167,7 +167,7 @@ describe('GridLayer', () => {
grid.on('tileload', tileLoadRaised);
grid.on('tileerror', () => {
if (keys.length === 4) {
expect(tileLoadRaised.notCalled).to.be(true);
expect(tileLoadRaised.notCalled).to.be.true;
done();
}
});
@ -179,7 +179,7 @@ describe('GridLayer', () => {
grid.on('tileerror', () => {
tileErrorRaised();
if (keys.length === 4) {
expect(tileErrorRaised.callCount).to.be(4);
expect(tileErrorRaised.callCount).to.equal(4);
done();
}
});
@ -193,7 +193,7 @@ describe('GridLayer', () => {
count++;
}
if (keys.length === 4) {
expect(count).to.be(4);
expect(count).to.equal(4);
done();
}
});
@ -218,7 +218,7 @@ describe('GridLayer', () => {
map.on('zoomend', onReset);
map.setView([0, 0], 0);
expect(onReset.calledBefore(onAddSpy)).to.be.ok();
expect(onReset.calledBefore(onAddSpy)).to.be.true;
});
});
@ -237,36 +237,36 @@ describe('GridLayer', () => {
minZoom
}).addTo(map);
expect(map.getMaxZoom()).to.be(maxZoom);
expect(map.getMinZoom()).to.be(minZoom);
expect(map.getMaxZoom()).to.equal(maxZoom);
expect(map.getMinZoom()).to.equal(minZoom);
});
});
describe('accessing a gridlayer\'s properties', () => {
it('provides a container', () => {
const layer = L.gridLayer().addTo(map);
expect(layer.getContainer()).to.be.ok();
expect(layer.getContainer()).to.be.ok;
});
});
describe('when a gridlayer is added to a map that already has a gridlayer', () => {
it('has its zoomlevels updated to fit the new layer', () => {
L.gridLayer({minZoom: 10, maxZoom: 15}).addTo(map);
expect(map.getMinZoom()).to.be(10);
expect(map.getMaxZoom()).to.be(15);
expect(map.getMinZoom()).to.equal(10);
expect(map.getMaxZoom()).to.equal(15);
L.gridLayer({minZoom: 5, maxZoom: 10}).addTo(map);
expect(map.getMinZoom()).to.be(5); // changed
expect(map.getMaxZoom()).to.be(15); // unchanged
expect(map.getMinZoom()).to.equal(5); // changed
expect(map.getMaxZoom()).to.equal(15); // unchanged
L.gridLayer({minZoom: 10, maxZoom: 20}).addTo(map);
expect(map.getMinZoom()).to.be(5); // unchanged
expect(map.getMaxZoom()).to.be(20); // changed
expect(map.getMinZoom()).to.equal(5); // unchanged
expect(map.getMaxZoom()).to.equal(20); // changed
L.gridLayer({minZoom: 0, maxZoom: 25}).addTo(map);
expect(map.getMinZoom()).to.be(0); // changed
expect(map.getMaxZoom()).to.be(25); // changed
expect(map.getMinZoom()).to.equal(0); // changed
expect(map.getMaxZoom()).to.equal(25); // changed
});
});
@ -278,24 +278,24 @@ describe('GridLayer', () => {
L.gridLayer({minZoom: 10, maxZoom: 20}).addTo(map),
L.gridLayer({minZoom: 0, maxZoom: 25}).addTo(map)
];
expect(map.getMinZoom()).to.be(0);
expect(map.getMaxZoom()).to.be(25);
expect(map.getMinZoom()).to.equal(0);
expect(map.getMaxZoom()).to.equal(25);
map.removeLayer(tiles[0]);
expect(map.getMinZoom()).to.be(0);
expect(map.getMaxZoom()).to.be(25);
expect(map.getMinZoom()).to.equal(0);
expect(map.getMaxZoom()).to.equal(25);
map.removeLayer(tiles[3]);
expect(map.getMinZoom()).to.be(5);
expect(map.getMaxZoom()).to.be(20);
expect(map.getMinZoom()).to.equal(5);
expect(map.getMaxZoom()).to.equal(20);
map.removeLayer(tiles[2]);
expect(map.getMinZoom()).to.be(5);
expect(map.getMaxZoom()).to.be(10);
expect(map.getMinZoom()).to.equal(5);
expect(map.getMaxZoom()).to.equal(10);
map.removeLayer(tiles[1]);
expect(map.getMinZoom()).to.be(0);
expect(map.getMaxZoom()).to.be(Infinity);
expect(map.getMinZoom()).to.equal(0);
expect(map.getMaxZoom()).to.equal(Infinity);
});
});
});
@ -310,7 +310,7 @@ describe('GridLayer', () => {
let tileCount = 0;
grid.createTile = function (coords) {
expect(coords.z).to.be(5);
expect(coords.z).to.equal(5);
tileCount++;
return document.createElement('div');
};
@ -334,7 +334,7 @@ describe('GridLayer', () => {
let tileCount = 0;
grid.createTile = function (coords) {
expect(coords.z).to.be(5);
expect(coords.z).to.equal(5);
tileCount++;
return document.createElement('div');
};
@ -354,11 +354,11 @@ describe('GridLayer', () => {
map.setView([0, 0], initialZoom);
const grid = L.gridLayer().addTo(map);
expect(grid._tileZoom).to.be(initialZoom);
expect(grid._tileZoom).to.equal(initialZoom);
grid.options.maxNativeZoom = 11;
grid.redraw();
expect(grid._tileZoom).to.be(11);
expect(grid._tileZoom).to.equal(11);
});
});
@ -408,9 +408,9 @@ describe('GridLayer', () => {
it('Loads 8 tiles zoom 1', (done) => {
grid.on('load', () => {
expect(counts.tileloadstart).to.be(8);
expect(counts.tileload).to.be(8);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(8);
expect(counts.tileload).to.equal(8);
expect(counts.tileunload).to.equal(0);
done();
});
@ -420,9 +420,9 @@ describe('GridLayer', () => {
it('Loads 5 tiles zoom 0', (done) => {
grid.on('load', () => {
expect(counts.tileloadstart).to.be(5);
expect(counts.tileload).to.be(5);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(5);
expect(counts.tileload).to.equal(5);
expect(counts.tileunload).to.equal(0);
done();
});
@ -432,9 +432,9 @@ describe('GridLayer', () => {
it('Loads 16 tiles zoom 10', (done) => {
grid.on('load', () => {
expect(counts.tileloadstart).to.be(16);
expect(counts.tileload).to.be(16);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(16);
expect(counts.tileload).to.equal(16);
expect(counts.tileunload).to.equal(0);
grid.off();
done();
@ -446,15 +446,15 @@ describe('GridLayer', () => {
it('Loads 32, unloads 16 tiles zooming in 10-11', (done) => {
grid.on('load', () => {
expect(counts.tileloadstart).to.be(16);
expect(counts.tileload).to.be(16);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(16);
expect(counts.tileload).to.equal(16);
expect(counts.tileunload).to.equal(0);
grid.off('load');
grid.on('load', () => {
expect(counts.tileloadstart).to.be(32);
expect(counts.tileload).to.be(32);
expect(counts.tileunload).to.be(16);
expect(counts.tileloadstart).to.equal(32);
expect(counts.tileload).to.equal(32);
expect(counts.tileunload).to.equal(16);
done();
});
@ -469,15 +469,15 @@ describe('GridLayer', () => {
it('Loads 32, unloads 16 tiles zooming out 11-10', (done) => {
grid.on('load', () => {
expect(counts.tileloadstart).to.be(16);
expect(counts.tileload).to.be(16);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(16);
expect(counts.tileload).to.equal(16);
expect(counts.tileunload).to.equal(0);
grid.off('load');
grid.on('load', () => {
expect(counts.tileloadstart).to.be(32);
expect(counts.tileload).to.be(32);
expect(counts.tileunload).to.be(16);
expect(counts.tileloadstart).to.equal(32);
expect(counts.tileload).to.equal(32);
expect(counts.tileunload).to.equal(16);
done();
});
@ -492,15 +492,15 @@ describe('GridLayer', () => {
it('Loads 32, unloads 16 tiles zooming out 18-10', (done) => {
grid.on('load', () => {
expect(counts.tileloadstart).to.be(16);
expect(counts.tileload).to.be(16);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(16);
expect(counts.tileload).to.equal(16);
expect(counts.tileunload).to.equal(0);
grid.off('load');
grid.on('load', () => {
expect(counts.tileloadstart).to.be(32);
expect(counts.tileload).to.be(32);
expect(counts.tileunload).to.be(16);
expect(counts.tileloadstart).to.equal(32);
expect(counts.tileload).to.equal(32);
expect(counts.tileunload).to.equal(16);
done();
});
@ -589,8 +589,8 @@ describe('GridLayer', () => {
// and avoid removing the above logTiles
// (which would happen when calling "grid.off('load')").
grid.once('load', () => {
expect(counts.tileload).to.be(16);
expect(counts.tileunload).to.be(0);
expect(counts.tileload).to.equal(16);
expect(counts.tileunload).to.equal(0);
// Wait for a frame to let _updateOpacity starting.
L.Util.requestAnimFrame(() => {
@ -601,12 +601,12 @@ describe('GridLayer', () => {
// Date.now() is 301.
grid.once('load', () => {
expect(counts.tileload).to.be(32);
expect(counts.tileload).to.equal(32);
// We're one frame into the zoom animation,
// so GridLayer._setView with noPrune === undefined is not called yet
// No tile should be unloaded yet.
expect(counts.tileunload).to.be(0);
expect(counts.tileunload).to.equal(0);
// Wait > 250msec for the zoom animation to complete,
// which triggers the tile pruning
@ -619,7 +619,7 @@ describe('GridLayer', () => {
// At 301 + 250 = 551ms, the pruneTile from the end of the zoom animation executes.
// It unloads the 'outside' 12 tiles from z10, but not the 4 tiles in the center,
// since _updateOpacity did not have a chance yet to flag the 16 new z11 tiles as "active".
expect(counts.tileunload).to.be(12);
expect(counts.tileunload).to.equal(12);
// Date.now() is 601.
// Wait for a frame to let _updateOpacity starting
@ -636,7 +636,7 @@ describe('GridLayer', () => {
clock.tick(300);
// At 851ms, the pruneTile from the end of the z11 tiles fade-in animation executes.
// It unloads the remaining 4 tiles from z10.
expect(counts.tileunload).to.be(16);
expect(counts.tileunload).to.equal(16);
// Date.now() is 901.
done();
});
@ -646,7 +646,7 @@ describe('GridLayer', () => {
// Animation (and new tiles loading) starts after 1 frame.
L.Util.requestAnimFrame(() => {
// 16 extra tiles from z11 being loaded. Total 16 + 16 = 32.
expect(counts.tileloadstart).to.be(32);
expect(counts.tileloadstart).to.equal(32);
});
});
@ -655,15 +655,15 @@ describe('GridLayer', () => {
map.addLayer(grid).setView([0, 0], 10);
// The first setView does not animated, therefore it starts loading tiles immediately.
// 16 tiles from z10 being loaded.
expect(counts.tileloadstart).to.be(16);
expect(counts.tileloadstart).to.equal(16);
// At 1ms, first pruneTile (map fires "viewreset" event => GridLayer._resetView => GridLayer._setView => _pruneTiles).
});
it('Loads 32, unloads 16 tiles zooming in 10-18', (done) => {
grid.on('load', () => {
expect(counts.tileloadstart).to.be(16);
expect(counts.tileload).to.be(16);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(16);
expect(counts.tileload).to.equal(16);
expect(counts.tileunload).to.equal(0);
grid.off('load');
grid.on('load', () => {
@ -671,9 +671,9 @@ describe('GridLayer', () => {
// In this particular scenario, the tile unloads happen in the
// next render frame after the grid's 'load' event.
L.Util.requestAnimFrame(() => {
expect(counts.tileloadstart).to.be(32);
expect(counts.tileload).to.be(32);
expect(counts.tileunload).to.be(16);
expect(counts.tileloadstart).to.equal(32);
expect(counts.tileload).to.equal(32);
expect(counts.tileunload).to.equal(16);
done();
});
});
@ -694,8 +694,8 @@ describe('GridLayer', () => {
// grid.on('tileload tileunload load', logTiles);
grid.once('load', () => {
expect(counts.tileload).to.be(16);
expect(counts.tileunload).to.be(0);
expect(counts.tileload).to.equal(16);
expect(counts.tileunload).to.equal(0);
// Wait for a frame to let _updateOpacity starting.
L.Util.requestAnimFrame(() => {
@ -706,9 +706,9 @@ describe('GridLayer', () => {
// Date.now() is 301.
grid.once('load', () => {
expect(counts.tileload).to.be(20);
expect(counts.tileload).to.equal(20);
// No tile should be unloaded yet.
expect(counts.tileunload).to.be(0);
expect(counts.tileunload).to.equal(0);
// Wait > 250msec for the zoom animation to complete,
// which triggers the tile pruning, but there are no
@ -718,8 +718,8 @@ describe('GridLayer', () => {
// At the end of the animation, all 16 tiles from z10
// are loading.
expect(counts.tileloadstart).to.be(32);
expect(counts.tileload).to.be(20);
expect(counts.tileloadstart).to.equal(32);
expect(counts.tileload).to.equal(20);
// Now that the zoom animation is complete,
// the grid is ready to fire a new "load" event
@ -728,15 +728,15 @@ describe('GridLayer', () => {
// central tiles from z10 as "active", since we are now
// > 200ms after the first "load" event fired.
grid.once('load', () => {
expect(counts.tileload).to.be(32);
expect(counts.tileload).to.equal(32);
// No tile should be unloaded yet.
expect(counts.tileunload).to.be(0);
expect(counts.tileunload).to.equal(0);
// Wait for a frame for next _updateOpacity to prune
// all 16 tiles from z11 which are now covered by the
// 4 central active tiles of z10.
L.Util.requestAnimFrame(() => {
expect(counts.tileunload).to.be(16);
expect(counts.tileunload).to.equal(16);
done();
});
});
@ -749,21 +749,21 @@ describe('GridLayer', () => {
// We're one frame into the zoom animation, there are
// 16 tiles for z11 plus 4 tiles for z10 covering the
// bounds at the *beginning* of the zoom-*out* anim
expect(counts.tileloadstart).to.be(20);
expect(counts.tileloadstart).to.equal(20);
});
});
map.addLayer(grid).setView([0, 0], 11);
// The first setView does not animated, therefore it starts loading tiles immediately.
// 16 tiles from z10 being loaded.
expect(counts.tileloadstart).to.be(16);
expect(counts.tileloadstart).to.equal(16);
});
it('Loads 32, unloads 16 tiles zooming out 18-10', (done) => {
grid.on('load', () => {
expect(counts.tileloadstart).to.be(16);
expect(counts.tileload).to.be(16);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(16);
expect(counts.tileload).to.equal(16);
expect(counts.tileunload).to.equal(0);
grid.off('load');
grid.on('load', () => {
@ -771,9 +771,9 @@ describe('GridLayer', () => {
// In this particular scenario, the tile unloads happen in the
// next render frame after the grid's 'load' event.
L.Util.requestAnimFrame(() => {
expect(counts.tileloadstart).to.be(32);
expect(counts.tileload).to.be(32);
expect(counts.tileunload).to.be(16);
expect(counts.tileloadstart).to.equal(32);
expect(counts.tileload).to.equal(32);
expect(counts.tileunload).to.equal(16);
done();
});
});
@ -792,16 +792,16 @@ describe('GridLayer', () => {
const mad = [40.40, -3.7], trd = [63.41, 10.41];
grid.on('load', () => {
expect(counts.tileloadstart).to.be(12);
expect(counts.tileload).to.be(12);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(12);
expect(counts.tileload).to.equal(12);
expect(counts.tileunload).to.equal(0);
grid.off('load');
map.on('zoomend', () => {
expect(counts.tileloadstart).to.be(290);
expect(counts.tileunload).to.be(275);
expect(counts.tileload).to.be(290);
expect(grid._container.querySelectorAll('div').length).to.be(16); // 15 + container
expect(counts.tileloadstart).to.equal(290);
expect(counts.tileunload).to.equal(275);
expect(counts.tileload).to.equal(290);
expect(grid._container.querySelectorAll('div').length).to.equal(16); // 15 + container
done();
});
@ -872,9 +872,9 @@ describe('GridLayer', () => {
// Date.now() is 1.
grid.once('load', () => {
expect(counts.tileloadstart).to.be(16);
expect(counts.tileload).to.be(16);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(16);
expect(counts.tileload).to.equal(16);
expect(counts.tileunload).to.equal(0);
// Wait for a frame to let _updateOpacity starting.
L.Util.requestAnimFrame(() => {
@ -889,13 +889,13 @@ describe('GridLayer', () => {
// Since there is no animation requested,
// We directly jump to the target position.
// => 12 new tiles, total = 16 + 12 = 28 tiles.
expect(counts.tileloadstart).to.be(28);
expect(counts.tileload).to.be(28);
expect(counts.tileloadstart).to.equal(28);
expect(counts.tileload).to.equal(28);
// Wait for a frame to let _updateOpacity starting
// It will prune the 12 tiles outside the new bounds.
L.Util.requestAnimFrame(() => {
expect(counts.tileunload).to.be(12);
expect(counts.tileunload).to.equal(12);
done();
});
});
@ -923,26 +923,26 @@ describe('GridLayer', () => {
it('Loads map, moves forth and back by 512 px, keepBuffer = 0', (done) => {
grid.once('load', () => {
expect(counts.tileloadstart).to.be(16);
expect(counts.tileload).to.be(16);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(16);
expect(counts.tileload).to.equal(16);
expect(counts.tileunload).to.equal(0);
grid.once('load', () => {
expect(counts.tileloadstart).to.be(28);
expect(counts.tileload).to.be(28);
expect(counts.tileloadstart).to.equal(28);
expect(counts.tileload).to.equal(28);
// Wait for a frame to let _updateOpacity starting
// It will prune the 12 tiles outside the new bounds.
L.Util.requestAnimFrame(() => {
expect(counts.tileunload).to.be(12);
expect(counts.tileunload).to.equal(12);
grid.once('load', () => {
expect(counts.tileloadstart).to.be(40);
expect(counts.tileload).to.be(40);
expect(counts.tileloadstart).to.equal(40);
expect(counts.tileload).to.equal(40);
// Wait an extra frame for the tile pruning to happen.
L.Util.requestAnimFrame(() => {
expect(counts.tileunload).to.be(24);
expect(counts.tileunload).to.equal(24);
done();
});
});
@ -966,15 +966,15 @@ describe('GridLayer', () => {
const spy = sinon.spy();
grid.on('load', () => {
expect(counts.tileloadstart).to.be(16);
expect(counts.tileload).to.be(16);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(16);
expect(counts.tileload).to.equal(16);
expect(counts.tileunload).to.equal(0);
grid.off('load');
grid.on('load', () => {
expect(counts.tileloadstart).to.be(28);
expect(counts.tileload).to.be(28);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(28);
expect(counts.tileload).to.equal(28);
expect(counts.tileunload).to.equal(0);
grid.off('load');
grid.addEventListener('load', spy);
@ -982,7 +982,7 @@ describe('GridLayer', () => {
map.panBy([-512, -512], {animate: false});
clock.tick(250);
expect(spy.called).to.be(false);
expect(spy.called).to.be.false;
done();
});
@ -1064,16 +1064,16 @@ describe('GridLayer', () => {
describe('Sanity checks for infinity', () => {
it('Throws error on map center at plus Infinity longitude', () => {
expect(() => {
map.setCenter([Infinity, Infinity]);
map.panTo([Infinity, Infinity]);
L.gridLayer().addTo(map);
}).to.throwError('Attempted to load an infinite number of tiles');
}).to.throw('Attempted to load an infinite number of tiles');
});
it('Throws error on map center at minus Infinity longitude', () => {
expect(() => {
map.setCenter([-Infinity, -Infinity]);
map.panTo([-Infinity, -Infinity]);
L.gridLayer().addTo(map);
}).to.throwError('Attempted to load an infinite number of tiles');
}).to.throw('Attempted to load an infinite number of tiles');
});
});
@ -1083,6 +1083,6 @@ describe('GridLayer', () => {
const wrapped = sinon.spy(map, 'getZoomScale');
grid._invalidateAll();
grid.redraw();
expect(wrapped.neverCalledWith(sinon.match.any, null)).to.be(true);
expect(wrapped.neverCalledWith(sinon.match.any, null)).to.be.true;
});
});

View File

@ -235,10 +235,10 @@ describe('TileLayer', () => {
it('Loads 8 kittens zoom 1', (done) => {
kittenLayer.on('load', () => {
expect(counts.tileloadstart).to.be(8);
expect(counts.tileload).to.be(8);
expect(counts.tileunload).to.be(0);
expect(kittenLayer._container.querySelectorAll('img').length).to.be(8);
expect(counts.tileloadstart).to.equal(8);
expect(counts.tileload).to.equal(8);
expect(counts.tileunload).to.equal(0);
expect(kittenLayer._container.querySelectorAll('img').length).to.equal(8);
done();
});
@ -252,19 +252,19 @@ describe('TileLayer', () => {
const mad = [40.40, -3.7], trd = [63.41, 10.41];
kittenLayer.on('load', () => {
expect(counts.tileloadstart).to.be(12);
expect(counts.tileload).to.be(12);
expect(counts.tileunload).to.be(0);
expect(counts.tileloadstart).to.equal(12);
expect(counts.tileload).to.equal(12);
expect(counts.tileunload).to.equal(0);
kittenLayer.off('load');
map.on('zoomend', () => {
expect(counts.tileloadstart).to.be(290);
expect(counts.tileunload).to.be(275);
expect(counts.tileloadstart).to.equal(290);
expect(counts.tileunload).to.equal(275);
// image tiles take time, so then might not be fully loaded yet.
expect(counts.tileload).to.be.lessThan(counts.tileloadstart + 1);
expect(counts.tileload).to.be.greaterThan(counts.tileunload);
expect(kittenLayer._container.querySelectorAll('img').length).to.be(15);
expect(kittenLayer._container.querySelectorAll('img').length).to.equal(15);
done();
});
@ -336,7 +336,7 @@ describe('TileLayer', () => {
expect(() => {
layer.addTo(simpleMap);
}).to.throwError('No value provided for variable {-y}');
}).to.throw('No value provided for variable {-y}');
simpleMap.remove();
document.body.removeChild(simplediv);
@ -422,7 +422,7 @@ describe('TileLayer', () => {
}).addTo(map);
eachImg(layer, (img) => {
expect(img.getAttribute('crossorigin')).to.be(expectedValue);
expect(img.getAttribute('crossorigin')).to.equal(expectedValue);
});
});
}
@ -442,8 +442,8 @@ describe('TileLayer', () => {
});
kittenLayer.on('load', () => {
expect(kittenLayer.options.maxZoom).to.be(maxZoom);
expect(kittenLayer.options.minZoom).to.be(minZoom);
expect(kittenLayer.options.maxZoom).to.equal(maxZoom);
expect(kittenLayer.options.minZoom).to.equal(minZoom);
// reset retina value
L.Browser.retina = originalRetina;
@ -468,7 +468,7 @@ describe('TileLayer', () => {
kittenLayer.on('load', () => {
// zooms should be identical so that we can load tiles for the given zoom level
expect(kittenLayer.options.maxZoom).to.be(kittenLayer.options.minZoom);
expect(kittenLayer.options.maxZoom).to.equal(kittenLayer.options.minZoom);
// reset retina value
L.Browser.retina = originalRetina;

View File

@ -88,7 +88,7 @@ describe('Canvas', () => {
const spyMap = sinon.spy();
map.on('mousemove', spyMap);
UIEventSimulator.fireAt('mousemove', 151, 151); // empty space
expect(spyMap.calledOnce).to.be.ok();
expect(spyMap.calledOnce).to.be.true;
});
it('should fire preclick before click', () => {
@ -97,7 +97,7 @@ describe('Canvas', () => {
layer.on('click', clickSpy);
layer.on('preclick', preclickSpy);
layer.once('preclick', () => {
expect(clickSpy.called).to.be(false);
expect(clickSpy.called).to.be.false;
});
UIEventSimulator.fireAt('click', 50, 50); // Click on the layer.
expect(clickSpy.callCount).to.eql(1);
@ -120,9 +120,9 @@ describe('Canvas', () => {
// Prosthetic does not fire a click when we down+up, but it real world
// browsers would, so let's simulate it.
UIEventSimulator.fireAt('click', 70, 60);
expect(downSpy.called).to.be(true);
expect(clickSpy.called).to.be(false);
expect(preclickSpy.called).to.be(false);
expect(downSpy.called).to.be.true;
expect(clickSpy.called).to.be.false;
expect(preclickSpy.called).to.be.false;
done();
}
});

View File

@ -17,7 +17,7 @@
it('takes that radius', () => {
const marker = L.circleMarker([0, 0], {radius: 20}).addTo(map);
expect(marker._radius).to.be(20);
expect(marker._radius).to.equal(20);
});
});
@ -26,7 +26,7 @@
const marker = L.circleMarker([0, 0], {radius: 20});
marker.setRadius(15);
marker.addTo(map);
expect(marker._radius).to.be(15);
expect(marker._radius).to.equal(15);
});
});
@ -35,7 +35,7 @@
const marker = L.circleMarker([0, 0], {radius: 20});
marker.addTo(map);
marker.setRadius(15);
expect(marker._radius).to.be(15);
expect(marker._radius).to.equal(15);
});
});
@ -44,7 +44,7 @@
const marker = L.circleMarker([0, 0], {radius: 20});
marker.addTo(map);
marker.setStyle({radius: 15});
expect(marker._radius).to.be(15);
expect(marker._radius).to.equal(15);
});
});
@ -53,7 +53,7 @@
const marker = L.circleMarker([0, 0], {radius: 20});
marker.setStyle({radius: 15});
marker.addTo(map);
expect(marker._radius).to.be(15);
expect(marker._radius).to.equal(15);
});
});
});
@ -74,10 +74,10 @@
marker.setLatLng(afterLatLng);
expect(eventArgs).to.not.be(null);
expect(eventArgs.oldLatLng).to.be(beforeLatLng);
expect(eventArgs.latlng).to.be(afterLatLng);
expect(marker.getLatLng()).to.be(afterLatLng);
expect(eventArgs).to.not.equal(null);
expect(eventArgs.oldLatLng).to.equal(beforeLatLng);
expect(eventArgs.latlng).to.equal(afterLatLng);
expect(marker.getLatLng()).to.equal(afterLatLng);
});
});
@ -89,8 +89,8 @@
circlemarker.addTo(map);
expect(circlemarker._containsPoint(point1)).to.be(true);
expect(circlemarker._containsPoint(point2)).to.be(false);
expect(circlemarker._containsPoint(point1)).to.be.true;
expect(circlemarker._containsPoint(point2)).to.be.false;
});
});
});

View File

@ -21,7 +21,7 @@ describe('Circle', () => {
it('throws error if radius is NaN', () => {
expect(() => {
L.circle([0, 0], NaN);
}).to.throwException('Circle radius cannot be NaN');
}).to.throw('Circle radius cannot be NaN');
});
});

View File

@ -51,7 +51,7 @@ describe('Path', () => {
const layer = L.polygon([[1, 2], [3, 4], [5, 6]]).addTo(map);
layer.on('click', spy);
UIEventSimulator.fire('click', layer._path);
expect(spy.called).to.be.ok();
expect(spy.called).to.be.true;
});
it('propagates click event by default', () => {
@ -63,9 +63,9 @@ describe('Path', () => {
layer.on('click', spy2);
map.on('click', mapSpy);
UIEventSimulator.fire('click', layer._path);
expect(spy.called).to.be.ok();
expect(spy2.called).to.be.ok();
expect(mapSpy.called).to.be.ok();
expect(spy.called).to.be.true;
expect(spy2.called).to.be.true;
expect(mapSpy.called).to.be.true;
});
it('can add a layer while being inside a moveend handler', () => {
@ -83,10 +83,10 @@ describe('Path', () => {
map.setView([1, 2], 12, {animate: false});
map.panBy([-260, 0], {animate: false});
expect(polygon._parts.length).to.be(0);
expect(polygon._parts.length).to.equal(0);
map.panBy([260, 0], {animate: false});
expect(polygon._parts.length).to.be(1);
expect(polygon._parts.length).to.equal(1);
});
it('it should return tolerance with stroke', () => {

View File

@ -16,7 +16,7 @@ describe('Polygon', () => {
const polygon = L.polygon(latLngs);
expect(L.LineUtil.isFlat(polygon._latlngs)).to.be(false);
expect(L.LineUtil.isFlat(polygon._latlngs)).to.be.false;
expect(polygon.getLatLngs()).to.eql(polygon._latlngs);
});
@ -72,7 +72,7 @@ describe('Polygon', () => {
it('can be added to the map when empty', () => {
const polygon = L.polygon([]).addTo(map);
const isAdded = map.hasLayer(polygon);
expect(isAdded).to.be(true);
expect(isAdded).to.be.true;
});
});
@ -81,13 +81,13 @@ describe('Polygon', () => {
it('should return true for a polygon with no latlngs', () => {
const layer = L.polygon([]);
expect(layer.isEmpty()).to.be(true);
expect(layer.isEmpty()).to.be.true;
});
it('should return false for simple polygon', () => {
const latLngs = [[1, 2], [3, 4], [5, 6]];
const layer = L.polygon(latLngs);
expect(layer.isEmpty()).to.be(false);
expect(layer.isEmpty()).to.be.false;
});
it('should return false for a multi-polygon', () => {
@ -96,7 +96,7 @@ describe('Polygon', () => {
[[[0, 10], [10, 10], [10, 0]], [[2, 3], [2, 4], [3, 4]]]
];
const layer = L.polygon(latLngs);
expect(layer.isEmpty()).to.be(false);
expect(layer.isEmpty()).to.be.false;
});
});
@ -173,7 +173,7 @@ describe('Polygon', () => {
];
const layer = L.polygon(latlngs);
layer.getCenter();
}).to.throwException('Must add layer to map before using getCenter()');
}).to.throw('Must add layer to map before using getCenter()');
});
it('should compute same center for low and high zoom', () => {
@ -356,7 +356,7 @@ describe('Polygon', () => {
polygon.setStyle(style);
for (const [prop, expectedValue] of Object.entries(style)) {
expect(polygon.options[prop]).to.be(expectedValue);
expect(polygon.options[prop]).to.equal(expectedValue);
}
});
});

View File

@ -47,7 +47,7 @@ describe('Polyline', () => {
it('can be added to the map when empty', () => {
const polyline = L.polyline([]).addTo(map);
expect(map.hasLayer(polyline)).to.be(true);
expect(map.hasLayer(polyline)).to.be.true;
});
});
@ -55,13 +55,13 @@ describe('Polyline', () => {
describe('#isEmpty', () => {
it('should return true for a polyline with no latlngs', () => {
const polyline = L.polyline([]);
expect(polyline.isEmpty()).to.be(true);
expect(polyline.isEmpty()).to.be.true;
});
it('should return false for simple polyline', () => {
const latLngs = [[1, 2], [3, 4]];
const polyline = L.polyline(latLngs);
expect(polyline.isEmpty()).to.be(false);
expect(polyline.isEmpty()).to.be.false;
});
it('should return false for multi-polyline', () => {
@ -70,7 +70,7 @@ describe('Polyline', () => {
[[11, 12], [13, 14]]
];
const polyline = L.polyline(latLngs);
expect(polyline.isEmpty()).to.be(false);
expect(polyline.isEmpty()).to.be.false;
});
});
@ -146,7 +146,7 @@ describe('Polyline', () => {
expect(() => {
const polyline = L.polyline([[0, 0], [0, 0.090]]);
polyline.getCenter();
}).to.throwException('Must add layer to map before using getCenter()');
}).to.throw('Must add layer to map before using getCenter()');
});
it('should compute same center for low and high zoom', () => {
@ -248,7 +248,7 @@ describe('Polyline', () => {
polyline.setStyle(style);
for (const [prop, expectedValue] of Object.entries(style)) {
expect(polyline.options[prop]).to.be(expectedValue);
expect(polyline.options[prop]).to.equal(expectedValue);
}
});
});
@ -264,7 +264,7 @@ describe('Polyline', () => {
polyline.setStyle(style);
for (const [prop, expectedValue] of Object.entries(style)) {
expect(polyline.options[prop]).to.be(expectedValue);
expect(polyline.options[prop]).to.equal(expectedValue);
}
});
});
@ -280,13 +280,13 @@ describe('Polyline', () => {
});
map.addLayer(polyline);
expect(polyline.closestLayerPoint(p1)).to.be(null);
expect(polyline.closestLayerPoint(p1)).to.equal(null);
polyline.setLatLngs(latlngs);
const point = polyline.closestLayerPoint(p1);
expect(point).not.to.be(null);
expect(point.distance).to.not.be(Infinity);
expect(point.distance).to.not.be(NaN);
expect(point).not.to.equal(null);
expect(point.distance).to.not.equal(Infinity);
expect(point.distance).to.not.equal(NaN);
const point2 = polyline.closestLayerPoint(p2);

View File

@ -16,7 +16,7 @@ describe('Rectangle', () => {
const rectangle = L.rectangle(latLngs);
expect(L.LineUtil.isFlat(rectangle._latlngs)).to.be(false);
expect(L.LineUtil.isFlat(rectangle._latlngs)).to.be.false;
expect(rectangle.getLatLngs()).to.eql(rectangle._latlngs);
});
@ -37,7 +37,7 @@ describe('Rectangle', () => {
// Throws error due to undefined lat
expect(() => {
L.rectangle([]);
}).to.throwException();
}).to.throw();
});
it('can be initialized with extending bounds', () => {
@ -119,7 +119,7 @@ describe('Rectangle', () => {
map.setView([0, 0], 6);
expect(() => {
L.polygon([[[2, 3], [4, 5]]]).addTo(map).bindTooltip('test');
}).to.not.throwException();
}).to.not.throw();
});
});
});

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@ describe('Map.BoxZoom', () => {
// check if click event on the map is fired
UIEventSimulator.fire('click', map._container);
expect(mapClick).to.be(true);
expect(mapClick).to.be.true;
let clientX = 100;
let clientY = 100;
@ -52,7 +52,7 @@ describe('Map.BoxZoom', () => {
// check if click event on the map is fired
mapClick = false;
UIEventSimulator.fire('click', map._container);
expect(mapClick).to.be(true);
expect(mapClick).to.be.true;
});
});

View File

@ -16,9 +16,9 @@ describe('Map.Drag', () => {
dragging: true
});
expect(map.dragging.enabled()).to.be(true);
expect(map.dragging.enabled()).to.be.true;
map.setView([0, 0], 0);
expect(map.dragging.enabled()).to.be(true);
expect(map.dragging.enabled()).to.be.true;
});
it('calls the map with dragging and worldCopyJump enabled', () => {
@ -27,9 +27,9 @@ describe('Map.Drag', () => {
worldCopyJump: true
});
expect(map.dragging.enabled()).to.be(true);
expect(map.dragging.enabled()).to.be.true;
map.setView([0, 0], 0);
expect(map.dragging.enabled()).to.be(true);
expect(map.dragging.enabled()).to.be.true;
});
it('calls the map with dragging disabled and worldCopyJump enabled; ' +
@ -39,10 +39,10 @@ describe('Map.Drag', () => {
worldCopyJump: true
});
expect(map.dragging.enabled()).to.be(false);
expect(map.dragging.enabled()).to.be.false;
map.setView([0, 0], 0);
map.dragging.enable();
expect(map.dragging.enabled()).to.be(true);
expect(map.dragging.enabled()).to.be.true;
});
});
@ -74,7 +74,7 @@ describe('Map.Drag', () => {
onStop() {
expect(map.getOffset()).to.eql(offset);
expect(map.getZoom()).to.be(1);
expect(map.getZoom()).to.equal(1);
expect(map.getCenter()).to.be.nearLatLng([21.943045533, -180]);
done();
@ -110,7 +110,7 @@ describe('Map.Drag', () => {
onStop() {
expect(map.getOffset()).to.eql(offset);
expect(map.getZoom()).to.be(1);
expect(map.getZoom()).to.equal(1);
expect(map.getCenter()).to.be.nearLatLng([21.943045533, -180]);
done();
@ -140,7 +140,7 @@ describe('Map.Drag', () => {
const hand = new Hand({
timing: 'fastframe',
onStop() {
expect(map.getZoom()).to.be(1);
expect(map.getZoom()).to.equal(1);
// Expect center point to be the same as before the click
expect(map.getCenter()).to.eql(originalCenter);
expect(spy.callCount).to.eql(0); // No drag event should have been fired.
@ -175,9 +175,9 @@ describe('Map.Drag', () => {
// A real user scenario would trigger a click on mouseup.
// We want to be sure we are cancelling it after a drag.
UIEventSimulator.fire('click', container);
expect(dragSpy.called).to.be(true);
expect(clickSpy.called).to.be(false);
expect(preclickSpy.called).to.be(false);
expect(dragSpy.called).to.be.true;
expect(clickSpy.called).to.be.false;
expect(preclickSpy.called).to.be.false;
done();
}
});
@ -212,10 +212,10 @@ describe('Map.Drag', () => {
// A real user scenario would trigger a click on mouseup.
// We want to be sure we are cancelling it after a drag.
UIEventSimulator.fire('click', container);
expect(mapDragSpy.called).to.be(true);
expect(markerDragSpy.called).to.be(false);
expect(clickSpy.called).to.be(false);
expect(preclickSpy.called).to.be(false);
expect(mapDragSpy.called).to.be.true;
expect(markerDragSpy.called).to.be.false;
expect(clickSpy.called).to.be.false;
expect(preclickSpy.called).to.be.false;
done();
}
});
@ -252,10 +252,10 @@ describe('Map.Drag', () => {
// A real user scenario would trigger a click on mouseup.
// We want to be sure we are cancelling it after a drag.
UIEventSimulator.fire('click', marker._icon);
expect(markerDragSpy.called).to.be(true);
expect(mapDragSpy.called).to.be(false);
expect(clickSpy.called).to.be(false);
expect(preclickSpy.called).to.be(false);
expect(markerDragSpy.called).to.be.true;
expect(mapDragSpy.called).to.be.false;
expect(clickSpy.called).to.be.false;
expect(preclickSpy.called).to.be.false;
done();
}
});
@ -284,7 +284,7 @@ describe('Map.Drag', () => {
const hand = new Hand({
timing: 'fastframe',
onStop() {
expect(map.getZoom()).to.be(1);
expect(map.getZoom()).to.equal(1);
// Expect center point to be the same as before the click
expect(map.getCenter()).to.eql(originalCenter);
expect(spy.callCount).to.eql(0); // No drag event should have been fired.
@ -318,7 +318,7 @@ describe('Map.Drag', () => {
onStop() {
expect(map.getOffset()).to.eql(offset);
expect(map.getZoom()).to.be(1);
expect(map.getZoom()).to.equal(1);
expect(map.getCenter()).to.be.nearLatLng([21.943045533, -180]);
done();
@ -345,9 +345,9 @@ describe('Map.Drag', () => {
const hand = new Hand({
timing: 'fastframe',
onStop() {
expect(map.getZoom()).to.be(1);
expect(map.getZoom()).to.equal(1);
// Expect center point to be the same as before the click
expect(map.getCenter().equals(originalCenter)).to.be.ok(); // small margin of error allowed
expect(map.getCenter().equals(originalCenter)).to.be.true; // small margin of error allowed
expect(spy.callCount).to.eql(0); // No drag event should have been fired.
done();

View File

@ -125,12 +125,12 @@ describe('Map.Keyboard', () => {
const popup = L.popup().setLatLng([0, 0]).setContent('Null Island');
map.openPopup(popup);
expect(popup.isOpen()).to.be(true);
expect(popup.isOpen()).to.be.true;
UIEventSimulator.fire('keydown', document, {code: KEYCODE_ESC});
UIEventSimulator.fire('keyup', document, {code: KEYCODE_ESC});
expect(popup.isOpen()).to.be(false);
expect(popup.isOpen()).to.be.false;
});
});
@ -140,12 +140,12 @@ describe('Map.Keyboard', () => {
const popup = L.popup({closeOnEscapeKey: false}).setLatLng([0, 0]).setContent('Null Island');
map.openPopup(popup);
expect(popup.isOpen()).to.be(true);
expect(popup.isOpen()).to.be.true;
UIEventSimulator.fire('keydown', document, {code: KEYCODE_ESC});
UIEventSimulator.fire('keyup', document, {code: KEYCODE_ESC});
expect(popup.isOpen()).to.be(true);
expect(popup.isOpen()).to.be.true;
});
});
@ -159,9 +159,9 @@ describe('Map.Keyboard', () => {
UIEventSimulator.fire('keypress', container, {code: KEYCODE_LOWERCASE_A});
setTimeout(() => {
expect(keyDownSpy.called).to.be(false);
expect(keyPressSpy.called).to.be.ok();
expect(keyUpSpy.called).to.be(false);
expect(keyDownSpy.called).to.be.false;
expect(keyPressSpy.called).to.be.true;
expect(keyUpSpy.called).to.be.false;
done();
}, 50);
});
@ -175,9 +175,9 @@ describe('Map.Keyboard', () => {
UIEventSimulator.fire('keydown', container, {code: KEYCODE_LOWERCASE_A});
setTimeout(() => {
expect(keyDownSpy.called).to.be.ok();
expect(keyPressSpy.called).to.be(false);
expect(keyUpSpy.called).to.be(false);
expect(keyDownSpy.called).to.be.true;
expect(keyPressSpy.called).to.be.false;
expect(keyUpSpy.called).to.be.false;
done();
}, 50);
});
@ -191,9 +191,9 @@ describe('Map.Keyboard', () => {
UIEventSimulator.fire('keyup', container, {code: KEYCODE_LOWERCASE_A});
setTimeout(() => {
expect(keyDownSpy.called).to.be(false);
expect(keyPressSpy.called).to.be(false);
expect(keyUpSpy.called).to.be.ok();
expect(keyDownSpy.called).to.be.false;
expect(keyPressSpy.called).to.be.false;
expect(keyUpSpy.called).to.be.true;
done();
}, 50);
});

View File

@ -74,11 +74,11 @@ describe('Map.ScrollWheelZoom', () => {
setTimeout(() => {
UIEventSimulator.fire(wheel, container, scrollIn);
expect(spy.notCalled).to.be.ok();
expect(spy.notCalled).to.be.true;
}, 50);
map.on('zoomend', () => {
expect(spy.calledOnce).to.be.ok();
expect(spy.calledOnce).to.be.true;
// Bug 1.8.0: Firefox wheel zoom makes 2 steps #7403
// expect(map.getCenter()).to.be.nearLatLng([25.48295117535531, -26.367187500000004]);
expect(map.getZoom()).to.be.greaterThan(zoom);
@ -99,7 +99,7 @@ describe('Map.ScrollWheelZoom', () => {
const zoomDiff = map.getZoom() - zoom;
map.setZoom(zoom, {animate: false});
expect(map.getZoom()).to.be(zoom);
expect(map.getZoom()).to.equal(zoom);
map.options.wheelPxPerZoomLevel = 30 / L.DomEvent.getWheelPxFactor();
UIEventSimulator.fire(wheel, container, scrollIn);

View File

@ -38,16 +38,16 @@ describe('Map.TapHoldSpec.js', () => {
UIEventSimulator.fire('pointerdown', container, {pointerId:0, ...posStart});
clock.tick(550);
expect(spy.notCalled).to.be.ok();
expect(spy.notCalled).to.be.true;
clock.tick(100);
expect(spy.called).to.be.ok();
expect(spy.calledOnce).to.be.ok();
expect(spy.called).to.be.true;
expect(spy.calledOnce).to.be.true;
const event = spy.lastCall.args[0];
expect(event.type).to.be('contextmenu');
expect(event.originalEvent._simulated).to.be.ok();
expect(event.type).to.equal('contextmenu');
expect(event.originalEvent._simulated).to.be.true;
});
it('does not fire contextmenu when touches > 1', () => {
@ -59,7 +59,7 @@ describe('Map.TapHoldSpec.js', () => {
UIEventSimulator.fire('pointerdown', container, {pointerId:1, ...posNear});
clock.tick(550);
expect(spy.notCalled).to.be.ok();
expect(spy.notCalled).to.be.true;
});
it('does not fire contextmenu when touches > 1 (case:2)', () => {
@ -74,14 +74,14 @@ describe('Map.TapHoldSpec.js', () => {
UIEventSimulator.fire('pointerup', container, {pointerId:0, ...posNear});
clock.tick(450);
expect(spy.notCalled).to.be.ok();
expect(spy.notCalled).to.be.true;
});
(L.Browser.pointer ? it : it.skip)('ignores events from mouse', () => {
UIEventSimulator.fire('pointerdown', container, {pointerId:0, pointerType:'mouse', ...posStart});
clock.tick(650);
expect(spy.notCalled).to.be.ok();
expect(spy.notCalled).to.be.true;
});
it('does not conflict with native contextmenu', () => {
@ -94,9 +94,9 @@ describe('Map.TapHoldSpec.js', () => {
clock.tick(100);
expect(spy.called).to.be.ok();
expect(spy.calledOnce).to.be.ok();
expect(spy.lastCall.args[0].originalEvent._simulated).not.to.be.ok();
expect(spy.called).to.be.true;
expect(spy.calledOnce).to.be.true;
expect(spy.lastCall.args[0].originalEvent._simulated).not.to.be.true;
// Note: depending on tapHoldDelay value it's also possible that native contextmenu may come after simulated one
// and the only way to handle this gracefully - increase tapHoldDelay value.
@ -115,7 +115,7 @@ describe('Map.TapHoldSpec.js', () => {
UIEventSimulator.fire('touchend', container, {touches: [posStart]});
UIEventSimulator.fire('pointerup', container, {pointerId:0, ...posNear});
expect(clickSpy.notCalled).to.be.ok();
expect(clickSpy.notCalled).to.be.true;
});
it('allows short movements', () => {
@ -128,7 +128,7 @@ describe('Map.TapHoldSpec.js', () => {
clock.tick(100);
expect(spy.called).to.be.ok();
expect(spy.called).to.be.true;
});
it('ignores long movements', () => {
@ -144,7 +144,7 @@ describe('Map.TapHoldSpec.js', () => {
clock.tick(100);
expect(spy.notCalled).to.be.ok();
expect(spy.notCalled).to.be.true;
});
it('.originalEvent has expected properties', () => {
@ -165,7 +165,7 @@ describe('Map.TapHoldSpec.js', () => {
target: container
}, posStart);
for (const [prop, expectedValue] of Object.entries(expectedProps)) {
expect(originalEvent[prop]).to.be(expectedValue);
expect(originalEvent[prop]).to.equal(expectedValue);
}
});
});

View File

@ -18,9 +18,9 @@ describe('Map.TouchZoom', () => {
it.skipIfNotTouch('Increases zoom when pinching out', (done) => {
map.setView([0, 0], 1);
map.once('zoomend', () => {
expect(map.getCenter()).to.eql({lat:0, lng:0});
expect(map.getCenter().equals(L.latLng({lat:0, lng:0}))).to.be.true;
// Initial zoom 1, initial distance 50px, final distance 450px
expect(map.getZoom()).to.be(4);
expect(map.getZoom()).to.equal(4);
done();
});
@ -39,9 +39,9 @@ describe('Map.TouchZoom', () => {
it.skipIfNotTouch('Decreases zoom when pinching in', (done) => {
map.setView([0, 0], 4);
map.once('zoomend', () => {
expect(map.getCenter()).to.eql({lat:0, lng:0});
expect(map.getCenter().equals(L.latLng({lat:0, lng:0}))).to.be.true;
// Initial zoom 4, initial distance 450px, final distance 50px
expect(map.getZoom()).to.be(1);
expect(map.getZoom()).to.equal(1);
done();
});
@ -68,12 +68,12 @@ describe('Map.TouchZoom', () => {
pinchZoomEvent = e.pinch || pinchZoomEvent;
});
map.once('zoomend', () => {
expect(spy.callCount > 1).to.be.ok();
expect(pinchZoomEvent).to.be.ok();
expect(spy.callCount > 1).to.be.true;
expect(pinchZoomEvent).to.be.true;
expect(map.getCenter()).to.eql({lat:0, lng:0});
expect(map.getCenter().equals(L.latLng({lat:0, lng:0}))).to.be.true;
// Initial zoom 4, initial distance 450px, final distance 50px
expect(map.getZoom()).to.be(1);
expect(map.getZoom()).to.equal(1);
done();
});
@ -104,8 +104,8 @@ describe('Map.TouchZoom', () => {
const hand = new Hand({
timing: 'fastframe',
onStop() {
expect(map.getCenter().lat).to.be(0);
expect(map.getCenter().lng > 5).to.be(true);
expect(map.getCenter().lat).to.equal(0);
expect(map.getCenter().lng > 5).to.be.true;
done();
}
});
@ -139,9 +139,9 @@ describe('Map.TouchZoom', () => {
map.setView([0, 0], 4);
map.once('zoomend', () => {
expect(map.getCenter()).to.eql({lat:0, lng:0});
expect(map.getCenter().equals(L.latLng({lat:0, lng:0}))).to.be.true;
// Initial zoom 4, initial distance 450px, final distance 50px
expect(map.getZoom()).to.be(1);
expect(map.getZoom()).to.equal(1);
done();
});
@ -190,9 +190,9 @@ describe('Map.TouchZoom', () => {
const width = renderedRect.width;
const height = renderedRect.height;
expect(height < 50).to.be(true);
expect(width < 50).to.be(true);
expect(height + width > 0).to.be(true);
expect(height < 50).to.be.true;
expect(width < 50).to.be.true;
expect(height + width > 0).to.be.true;
const x = renderedRect.x;
const y = renderedRect.y;
@ -252,9 +252,9 @@ describe('Map.TouchZoom', () => {
const width = renderedRect.width;
const height = renderedRect.height;
expect(height < 50).to.be(true);
expect(width < 50).to.be(true);
expect(height + width > 0).to.be(true);
expect(height < 50).to.be.true;
expect(width < 50).to.be.true;
expect(height + width > 0).to.be.true;
const x = renderedRect.x;
const y = renderedRect.y;

View File

@ -792,7 +792,7 @@ export const Map = Evented.extend({
}
this._layers = [];
this._panes = [];
this._panes = {};
delete this._mapPane;
delete this._renderer;