Port tests to vitest

This commit is contained in:
Pieter Vander Vennet 2023-02-03 04:48:32 +01:00
parent 64a4d7e929
commit 228ceb120d
33 changed files with 673 additions and 326 deletions

436
package-lock.json generated
View file

@ -27,6 +27,7 @@
"geojson2svg": "^1.3.1",
"i18next-client": "^1.11.4",
"idb-keyval": "^6.0.3",
"jest-mock": "^29.4.1",
"jspdf": "^2.5.1",
"latlon2country": "^1.2.6",
"leaflet": "^1.9.2",
@ -64,7 +65,6 @@
"@types/leaflet-markercluster": "^1.0.3",
"@types/leaflet-providers": "^1.2.0",
"@types/lz-string": "^1.3.34",
"@types/mocha": "^9.1.0",
"@types/node": "^18.11.18",
"@types/papaparse": "^5.3.1",
"@types/prompt-sync": "^4.1.0",
@ -74,7 +74,6 @@
"chai": "^4.3.6",
"dependency-cruiser": "^10.4.0",
"fs": "0.0.1-security",
"mocha": "^9.2.2",
"prettier": "^2.7.1",
"prettier-plugin-svelte": "^2.9.0",
"read-file": "^0.2.0",
@ -1622,6 +1621,97 @@
"node": ">=12"
}
},
"node_modules/@jest/schemas": {
"version": "29.4.0",
"resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.0.tgz",
"integrity": "sha512-0E01f/gOZeNTG76i5eWWSupvSHaIINrTie7vCyjiYFKgzNdyEGd12BUv4oNBFHOqlHDbtoJi3HrQ38KCC90NsQ==",
"dependencies": {
"@sinclair/typebox": "^0.25.16"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
"node_modules/@jest/types": {
"version": "29.4.1",
"resolved": "https://registry.npmjs.org/@jest/types/-/types-29.4.1.tgz",
"integrity": "sha512-zbrAXDUOnpJ+FMST2rV7QZOgec8rskg2zv8g2ajeqitp4tvZiyqTCYXANrKsM+ryj5o+LI+ZN2EgU9drrkiwSA==",
"dependencies": {
"@jest/schemas": "^29.4.0",
"@types/istanbul-lib-coverage": "^2.0.0",
"@types/istanbul-reports": "^3.0.0",
"@types/node": "*",
"@types/yargs": "^17.0.8",
"chalk": "^4.0.0"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
"node_modules/@jest/types/node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/@jest/types/node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/@jest/types/node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/@jest/types/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/@jest/types/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"engines": {
"node": ">=8"
}
},
"node_modules/@jest/types/node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/@jridgewell/gen-mapping": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz",
@ -1831,6 +1921,11 @@
}
}
},
"node_modules/@sinclair/typebox": {
"version": "0.25.21",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.21.tgz",
"integrity": "sha512-gFukHN4t8K4+wVC+ECqeqwzBDeFeTzBXroBTqE6vcWrQGbEUpHO7LYdG0f4xnvYq4VOEwITSlHlp0JBAIFMS/g=="
},
"node_modules/@sveltejs/vite-plugin-svelte": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.0.2.tgz",
@ -3470,6 +3565,27 @@
"integrity": "sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==",
"devOptional": true
},
"node_modules/@types/istanbul-lib-coverage": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz",
"integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g=="
},
"node_modules/@types/istanbul-lib-report": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz",
"integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==",
"dependencies": {
"@types/istanbul-lib-coverage": "*"
}
},
"node_modules/@types/istanbul-reports": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz",
"integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==",
"dependencies": {
"@types/istanbul-lib-report": "*"
}
},
"node_modules/@types/json-schema": {
"version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
@ -3516,12 +3632,6 @@
"integrity": "sha512-j6G1e8DULJx3ONf6NdR5JiR2ZY3K3PaaqiEuKYkLQO0Czfi1AzrtjfnfCROyWGeDd5IVMKCwsgSmMip9OWijow==",
"dev": true
},
"node_modules/@types/mocha": {
"version": "9.1.1",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.1.tgz",
"integrity": "sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw==",
"dev": true
},
"node_modules/@types/node": {
"version": "18.11.18",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
@ -3587,6 +3697,19 @@
"@types/node": "*"
}
},
"node_modules/@types/yargs": {
"version": "17.0.22",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.22.tgz",
"integrity": "sha512-pet5WJ9U8yPVRhkwuEIp5ktAeAqRZOq4UdAyWLWzxbtpyXnzbtLdKiXAjJzi/KLmPGS9wk86lUFWZFN6sISo4g==",
"dependencies": {
"@types/yargs-parser": "*"
}
},
"node_modules/@types/yargs-parser": {
"version": "21.0.0",
"resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz",
"integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA=="
},
"node_modules/@ungap/promise-all-settled": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz",
@ -4411,6 +4534,20 @@
"integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==",
"dev": true
},
"node_modules/ci-info": {
"version": "3.7.1",
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.7.1.tgz",
"integrity": "sha512-4jYS4MOAaCIStSRwiuxc4B8MYhIe676yO1sYGzARnjXkWpmzZMMYxY6zu8WYWDhSuth5zhrQ1rhNSibyyvv4/w==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/sibiraj-s"
}
],
"engines": {
"node": ">=8"
}
},
"node_modules/cli-cursor": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz",
@ -5774,8 +5911,7 @@
"node_modules/graceful-fs": {
"version": "4.2.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==",
"dev": true
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA=="
},
"node_modules/growl": {
"version": "1.10.5",
@ -6419,6 +6555,99 @@
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g=="
},
"node_modules/jest-mock": {
"version": "29.4.1",
"resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.4.1.tgz",
"integrity": "sha512-MwA4hQ7zBOcgVCVnsM8TzaFLVUD/pFWTfbkY953Y81L5ret3GFRZtmPmRFAjKQSdCKoJvvqOu6Bvfpqlwwb0dQ==",
"dependencies": {
"@jest/types": "^29.4.1",
"@types/node": "*",
"jest-util": "^29.4.1"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
"node_modules/jest-util": {
"version": "29.4.1",
"resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.4.1.tgz",
"integrity": "sha512-bQy9FPGxVutgpN4VRc0hk6w7Hx/m6L53QxpDreTZgJd9gfx/AV2MjyPde9tGyZRINAUrSv57p2inGBu2dRLmkQ==",
"dependencies": {
"@jest/types": "^29.4.1",
"@types/node": "*",
"chalk": "^4.0.0",
"ci-info": "^3.2.0",
"graceful-fs": "^4.2.9",
"picomatch": "^2.2.3"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
"node_modules/jest-util/node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/jest-util/node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/jest-util/node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/jest-util/node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/jest-util/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"engines": {
"node": ">=8"
}
},
"node_modules/jest-util/node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/jose": {
"version": "4.11.2",
"resolved": "https://registry.npmjs.org/jose/-/jose-4.11.2.tgz",
@ -12245,6 +12474,72 @@
"integrity": "sha512-mdPjPxfnmoqhgpiEArqi4egmBAMYvaObgn4poorpUaqmvzzbvqbowRllQ+ZgzGVMGKaPkqUmPDOOFQRUFDmeUw==",
"optional": true
},
"@jest/schemas": {
"version": "29.4.0",
"resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.4.0.tgz",
"integrity": "sha512-0E01f/gOZeNTG76i5eWWSupvSHaIINrTie7vCyjiYFKgzNdyEGd12BUv4oNBFHOqlHDbtoJi3HrQ38KCC90NsQ==",
"requires": {
"@sinclair/typebox": "^0.25.16"
}
},
"@jest/types": {
"version": "29.4.1",
"resolved": "https://registry.npmjs.org/@jest/types/-/types-29.4.1.tgz",
"integrity": "sha512-zbrAXDUOnpJ+FMST2rV7QZOgec8rskg2zv8g2ajeqitp4tvZiyqTCYXANrKsM+ryj5o+LI+ZN2EgU9drrkiwSA==",
"requires": {
"@jest/schemas": "^29.4.0",
"@types/istanbul-lib-coverage": "^2.0.0",
"@types/istanbul-reports": "^3.0.0",
"@types/node": "*",
"@types/yargs": "^17.0.8",
"chalk": "^4.0.0"
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"requires": {
"color-convert": "^2.0.1"
}
},
"chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"requires": {
"has-flag": "^4.0.0"
}
}
}
},
"@jridgewell/gen-mapping": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz",
@ -12380,6 +12675,11 @@
"picomatch": "^2.3.1"
}
},
"@sinclair/typebox": {
"version": "0.25.21",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.25.21.tgz",
"integrity": "sha512-gFukHN4t8K4+wVC+ECqeqwzBDeFeTzBXroBTqE6vcWrQGbEUpHO7LYdG0f4xnvYq4VOEwITSlHlp0JBAIFMS/g=="
},
"@sveltejs/vite-plugin-svelte": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.0.2.tgz",
@ -13691,6 +13991,27 @@
"integrity": "sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==",
"devOptional": true
},
"@types/istanbul-lib-coverage": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz",
"integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g=="
},
"@types/istanbul-lib-report": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz",
"integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==",
"requires": {
"@types/istanbul-lib-coverage": "*"
}
},
"@types/istanbul-reports": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz",
"integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==",
"requires": {
"@types/istanbul-lib-report": "*"
}
},
"@types/json-schema": {
"version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
@ -13736,12 +14057,6 @@
"integrity": "sha512-j6G1e8DULJx3ONf6NdR5JiR2ZY3K3PaaqiEuKYkLQO0Czfi1AzrtjfnfCROyWGeDd5IVMKCwsgSmMip9OWijow==",
"dev": true
},
"@types/mocha": {
"version": "9.1.1",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.1.tgz",
"integrity": "sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw==",
"dev": true
},
"@types/node": {
"version": "18.11.18",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
@ -13806,6 +14121,19 @@
"@types/node": "*"
}
},
"@types/yargs": {
"version": "17.0.22",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.22.tgz",
"integrity": "sha512-pet5WJ9U8yPVRhkwuEIp5ktAeAqRZOq4UdAyWLWzxbtpyXnzbtLdKiXAjJzi/KLmPGS9wk86lUFWZFN6sISo4g==",
"requires": {
"@types/yargs-parser": "*"
}
},
"@types/yargs-parser": {
"version": "21.0.0",
"resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz",
"integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA=="
},
"@ungap/promise-all-settled": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz",
@ -14415,6 +14743,11 @@
"integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==",
"dev": true
},
"ci-info": {
"version": "3.7.1",
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.7.1.tgz",
"integrity": "sha512-4jYS4MOAaCIStSRwiuxc4B8MYhIe676yO1sYGzARnjXkWpmzZMMYxY6zu8WYWDhSuth5zhrQ1rhNSibyyvv4/w=="
},
"cli-cursor": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz",
@ -15472,8 +15805,7 @@
"graceful-fs": {
"version": "4.2.10",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz",
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==",
"dev": true
"integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA=="
},
"growl": {
"version": "1.10.5",
@ -15933,6 +16265,74 @@
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
"integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g=="
},
"jest-mock": {
"version": "29.4.1",
"resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.4.1.tgz",
"integrity": "sha512-MwA4hQ7zBOcgVCVnsM8TzaFLVUD/pFWTfbkY953Y81L5ret3GFRZtmPmRFAjKQSdCKoJvvqOu6Bvfpqlwwb0dQ==",
"requires": {
"@jest/types": "^29.4.1",
"@types/node": "*",
"jest-util": "^29.4.1"
}
},
"jest-util": {
"version": "29.4.1",
"resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.4.1.tgz",
"integrity": "sha512-bQy9FPGxVutgpN4VRc0hk6w7Hx/m6L53QxpDreTZgJd9gfx/AV2MjyPde9tGyZRINAUrSv57p2inGBu2dRLmkQ==",
"requires": {
"@jest/types": "^29.4.1",
"@types/node": "*",
"chalk": "^4.0.0",
"ci-info": "^3.2.0",
"graceful-fs": "^4.2.9",
"picomatch": "^2.2.3"
},
"dependencies": {
"ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"requires": {
"color-convert": "^2.0.1"
}
},
"chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
},
"supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"requires": {
"has-flag": "^4.0.0"
}
}
}
},
"jose": {
"version": "4.11.2",
"resolved": "https://registry.npmjs.org/jose/-/jose-4.11.2.tgz",

View file

@ -14,7 +14,7 @@
"watch:css": "tailwindcss -i index.css -o css/index-tailwind-output.css --watch",
"generate:css": "tailwindcss -i index.css -o css/index-tailwind-output.css",
"generate:doctests": "doctest-ts-improved . --ignore .*.spec.ts --ignore .*ConfigJson.ts",
"test:run-only": "mocha --require test/testhooks.ts \"./**/*.doctest.ts\" \"test/*\" \"test/**/*.ts\"",
"test:run-only": "vitest --require test/testhooks.ts \"./**/*.doctest.ts\" \"test/*\" \"test/**/*.ts\"",
"test": "(npm run generate:doctests 2>&1 | grep -v \"No doctests found in\") && npm run test:run-only && npm run clean:tests",
"init": "npm ci && npm run generate && npm run generate:editor-layer-index && npm run generate:layouts && npm run clean",
"generate:editor-layer-index": "vite-node scripts/downloadFile.ts -- https://osmlab.github.io/editor-layer-index/imagery.geojson assets/editor-layer-index.json",
@ -82,6 +82,7 @@
"geojson2svg": "^1.3.1",
"i18next-client": "^1.11.4",
"idb-keyval": "^6.0.3",
"jest-mock": "^29.4.1",
"jspdf": "^2.5.1",
"latlon2country": "^1.2.6",
"leaflet": "^1.9.2",
@ -119,7 +120,6 @@
"@types/leaflet-markercluster": "^1.0.3",
"@types/leaflet-providers": "^1.2.0",
"@types/lz-string": "^1.3.34",
"@types/mocha": "^9.1.0",
"@types/node": "^18.11.18",
"@types/papaparse": "^5.3.1",
"@types/prompt-sync": "^4.1.0",
@ -129,7 +129,6 @@
"chai": "^4.3.6",
"dependency-cruiser": "^10.4.0",
"fs": "0.0.1-security",
"mocha": "^9.2.2",
"prettier": "^2.7.1",
"prettier-plugin-svelte": "^2.9.0",
"read-file": "^0.2.0",

View file

@ -1,5 +1,5 @@
import { describe } from "mocha"
import { exec } from "child_process"
import { describe, it } from "vitest"
/**
*

View file

@ -1,4 +1,3 @@
import { expect } from "chai"
import { Utils } from "../../../Utils"
import UserRelatedState from "../../../Logic/State/UserRelatedState"
import LayoutConfig from "../../../Models/ThemeConfig/LayoutConfig"
@ -11,6 +10,7 @@ import SelectedFeatureHandler from "../../../Logic/Actors/SelectedFeatureHandler
import { ElementStorage } from "../../../Logic/ElementStorage"
import { OsmTags } from "../../../Models/OsmFeature"
import { Feature, Geometry } from "geojson"
import { describe, expect, it } from "vitest"
const latestTags = {
amenity: "public_bookcase",
@ -83,9 +83,9 @@ it("should download the latest version", () => {
SelectedElementTagsUpdater.applyUpdate(state, latestTags, feature.properties.id)
// The name should be updated
expect(feature.properties.name).deep.equal("Stubbekwartier-buurtbibliotheek")
expect(feature.properties.name).toEqual("Stubbekwartier-buurtbibliotheek")
// The fixme should be removed
expect(feature.properties.fixme).deep.equal(undefined)
expect(feature.properties.fixme).toBeUndefined()
})
it("Hash without selected element should download geojson from OSM-API", async () => {
const hash = new UIEventSource("node/5568693115")
@ -97,9 +97,9 @@ it("Hash without selected element should download geojson from OSM-API", async (
})
loc.addCallback((_) => {
expect(selected.data.properties.id).deep.equal("node/5568693115")
expect(loc.data.zoom).deep.equal(14)
expect(loc.data.lat).deep.equal(51.2179199)
expect(selected.data.properties.id).toEqual("node/5568693115")
expect(loc.data.zoom).toEqual(14)
expect(loc.data.lat).toEqual(51.2179199)
})
new SelectedFeatureHandler(hash, {

View file

@ -1,8 +1,7 @@
import { describe } from "mocha"
import { expect } from "chai"
import CreateMultiPolygonWithPointReuseAction from "../../../Logic/Osm/Actions/CreateMultiPolygonWithPointReuseAction"
import { Tag } from "../../../Logic/Tags/Tag"
import { Changes } from "../../../Logic/Osm/Changes"
import { describe, expect, it } from "vitest"
describe("CreateMultiPolygonWithPointReuseAction", () => {
it("should produce a correct changeset", () => {
@ -106,21 +105,29 @@ describe("CreateMultiPolygonWithPointReuseAction", () => {
const descriptions = await action.Perform(new Changes())
const ways = descriptions.filter((d) => d.type === "way")
expect(ways[0].id == -18, "unexpected id").true
expect(ways[1].id == -27, "unexpected id").true
// "unexpected id"
expect(ways[0].id == -18).toBe(true)
// "unexpected id"
expect(ways[1].id == -27).toBe(true)
const outer = ways[0].changes["coordinates"]
expect(outer).deep.equal(feature.geometry.coordinates[0])
expect(outer).toEqual(feature.geometry.coordinates[0])
const inner = ways[1].changes["coordinates"]
expect(inner).deep.equal(feature.geometry.coordinates[1])
expect(inner).toEqual(feature.geometry.coordinates[1])
const members = <{ type: string; role: string; ref: number }[]>(
descriptions.find((d) => d.type === "relation").changes["members"]
)
expect(members[0].role, "incorrect role").eq("outer")
expect(members[1].role, "incorrect role").eq("inner")
expect(members[0].type, "incorrect type").eq("way")
expect(members[1].type, "incorrect type").eq("way")
expect(members[0].ref, "incorrect id").eq(-18)
expect(members[1].ref, "incorrect id").eq(-27)
// "incorrect role"
expect(members[0].role).toBe("outer")
// "incorrect role"
expect(members[1].role).toBe("inner")
// "incorrect type"
expect(members[0].type).toBe("way")
// "incorrect type"
expect(members[1].type).toBe("way")
// "incorrect id"
expect(members[0].ref).toBe(-18)
// "incorrect id"
expect(members[1].ref).toBe(-27)
}
})
})

View file

@ -1,7 +1,6 @@
import { describe } from "mocha"
import { expect } from "chai"
import { ExtraFuncParams, ExtraFunctions } from "../../Logic/ExtraFunctions"
import { OsmFeature } from "../../Models/OsmFeature"
import { describe, expect, it } from "vitest"
describe("OverlapFunc", () => {
it("should give doors on the edge", () => {
@ -122,6 +121,6 @@ describe("OverlapFunc", () => {
ExtraFunctions.FullPatchFeature(params, hermanTeirlinck)
const overlap = (<any>hermanTeirlinck).overlapWith("*")
console.log(JSON.stringify(overlap))
expect(overlap[0].feat == door).true
expect(overlap[0].feat == door).toBe(true)
})
})

View file

@ -1,4 +1,3 @@
import { describe } from "mocha"
import OsmFeatureSource from "../../../Logic/FeatureSource/TiledFeatureSource/OsmFeatureSource"
import { UIEventSource } from "../../../Logic/UIEventSource"
import ScriptUtils from "../../../scripts/ScriptUtils"
@ -8,7 +7,7 @@ import { readFileSync } from "fs"
import { Utils } from "../../../Utils"
import { Tag } from "../../../Logic/Tags/Tag"
import LayerConfig from "../../../Models/ThemeConfig/LayerConfig"
import { expect } from "chai"
import { describe, expect, it } from "vitest"
const expected = {
type: "Feature",
@ -92,7 +91,7 @@ function test(done: () => void) {
handleTile: (tile) => {
fetchedTile = tile
const data = tile.features.data[0].feature
expect(data.properties).deep.eq({
expect(data.properties).toEqual({
id: "relation/5759328",
timestamp: "2022-06-10T00:46:55Z",
version: 6,
@ -107,8 +106,8 @@ function test(done: () => void) {
website: "http://ktahalle.be/",
_backend: "https://osm.org",
})
expect(data.geometry.type).eq("MultiPolygon")
expect(data).deep.eq(expected)
expect(data.geometry.type).toBe("MultiPolygon")
expect(data).toEqual(expected)
done()
},
isActive: new UIEventSource<boolean>(true),

View file

@ -1,7 +1,6 @@
import { describe } from "mocha"
import TileFreshnessCalculator from "../../../Logic/FeatureSource/TileFreshnessCalculator"
import { Tiles } from "../../../Models/TileRange"
import { expect } from "chai"
import { describe, expect, it } from "vitest"
describe("TileFreshnessCalculator", () => {
it("should get the freshness for loaded tiles", () => {
@ -11,13 +10,13 @@ describe("TileFreshnessCalculator", () => {
date.setTime(42)
calc.addTileLoad(Tiles.tile_index(19, 266406, 175534), date)
expect(calc.freshnessFor(19, 266406, 175534).getTime()).eq(42)
expect(calc.freshnessFor(20, 266406 * 2, 175534 * 2 + 1).getTime()).eq(42)
expect(calc.freshnessFor(19, 266406, 175535)).undefined
expect(calc.freshnessFor(18, 266406 / 2, 175534 / 2)).undefined
expect(calc.freshnessFor(19, 266406, 175534).getTime()).toBe(42)
expect(calc.freshnessFor(20, 266406 * 2, 175534 * 2 + 1).getTime()).toBe(42)
expect(calc.freshnessFor(19, 266406, 175535)).toBeUndefined()
expect(calc.freshnessFor(18, 266406 / 2, 175534 / 2)).toBeUndefined()
calc.addTileLoad(Tiles.tile_index(19, 266406, 175534 + 1), date)
calc.addTileLoad(Tiles.tile_index(19, 266406 + 1, 175534), date)
calc.addTileLoad(Tiles.tile_index(19, 266406 + 1, 175534 + 1), date)
expect(calc.freshnessFor(18, 266406 / 2, 175534 / 2).getTime()).eq(42)
expect(calc.freshnessFor(18, 266406 / 2, 175534 / 2).getTime()).toBe(42)
})
})

View file

@ -1,7 +1,6 @@
import { describe } from "mocha"
import { expect } from "chai"
import * as turf from "@turf/turf"
import { GeoOperations } from "../../Logic/GeoOperations"
import { describe, expect, it } from "vitest"
describe("GeoOperations", () => {
describe("calculateOverlap", () => {
@ -123,9 +122,9 @@ describe("GeoOperations", () => {
}
const p0 = turf.polygon(polyGrb.geometry.coordinates)
expect(p0).not.null
expect(p0).not.toBeNull()
const p1 = turf.polygon(polyHouse.geometry.coordinates)
expect(p1).not.null
expect(p1).not.toBeNull()
const overlaps = GeoOperations.calculateOverlap(polyGrb, [polyHouse])
expect(overlaps).empty

View file

@ -1,8 +1,7 @@
import { describe } from "mocha"
import { expect } from "chai"
import AllImageProviders from "../../../Logic/ImageProviders/AllImageProviders"
import { UIEventSource } from "../../../Logic/UIEventSource"
import { Utils } from "../../../Utils"
import { describe, expect, it } from "vitest"
describe("ImageProviders", () => {
it("should work on a variaty of inputs", () => {
@ -16,9 +15,9 @@ describe("ImageProviders", () => {
if (img === undefined) {
throw "No image found"
}
expect(img.url).deep.equal(url)
expect(img.url).toEqual(url)
if (providerName) {
expect(providerName).deep.equal(img.provider.constructor.name)
expect(providerName).toEqual(img.provider.constructor.name)
}
console.log("OK")
})

View file

@ -1,5 +1,3 @@
import { describe } from "mocha"
import { expect } from "chai"
import { Utils } from "../../../../Utils"
import { OsmObject, OsmRelation } from "../../../../Logic/Osm/OsmObject"
import {
@ -7,6 +5,7 @@ import {
TurnRestrictionRSH,
} from "../../../../Logic/Osm/Actions/RelationSplitHandler"
import { Changes } from "../../../../Logic/Osm/Changes"
import { describe, expect, it } from "vitest"
describe("RelationSplitHandler", () => {
Utils.injectJsonDownloadForTests("https://www.openstreetmap.org/api/0.6/node/1124134958/ways", {
@ -651,10 +650,8 @@ describe("RelationSplitHandler", () => {
const changeDescription = await splitter.CreateChangeDescriptions(new Changes())
const allIds = changeDescription[0].changes["members"].map((m) => m.ref).join(",")
const expected = "687866206,295132739,-1,690497698"
expect(
allIds.indexOf(expected) >= 0,
"didn't find the expected order of ids in the relation to test"
).true
// "didn't find the expected order of ids in the relation to test"
expect(allIds.indexOf(expected) >= 0).toBe(true)
})
it("should split turn restrictions (split of https://www.openstreetmap.org/way/143298912)", async () => {
@ -705,7 +702,7 @@ describe("RelationSplitHandler", () => {
.map((m) => m.type + "/" + m.ref + "-->" + m.role)
.join(",")
const expected = "way/318616190-->from,node/1407529979-->via,way/-1-->to"
expect(allIds).deep.equal(expected)
expect(allIds).toEqual(expected)
// Reversing the ids has no effect
const splitterReverse = new TurnRestrictionRSH(
@ -719,6 +716,6 @@ describe("RelationSplitHandler", () => {
"no-theme"
)
const changesReverse = await splitterReverse.CreateChangeDescriptions(new Changes())
expect(changesReverse.length).deep.equal(0)
expect(changesReverse.length).toEqual(0)
})
})

View file

@ -1,13 +1,11 @@
import { describe } from "mocha"
import { expect } from "chai"
import Minimap from "../../../../UI/Base/Minimap"
import { Utils } from "../../../../Utils"
import LayoutConfig from "../../../../Models/ThemeConfig/LayoutConfig"
import State from "../../../../State"
import { BBox } from "../../../../Logic/BBox"
import ReplaceGeometryAction from "../../../../Logic/Osm/Actions/ReplaceGeometryAction"
import ShowDataLayerImplementation from "../../../../UI/ShowDataLayer/ShowDataLayerImplementation"
import ShowDataLayer from "../../../../UI/ShowDataLayer/ShowDataLayer"
import { describe, expect, it } from "vitest"
describe("ReplaceGeometryAction", () => {
const grbStripped = {
@ -896,7 +894,7 @@ describe("ReplaceGeometryAction", () => {
})
const closestIds = await action.GetClosestIds()
expect(closestIds.closestIds).deep.equal([
expect(closestIds.closestIds).toEqual([
9219979643,
1728823481,
4978289383,
@ -910,14 +908,14 @@ describe("ReplaceGeometryAction", () => {
undefined,
])
expect(closestIds.reprojectedNodes.size).deep.equal(1)
expect(closestIds.reprojectedNodes.size).toEqual(1)
const reproj = closestIds.reprojectedNodes.get(1728823549)
expect(reproj.projectAfterIndex).deep.equal(1)
expect(reproj.newLon).deep.equal(3.2168880864669203)
expect(reproj.newLat).deep.equal(51.214739524104694)
expect(closestIds.detachedNodes.size).deep.equal(0)
expect(reproj.projectAfterIndex).toEqual(1)
expect(reproj.newLon).toEqual(3.2168880864669203)
expect(reproj.newLat).toEqual(51.214739524104694)
expect(closestIds.detachedNodes.size).toEqual(0)
const changes = await action.Perform(state.changes)
expect(changes[11].changes["coordinates"]).deep.equal([
expect(changes[11].changes["coordinates"]).toEqual([
[3.216690793633461, 51.21474084112525],
[3.2167256623506546, 51.214696737309964],
[3.2168880864669203, 51.214739524104694],

View file

@ -1,8 +1,7 @@
import { describe } from "mocha"
import { expect } from "chai"
import { Utils } from "../../../../Utils"
import SplitAction from "../../../../Logic/Osm/Actions/SplitAction"
import { Changes } from "../../../../Logic/Osm/Changes"
import { describe, expect, it } from "vitest"
describe("SplitAction", () => {
{
@ -2690,20 +2689,20 @@ describe("SplitAction", () => {
})
const changeDescription = await splitter.CreateChangeDescriptions(new Changes())
expect(changeDescription[0].type).eq("node")
expect(changeDescription[0].id).eq(-1)
expect(changeDescription[0].changes["lat"]).eq(51.181710380278176)
expect(changeDescription[0].changes["lon"]).eq(3.246733546257019)
expect(changeDescription[1].type).eq("way")
expect(changeDescription[1].id).eq(-2)
expect(changeDescription[1].changes["coordinates"].length).eq(6)
expect(changeDescription[1].changes["coordinates"][5][0]).eq(splitPoint[0])
expect(changeDescription[1].changes["coordinates"][5][1]).eq(splitPoint[1])
expect(changeDescription[2].type).eq("way")
expect(changeDescription[2].id).eq(295132739)
expect(changeDescription[2].changes["coordinates"].length).eq(10)
expect(changeDescription[2].changes["coordinates"][0][0]).eq(splitPoint[0])
expect(changeDescription[2].changes["coordinates"][0][1]).eq(splitPoint[1])
expect(changeDescription[0].type).toBe("node")
expect(changeDescription[0].id).toBe(-1)
expect(changeDescription[0].changes["lat"]).toBe(51.181710380278176)
expect(changeDescription[0].changes["lon"]).toBe(3.246733546257019)
expect(changeDescription[1].type).toBe("way")
expect(changeDescription[1].id).toBe(-2)
expect(changeDescription[1].changes["coordinates"].length).toBe(6)
expect(changeDescription[1].changes["coordinates"][5][0]).toBe(splitPoint[0])
expect(changeDescription[1].changes["coordinates"][5][1]).toBe(splitPoint[1])
expect(changeDescription[2].type).toBe("way")
expect(changeDescription[2].id).toBe(295132739)
expect(changeDescription[2].changes["coordinates"].length).toBe(10)
expect(changeDescription[2].changes["coordinates"][0][0]).toBe(splitPoint[0])
expect(changeDescription[2].changes["coordinates"][0][1]).toBe(splitPoint[1])
})
it("split 295132739 on already existing node", async () => {
@ -2715,13 +2714,13 @@ describe("SplitAction", () => {
})
const changeDescription = await splitter.CreateChangeDescriptions(new Changes())
expect(changeDescription.length).eq(2)
expect(changeDescription[0].type).eq("way")
expect(changeDescription[1].type).eq("way")
expect(changeDescription.length).toBe(2)
expect(changeDescription[0].type).toBe("way")
expect(changeDescription[1].type).toBe("way")
expect(
changeDescription[0].changes["nodes"][changeDescription[0].changes["nodes"].length - 1]
).eq(changeDescription[1].changes["nodes"][0])
expect(changeDescription[1].changes["nodes"][0]).eq(1507524610)
).toBe(changeDescription[1].changes["nodes"][0])
expect(changeDescription[1].changes["nodes"][0]).toBe(1507524610)
})
it("split 61435323 on already existing node", async () => {
@ -2733,8 +2732,8 @@ describe("SplitAction", () => {
const changeDescription = await splitter.CreateChangeDescriptions(new Changes())
// Should be a new node
expect(changeDescription[0].type).eq("node")
expect(changeDescription[3].type).eq("relation")
expect(changeDescription[0].type).toBe("node")
expect(changeDescription[3].type).toBe("relation")
})
it("Split test line", async () => {
@ -2764,11 +2763,11 @@ describe("SplitAction", () => {
8715440363
*/
expect(changes[0].changes["nodes"]).deep.equal([
expect(changes[0].changes["nodes"]).toEqual([
6490126559, 8715440375, 8715440374, 8715440373, 8715440372, 8715440371, 8715440370,
8715440369, 8715440368,
])
expect(changes[1].changes["nodes"]).deep.equal([
expect(changes[1].changes["nodes"]).toEqual([
8715440368, 8715440367, 8715440366, 8715440365, 8715440364, 8715440363,
])
})
@ -2784,14 +2783,14 @@ describe("SplitAction", () => {
const changes = await splitAction.Perform(new Changes())
// THe first change is the creation of the new node
expect(changes[0].type).deep.equal("node")
expect(changes[0].id).deep.equal(-1)
expect(changes[0].type).toEqual("node")
expect(changes[0].id).toEqual(-1)
expect(changes[1].changes["nodes"]).deep.equal([
expect(changes[1].changes["nodes"]).toEqual([
6490126559, 8715440375, 8715440374, 8715440373, 8715440372, 8715440371, 8715440370,
8715440369, -1,
])
expect(changes[2].changes["nodes"]).deep.equal([
expect(changes[2].changes["nodes"]).toEqual([
-1, 8715440368, 8715440367, 8715440366, 8715440365, 8715440364, 8715440363,
])
})

View file

@ -1,6 +1,6 @@
import { expect } from "chai"
import { ChangeDescription } from "../../../Logic/Osm/Actions/ChangeDescription"
import { Changes } from "../../../Logic/Osm/Changes"
import { expect, it } from "vitest"
it("Generate preXML from changeDescriptions", () => {
const changeDescrs: ChangeDescription[] = [
@ -29,11 +29,11 @@ it("Generate preXML from changeDescriptions", () => {
]
const c = new Changes()
const descr = c.CreateChangesetObjects(changeDescrs, [])
expect(descr.modifiedObjects).length(0)
expect(descr.deletedObjects).length(0)
expect(descr.newObjects).length(1)
expect(descr.modifiedObjects).toHaveLength(0)
expect(descr.deletedObjects).toHaveLength(0)
expect(descr.newObjects).toHaveLength(1)
const ch = descr.newObjects[0]
expect(ch.tags["foo"]).eq("bar")
expect(ch.tags["someKey"]).eq("someValue")
expect(ch.tags["foo"]).toBe("bar")
expect(ch.tags["someKey"]).toBe("someValue")
})

View file

@ -1,11 +1,10 @@
import { describe } from "mocha"
import { expect } from "chai"
import { Utils } from "../../../Utils"
import { ChangesetHandler, ChangesetTag } from "../../../Logic/Osm/ChangesetHandler"
import { UIEventSource } from "../../../Logic/UIEventSource"
import { OsmConnection } from "../../../Logic/Osm/OsmConnection"
import { ElementStorage } from "../../../Logic/ElementStorage"
import { Changes } from "../../../Logic/Osm/Changes"
import { describe, expect, it } from "vitest"
describe("ChangesetHanlder", () => {
describe("RewriteTagsOf", () => {
@ -56,18 +55,16 @@ describe("ChangesetHanlder", () => {
oldChangesetMeta
)
const d = Utils.asDict(rewritten)
expect(d.size).deep.equal(10)
expect(d.get("answer")).deep.equal("5")
expect(d.get("comment")).deep.equal(
"Adding data with #MapComplete for theme #toerisme_vlaanderen"
)
expect(d.get("created_by")).deep.equal("MapComplete 0.16.6")
expect(d.get("host")).deep.equal("https://mapcomplete.osm.be/toerisme_vlaanderen.html")
expect(d.get("imagery")).deep.equal("osm")
expect(d.get("source")).deep.equal("survey")
expect(d.get("source:node/-1")).deep.equal("note/1234")
expect(d.get("theme")).deep.equal("toerisme_vlaanderen")
expect(d.get("newTag")).deep.equal("newValue")
expect(d.size).toEqual(10)
expect(d.get("answer")).toEqual("5")
expect(d.get("comment")).toEqual("Adding data with #MapComplete for theme #toerisme_vlaanderen")
expect(d.get("created_by")).toEqual("MapComplete 0.16.6")
expect(d.get("host")).toEqual("https://mapcomplete.osm.be/toerisme_vlaanderen.html")
expect(d.get("imagery")).toEqual("osm")
expect(d.get("source")).toEqual("survey")
expect(d.get("source:node/-1")).toEqual("note/1234")
expect(d.get("theme")).toEqual("toerisme_vlaanderen")
expect(d.get("newTag")).toEqual("newValue")
})
it("should aggregate numeric tags", () => {
const changesetHandler = new ChangesetHandler(
@ -116,17 +113,15 @@ describe("ChangesetHanlder", () => {
)
const d = Utils.asDict(rewritten)
expect(d.size).deep.equal(9)
expect(d.get("answer")).deep.equal("42")
expect(d.get("comment")).deep.equal(
"Adding data with #MapComplete for theme #toerisme_vlaanderen"
)
expect(d.get("created_by")).deep.equal("MapComplete 0.16.6")
expect(d.get("host")).deep.equal("https://mapcomplete.osm.be/toerisme_vlaanderen.html")
expect(d.get("imagery")).deep.equal("osm")
expect(d.get("source")).deep.equal("survey")
expect(d.get("source:node/-1")).deep.equal("note/1234")
expect(d.get("theme")).deep.equal("toerisme_vlaanderen")
expect(d.size).toEqual(9)
expect(d.get("answer")).toEqual("42")
expect(d.get("comment")).toEqual("Adding data with #MapComplete for theme #toerisme_vlaanderen")
expect(d.get("created_by")).toEqual("MapComplete 0.16.6")
expect(d.get("host")).toEqual("https://mapcomplete.osm.be/toerisme_vlaanderen.html")
expect(d.get("imagery")).toEqual("osm")
expect(d.get("source")).toEqual("survey")
expect(d.get("source:node/-1")).toEqual("note/1234")
expect(d.get("theme")).toEqual("toerisme_vlaanderen")
})
it("should rewrite special reasons with the correct ID", () => {
const changesetHandler = new ChangesetHandler(
@ -169,17 +164,15 @@ describe("ChangesetHanlder", () => {
)
const d = Utils.asDict(rewritten)
expect(d.size).deep.equal(9)
expect(d.get("answer")).deep.equal("5")
expect(d.get("comment")).deep.equal(
"Adding data with #MapComplete for theme #toerisme_vlaanderen"
)
expect(d.get("created_by")).deep.equal("MapComplete 0.16.6")
expect(d.get("host")).deep.equal("https://mapcomplete.osm.be/toerisme_vlaanderen.html")
expect(d.get("imagery")).deep.equal("osm")
expect(d.get("source")).deep.equal("survey")
expect(d.get("source:node/42")).deep.equal("note/1234")
expect(d.get("theme")).deep.equal("toerisme_vlaanderen")
expect(d.size).toEqual(9)
expect(d.get("answer")).toEqual("5")
expect(d.get("comment")).toEqual("Adding data with #MapComplete for theme #toerisme_vlaanderen")
expect(d.get("created_by")).toEqual("MapComplete 0.16.6")
expect(d.get("host")).toEqual("https://mapcomplete.osm.be/toerisme_vlaanderen.html")
expect(d.get("imagery")).toEqual("osm")
expect(d.get("source")).toEqual("survey")
expect(d.get("source:node/42")).toEqual("note/1234")
expect(d.get("theme")).toEqual("toerisme_vlaanderen")
})
})
@ -200,12 +193,13 @@ describe("ChangesetHanlder", () => {
extraMetaTags,
changes
)
expect(hasSpecialMotivationChanges, "Special rewrite did not trigger").true
// "Special rewrite did not trigger"
expect(hasSpecialMotivationChanges).toBe(true)
// Rewritten inline by rewriteMetaTags
expect(extraMetaTags[1].key).deep.equal("source:node/42")
expect(extraMetaTags[1].value).deep.equal("note/1234")
expect(extraMetaTags[0].key).deep.equal("created_by")
expect(extraMetaTags[0].value).deep.equal("mapcomplete")
expect(extraMetaTags[1].key).toEqual("source:node/42")
expect(extraMetaTags[1].value).toEqual("note/1234")
expect(extraMetaTags[0].key).toEqual("created_by")
expect(extraMetaTags[0].value).toEqual("mapcomplete")
})
})
})

View file

@ -1,9 +1,8 @@
import { describe } from "mocha"
import { expect } from "chai"
import { OsmObject } from "../../../Logic/Osm/OsmObject"
import { Utils } from "../../../Utils"
import ScriptUtils from "../../../scripts/ScriptUtils"
import { readFileSync } from "fs"
import { describe, expect, it } from "vitest"
describe("OsmObject", () => {
describe("download referencing ways", () => {
@ -81,8 +80,8 @@ describe("OsmObject", () => {
it("should download referencing ways", async () => {
const ways = await OsmObject.DownloadReferencingWays("node/1124134958")
expect(ways).not.undefined
expect(ways).length(4)
expect(ways).toBeDefined()
expect(ways).toHaveLength(4)
})
it("should download full OSM-relations", async () => {
@ -93,7 +92,7 @@ describe("OsmObject", () => {
)
const r = await OsmObject.DownloadObjectAsync("relation/5759328").then((x) => x)
const geojson = r.asGeoJson()
expect(geojson.geometry.type).eq("MultiPolygon")
expect(geojson.geometry.type).toBe("MultiPolygon")
})
})
})

View file

@ -1,7 +1,6 @@
import { describe } from "mocha"
import { expect } from "chai"
import { TagUtils } from "../../../Logic/Tags/TagUtils"
import { Tag } from "../../../Logic/Tags/Tag"
import { describe, expect, it } from "vitest"
describe("Lazy object properties", () => {
it("should be matche by a normal tag", () => {
@ -16,7 +15,7 @@ describe("Lazy object properties", () => {
},
})
const filter = new Tag("_key", "yes")
expect(filter.matchesProperties(properties)).true
expect(filter.matchesProperties(properties)).toBe(true)
})
it("should be matched by a RegexTag", () => {
@ -31,6 +30,6 @@ describe("Lazy object properties", () => {
},
})
const filter = TagUtils.Tag("_key~*")
expect(filter.matchesProperties(properties)).true
expect(filter.matchesProperties(properties)).toBe(true)
})
})

View file

@ -1,30 +1,29 @@
import { describe } from "mocha"
import { expect } from "chai"
import { TagsFilter } from "../../../Logic/Tags/TagsFilter"
import { And } from "../../../Logic/Tags/And"
import { Tag } from "../../../Logic/Tags/Tag"
import { TagUtils } from "../../../Logic/Tags/TagUtils"
import { Or } from "../../../Logic/Tags/Or"
import { RegexTag } from "../../../Logic/Tags/RegexTag"
import { describe, expect, it } from "vitest"
describe("Tag optimalization", () => {
describe("And", () => {
it("with condition and nested and should be flattened", () => {
const t = new And([new And([new Tag("x", "y")]), new Tag("a", "b")])
const opt = <TagsFilter>t.optimize()
expect(TagUtils.toString(opt)).eq(`a=b&x=y`)
expect(TagUtils.toString(opt)).toBe(`a=b&x=y`)
})
it("should be 'true' if no conditions are given", () => {
const t = new And([])
const opt = t.optimize()
expect(opt).eq(true)
expect(opt).toBe(true)
})
it("should return false on conflicting tags", () => {
const t = new And([new Tag("key", "a"), new Tag("key", "b")])
const opt = t.optimize()
expect(opt).eq(false)
expect(opt).toBe(false)
})
it("with nested ors and common property should be extracted", () => {
@ -35,7 +34,7 @@ describe("Tag optimalization", () => {
new Or([new Tag("x", "y"), new Tag("c", "d")]),
])
const opt = <TagsFilter>t.optimize()
expect(TagUtils.toString(opt)).eq("foo=bar& (x=y| (a=b&c=d) )")
expect(TagUtils.toString(opt)).toBe("foo=bar& (x=y| (a=b&c=d) )")
})
it("with nested ors and common regextag should be extracted", () => {
@ -46,7 +45,7 @@ describe("Tag optimalization", () => {
new Or([new RegexTag("x", "y"), new RegexTag("c", "d")]),
])
const opt = <TagsFilter>t.optimize()
expect(TagUtils.toString(opt)).eq("foo=bar& ( (a=b&c=d) |x=y)")
expect(TagUtils.toString(opt)).toBe("foo=bar& ( (a=b&c=d) |x=y)")
})
it("with nested ors and inverted regextags should _not_ be extracted", () => {
@ -57,19 +56,19 @@ describe("Tag optimalization", () => {
new Or([new RegexTag("x", "y", true), new RegexTag("c", "d")]),
])
const opt = <TagsFilter>t.optimize()
expect(TagUtils.toString(opt)).eq("foo=bar& (a=b|x=y) & (c=d|x!=y)")
expect(TagUtils.toString(opt)).toBe("foo=bar& (a=b|x=y) & (c=d|x!=y)")
})
it("should move regextag to the end", () => {
const t = new And([new RegexTag("x", "y"), new Tag("a", "b")])
const opt = <TagsFilter>t.optimize()
expect(TagUtils.toString(opt)).eq("a=b&x=y")
expect(TagUtils.toString(opt)).toBe("a=b&x=y")
})
it("should sort tags by their popularity (least popular first)", () => {
const t = new And([new Tag("bicycle", "yes"), new Tag("amenity", "binoculars")])
const opt = <TagsFilter>t.optimize()
expect(TagUtils.toString(opt)).eq("amenity=binoculars&bicycle=yes")
expect(TagUtils.toString(opt)).toBe("amenity=binoculars&bicycle=yes")
})
it("should optimize nested ORs", () => {
@ -163,17 +162,17 @@ describe("Tag optimalization", () => {
"leisure=playground&playground!=forest",
]
expect((<Or>opt).or.map((f) => TagUtils.toString(f))).deep.eq(expected)
expect((<Or>opt).or.map((f) => TagUtils.toString(f))).toEqual(expected)
})
it("should detect conflicting tags", () => {
const q = new And([new Tag("key", "value"), new RegexTag("key", "value", true)])
expect(q.optimize()).eq(false)
expect(q.optimize()).toBe(false)
})
it("should detect conflicting tags with a regex", () => {
const q = new And([new Tag("key", "value"), new RegexTag("key", /value/, true)])
expect(q.optimize()).eq(false)
expect(q.optimize()).toBe(false)
})
})
@ -184,17 +183,17 @@ describe("Tag optimalization", () => {
new And([new Tag("foo", "bar"), new Tag("x", "y")]),
])
const opt = <TagsFilter>t.optimize()
expect(TagUtils.toString(opt)).eq("foo=bar")
expect(TagUtils.toString(opt)).toBe("foo=bar")
})
it("should flatten nested ors", () => {
const t = new Or([new Or([new Tag("x", "y")])]).optimize()
expect(t).deep.eq(new Tag("x", "y"))
expect(t).toEqual(new Tag("x", "y"))
})
it("should flatten nested ors", () => {
const t = new Or([new Tag("a", "b"), new Or([new Tag("x", "y")])]).optimize()
expect(t).deep.eq(new Or([new Tag("a", "b"), new Tag("x", "y")]))
expect(t).toEqual(new Or([new Tag("a", "b"), new Tag("x", "y")]))
})
})
@ -259,33 +258,31 @@ describe("Tag optimalization", () => {
)
*/
expect(opt).deep.eq(
TagUtils.Tag({
or: [
"club=climbing",
{
and: ["sport=climbing", { or: ["club~*", "office~*"] }],
},
{
and: [
"sport=climbing",
{
or: [
"leisure=sports_centre",
{
and: [
"climbing!~route",
"climbing!=route_top",
"climbing!=route_bottom",
"leisure!~sports_centre",
],
},
],
},
],
},
],
})
)
expect(opt).toEqual(TagUtils.Tag({
or: [
"club=climbing",
{
and: ["sport=climbing", { or: ["club~*", "office~*"] }],
},
{
and: [
"sport=climbing",
{
or: [
"leisure=sports_centre",
{
and: [
"climbing!~route",
"climbing!=route_top",
"climbing!=route_bottom",
"leisure!~sports_centre",
],
},
],
},
],
},
],
}))
})
})

View file

@ -1,12 +1,12 @@
import { describe } from "mocha"
import { expect } from "chai"
import { TagUtils } from "../../../Logic/Tags/TagUtils"
import { equal } from "assert"
import { describe, expect, it } from "vitest"
describe("TagUtils", () => {
describe("ParseTag", () => {
it("should refuse a key!=* tag", () => {
expect(() => TagUtils.Tag("key!=*")).to.throw()
expect(() => TagUtils.Tag("key!=*")).toThrowError()
})
it("should handle compare tag <=5", () => {
@ -42,8 +42,8 @@ describe("TagUtils", () => {
it("should handle date comparison tags", () => {
const filter = TagUtils.Tag("date_created<2022-01-07")
expect(filter.matchesProperties({ date_created: "2022-01-08" })).false
expect(filter.matchesProperties({ date_created: "2022-01-01" })).true
expect(filter.matchesProperties({ date_created: "2022-01-08" })).toBe(false)
expect(filter.matchesProperties({ date_created: "2022-01-01" })).toBe(true)
})
})
})

View file

@ -1,7 +1,6 @@
import { describe } from "mocha"
import { expect } from "chai"
import { Utils } from "../../../Utils"
import Wikidata from "../../../Logic/Web/Wikidata"
import { describe, expect, it } from "vitest"
const Q140 = {
entities: {
@ -9464,21 +9463,20 @@ Utils.injectJsonDownloadForTests(
describe("Wikidata", () => {
it("should download Q140 (lion)", async () => {
const wikidata = await Wikidata.LoadWikidataEntryAsync("Q140")
expect(wikidata.claims.get("P18")).length(2)
expect(wikidata.claims.get("P18")).toHaveLength(2)
})
it("should download wikidata", async () => {
const wdata = await Wikidata.LoadWikidataEntryAsync(14517013)
expect(wdata.wikisites).to.have.key("nl")
expect(wdata.wikisites.get("nl")).eq("Vredesmolen")
expect(wdata.wikisites.get("nl")).toBe("Vredesmolen")
})
it("should download a lexeme", async () => {
const response = await Wikidata.LoadWikidataEntryAsync(
"https://www.wikidata.org/wiki/Lexeme:L614072"
)
expect(response).not.undefined
expect(response.labels).to.have.key("nl")
expect(response.labels).to.contains("Groen")
expect(response).toBeDefined()
expect(response.labels).toEqual(new Map<string, string>([["nl", "Groen"]]))
})
})

View file

@ -1,5 +1,3 @@
import { describe } from "mocha"
import { expect } from "chai"
import { Utils } from "../../../../Utils"
import { DesugaringContext } from "../../../../Models/ThemeConfig/Conversion/Conversion"
import { LayerConfigJson } from "../../../../Models/ThemeConfig/Json/LayerConfigJson"
@ -7,6 +5,7 @@ import { TagRenderingConfigJson } from "../../../../Models/ThemeConfig/Json/TagR
import { PrepareLayer } from "../../../../Models/ThemeConfig/Conversion/PrepareLayer"
import * as bookcases from "../../../../assets/layers/public_bookcase/public_bookcase.json"
import CreateNoteImportLayer from "../../../../Models/ThemeConfig/Conversion/CreateNoteImportLayer"
import { describe, expect, it } from "vitest"
describe("CreateNoteImportLayer", () => {
it("should generate a layerconfig", () => {
@ -24,18 +23,15 @@ describe("CreateNoteImportLayer", () => {
layer,
"ImportLayerGeneratorTest: convert"
)
expect(generatedLayer.isShown["and"][1].or[0].and[0]).deep.equal(
"_tags~(^|.*;)amenity=public_bookcase($|;.*)"
)
expect(generatedLayer.minzoom <= layer.minzoom, "Zoomlevel is to high").true
expect(generatedLayer.isShown["and"][1].or[0].and[0]).toEqual("_tags~(^|.*;)amenity=public_bookcase($|;.*)")
// "Zoomlevel is to high"
expect(generatedLayer.minzoom <= layer.minzoom).toBe(true)
let renderings = Utils.NoNull(
Utils.NoNull(
generatedLayer.tagRenderings.map((tr) => (<TagRenderingConfigJson>tr).render)
).map((render) => render["en"])
)
expect(
renderings.some((r) => r.indexOf("import_button") > 0),
"no import button found"
).true
// "no import button found"
expect(renderings.some((r) => r.indexOf("import_button") > 0)).toBe(true)
})
})

View file

@ -1,7 +1,6 @@
import { describe } from "mocha"
import { expect } from "chai"
import LayoutConfig from "../../../../Models/ThemeConfig/LayoutConfig"
import { FixLegacyTheme } from "../../../../Models/ThemeConfig/Conversion/LegacyJsonConvert"
import { describe, expect, it } from "vitest"
describe("FixLegacyTheme", () => {
it("should create a working theme config", () => {
@ -135,8 +134,9 @@ describe("FixLegacyTheme", () => {
],
}
const fixed = new FixLegacyTheme().convert(<any>walking_node_theme, "While testing")
expect(fixed.errors, "Could not fix the legacy theme").empty
// "Could not fix the legacy theme"
expect(fixed.errors).empty
const theme = new LayoutConfig(fixed.result, false)
expect(theme).not.undefined
expect(theme).toBeDefined()
})
})

View file

@ -1,5 +1,3 @@
import { describe } from "mocha"
import { expect } from "chai"
import { LayerConfigJson } from "../../../../Models/ThemeConfig/Json/LayerConfigJson"
import { TagRenderingConfigJson } from "../../../../Models/ThemeConfig/Json/TagRenderingConfigJson"
import LineRenderingConfigJson from "../../../../Models/ThemeConfig/Json/LineRenderingConfigJson"
@ -10,6 +8,7 @@ import {
} from "../../../../Models/ThemeConfig/Conversion/PrepareLayer"
import { QuestionableTagRenderingConfigJson } from "../../../../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson"
import RewritableConfigJson from "../../../../Models/ThemeConfig/Json/RewritableConfigJson"
import { describe, expect, it } from "vitest"
describe("ExpandRewrite", () => {
it("should not allow overlapping keys", () => {
@ -106,7 +105,7 @@ describe("PrepareLayer", () => {
titleIcons: [{ render: "defaults", id: "defaults" }],
}
expect(result).deep.eq(expected)
expect(result).toEqual(expected)
})
})
@ -126,7 +125,7 @@ describe("RewriteSpecial", function () {
},
}
const r = new RewriteSpecial().convert(tr, "test").result
expect(r).to.deep.eq({
expect(r).toEqual({
id: "uk_addresses_import_button",
render: {
"*": "{import_button(address,urpn_count=$urpn_count;ref:GB:uprn=$ref:GB:uprn$,Add this address,./assets/themes/uk_addresses/housenumber_add.svg,,,,none,)}",

View file

@ -1,5 +1,3 @@
import { describe } from "mocha"
import { expect } from "chai"
import { LayoutConfigJson } from "../../../../Models/ThemeConfig/Json/LayoutConfigJson"
import { LayerConfigJson } from "../../../../Models/ThemeConfig/Json/LayerConfigJson"
import { PrepareTheme } from "../../../../Models/ThemeConfig/Conversion/PrepareTheme"
@ -12,6 +10,7 @@ import * as cyclofix from "../../../../assets/generated/themes/cyclofix.json"
import { Tag } from "../../../../Logic/Tags/Tag"
import { DesugaringContext } from "../../../../Models/ThemeConfig/Conversion/Conversion"
import { And } from "../../../../Logic/Tags/And"
import { describe, expect, it } from "vitest"
const themeConfigJson: LayoutConfigJson = {
description: "Descr",
@ -49,7 +48,7 @@ describe("PrepareTheme", () => {
const layerUnderTest = <LayerConfig>(
themeConfig.layers.find((l) => l.id === "public_bookcase")
)
expect(layerUnderTest.source.osmTags).deep.eq(
expect(layerUnderTest.source.osmTags).toEqual(
new And([new Tag("amenity", "public_bookcase")])
)
})
@ -65,7 +64,7 @@ describe("PrepareTheme", () => {
const layerUnderTest = <LayerConfig>(
themeConfig.layers.find((l) => l.id === "public_bookcase")
)
expect(layerUnderTest.source.geojsonSource).eq("xyz")
expect(layerUnderTest.source.geojsonSource).toBe("xyz")
})
it("should apply override", () => {
@ -85,7 +84,7 @@ describe("PrepareTheme", () => {
const layerUnderTest = <LayerConfig>(
themeConfig.layers.find((l) => l.id === "public_bookcase")
)
expect(layerUnderTest.source.geojsonSource).eq("https://example.com/data.geojson")
expect(layerUnderTest.source.geojsonSource).toBe("https://example.com/data.geojson")
})
it("should remove names which are overriden with null", () => {
@ -126,8 +125,8 @@ describe("PrepareTheme", () => {
const rewritten = new PrepareTheme(ctx, {
skipDefaultLayers: true,
}).convertStrict(layout, "test")
expect(rewritten.layers[0]).deep.eq(testLayer)
expect(rewritten.layers[1]).deep.eq({
expect(rewritten.layers[0]).toEqual(testLayer)
expect(rewritten.layers[1]).toEqual({
source: {
osmTags: "x=y",
},
@ -158,7 +157,7 @@ describe("ExtractImages", () => {
"close",
]
for (const expected of expectedValues) {
expect(images).contains(expected)
expect(images).toEqual(expect.arrayContaining([expected]))
}
})
})

View file

@ -1,7 +1,6 @@
import { describe } from "mocha"
import { expect } from "chai"
import SourceConfig from "../../../Models/ThemeConfig/SourceConfig"
import { TagUtils } from "../../../Logic/Tags/TagUtils"
import { describe, expect, it } from "vitest"
describe("SourceConfig", () => {
it("should throw an error on conflicting tags", () => {
@ -14,6 +13,6 @@ describe("SourceConfig", () => {
},
false
)
}).to.throw(/tags are conflicting/)
}).toThrowError(/tags are conflicting/)
})
})

View file

@ -1,7 +1,6 @@
import { describe } from "mocha"
import { expect } from "chai"
import TagRenderingConfig from "../../../Models/ThemeConfig/TagRenderingConfig"
import Locale from "../../../UI/i18n/Locale"
import { describe, expect, it } from "vitest"
describe("TagRenderingConfig", () => {
describe("isKnown", () => {
@ -26,11 +25,11 @@ describe("TagRenderingConfig", () => {
"Tests"
)
expect(tr.GetRenderValue({ foo: "bar" })).undefined
expect(tr.GetRenderValue({ foo: "bar" })).toBeUndefined()
expect(tr.GetRenderValue({ noname: "yes" })?.textFor("nl")).eq("Has no name")
expect(tr.GetRenderValue({ name: "xyz" })?.textFor("nl")).eq("Ook een {name}")
expect(tr.GetRenderValue({ foo: "bar" })).undefined
expect(tr.GetRenderValue({ noname: "yes" })?.textFor("nl")).toBe("Has no name")
expect(tr.GetRenderValue({ name: "xyz" })?.textFor("nl")).toBe("Ook een {name}")
expect(tr.GetRenderValue({ foo: "bar" })).toBeUndefined()
})
it("should give a correct indication", () => {
@ -63,8 +62,8 @@ describe("TagRenderingConfig", () => {
}
const tagRendering = new TagRenderingConfig(config, "test")
expect(tagRendering.IsKnown({ bottle: "yes" })).true
expect(tagRendering.IsKnown({})).false
expect(tagRendering.IsKnown({ bottle: "yes" })).toBe(true)
expect(tagRendering.IsKnown({})).toBe(false)
})
})
})

View file

@ -1,7 +1,6 @@
import { describe } from "mocha"
import { expect } from "chai"
import { Unit } from "../../Models/Unit"
import { Denomination } from "../../Models/Denomination"
import { describe, expect, it } from "vitest"
describe("Unit", () => {
it("should convert a value back and forth", () => {
@ -19,10 +18,10 @@ describe("Unit", () => {
)
const canonical = denomintion.canonicalValue("5", true)
expect(canonical).eq("5 MW")
expect(canonical).toBe("5 MW")
const units = new Unit(["key"], [denomintion], false)
const [detected, detectedDenom] = units.findDenomination("5 MW", () => "be")
expect(detected).eq("5")
expect(detectedDenom).eq(denomintion)
expect(detected).toBe("5")
expect(detectedDenom).toBe(denomintion)
})
})

View file

@ -1,10 +1,9 @@
import { describe } from "mocha"
import { TagRenderingConfigJson } from "../../../Models/ThemeConfig/Json/TagRenderingConfigJson"
import TagRenderingConfig from "../../../Models/ThemeConfig/TagRenderingConfig"
import TagRenderingQuestion from "../../../UI/Popup/TagRenderingQuestion"
import { UIEventSource } from "../../../Logic/UIEventSource"
import { expect } from "chai"
import Locale from "../../../UI/i18n/Locale"
import { describe, expect, it } from "vitest"
describe("TagRenderingQuestion", () => {
it("should have a freeform text field with the user defined placeholder", () => {
@ -21,7 +20,7 @@ describe("TagRenderingQuestion", () => {
const config = new TagRenderingConfig(configJson, "test")
const ui = new TagRenderingQuestion(new UIEventSource<any>({}), config)
const html = ui.ConstructElement()
expect(html.getElementsByTagName("input")[0]["placeholder"]).eq(
expect(html.getElementsByTagName("input")[0]["placeholder"]).toBe(
"Some user defined placeholder"
)
})
@ -40,7 +39,7 @@ describe("TagRenderingQuestion", () => {
const config = new TagRenderingConfig(configJson, "test")
const ui = new TagRenderingQuestion(new UIEventSource<any>({}), config)
const html = ui.ConstructElement()
expect(html.getElementsByTagName("input")[0]["placeholder"]).eq(
expect(html.getElementsByTagName("input")[0]["placeholder"]).toBe(
"capacity (a positive, whole number)"
)
})

View file

@ -1,16 +1,12 @@
import { describe } from "mocha"
import SpecialVisualizations from "../../UI/SpecialVisualizations"
import { expect } from "chai"
import { describe, expect, it } from "vitest"
describe("SpecialVisualisations", () => {
describe("predifined special visualisations", () => {
it("should not have an argument called 'type'", () => {
const specials = SpecialVisualizations.specialVisualizations
for (const special of specials) {
expect(special.funcName).not.eq(
"type",
"A special visualisation is not allowed to be named 'type', as this will conflict with the 'special'-blocks"
)
expect(special.funcName).not.toBe("type")
if (special.args === undefined) {
throw (
@ -20,10 +16,7 @@ describe("SpecialVisualisations", () => {
}
for (const arg of special.args) {
expect(arg.name).not.eq(
"type",
"An argument is not allowed to be called 'type', as this will conflict with the 'special'-blocks"
)
expect(arg.name).not.toBe("type")
}
}
})

View file

@ -1,7 +1,6 @@
import { Utils } from "../Utils"
import LZString from "lz-string"
import { describe } from "mocha"
import { expect } from "chai"
import { describe, expect, it } from "vitest"
const example = {
id: "bookcases",
@ -36,25 +35,25 @@ describe("Utils", () => {
const str = JSON.stringify({ title: "abc", and: "xyz", render: "somevalue" })
const minified = Utils.MinifyJSON(str)
const restored = Utils.UnMinify(minified)
expect(str).eq(restored)
expect(str).toBe(restored)
})
it("should minify and restore the bookcase example", () => {
const str = JSON.stringify(example, null, 0)
const minified = Utils.MinifyJSON(str)
const restored = Utils.UnMinify(minified)
expect(str).eq(restored)
expect(str).toBe(restored)
})
it("should LZ-compress a theme", () => {
const str = JSON.stringify(example, null, 0)
const minified = LZString.compressToBase64(Utils.MinifyJSON(str))
const restored = Utils.UnMinify(LZString.decompressFromBase64(minified))
expect(str).eq(restored)
expect(str).toBe(restored)
})
it("shoud be able to decode the LZ-compression of a theme", () => {
const str = JSON.stringify(example, null, 0)
const minified = LZString.compressToBase64(str)
const restored = LZString.decompressFromBase64(minified)
expect(str).eq(restored)
expect(str).toBe(restored)
})
})
})

View file

@ -1,9 +1,8 @@
import { describe } from "mocha"
import { expect } from "chai"
import { Utils } from "../../Utils"
import { existsSync, mkdirSync, readFileSync, rmdirSync, unlinkSync } from "fs"
import ScriptUtils from "../../scripts/ScriptUtils"
import { main } from "../../scripts/generateCache"
import { describe, expect, it } from "vitest"
function initDownloads(query: string) {
const d = {
@ -7613,10 +7612,8 @@ describe("GenerateCache", () => {
encoding: "utf8",
})
)
expect(birdhides.features.length).deep.equal(5)
expect(
birdhides.features.some((f) => f.properties.id === "node/5158056232"),
"Didn't find birdhide node/5158056232 "
).true
expect(birdhides.features.length).toEqual(5)
// "Didn't find birdhide node/5158056232 "
expect(birdhides.features.some((f) => f.properties.id === "node/5158056232")).toBe(true)
})
})

View file

@ -2,40 +2,18 @@ import ScriptUtils from "../scripts/ScriptUtils"
import { Utils } from "../Utils"
import * as fakedom from "fake-dom"
import Locale from "../UI/i18n/Locale"
import { beforeEach } from "vitest"
export const mochaHooks = {
beforeEach(done) {
ScriptUtils.fixUtils()
Locale.language.setData("en")
beforeEach(async () => {
ScriptUtils.fixUtils()
Locale.language.setData("en")
if (fakedom === undefined || window === undefined) {
throw "FakeDom not initialized"
}
if (fakedom === undefined || window === undefined) {
throw "FakeDom not initialized"
}
// Block internet access
const realDownloadFunc = Utils.externalDownloadFunction
Utils.externalDownloadFunction = async (url) => {
console.error(
"Fetching ",
url,
"blocked in tests, use Utils.injectJsonDownloadForTests"
)
const data = await realDownloadFunc(url)
console.log(
"\n\n ----------- \nBLOCKED DATA\n Utils.injectJsonDownloadForTests(\n" + " ",
JSON.stringify(url),
", \n",
" ",
// JSON.stringify(data),
"\n )\n------------------\n\n"
)
throw new Error(
"Detected internet access for URL " +
url +
", please inject it with Utils.injectJsonDownloadForTests"
)
}
done()
},
}
// Block internet access
Utils.externalDownloadFunction = async (url) => {
throw "Fetching " + url + "blocked in tests, use Utils.injectJsonDownloadForTests instead"
}
})

8
vitest.config.ts Normal file
View file

@ -0,0 +1,8 @@
import { defineConfig } from "vitest/config"
export default defineConfig({
test: {
globals: true,
setupFiles: ["./test/testhooks.ts"],
},
})