@panoramax/web-viewer 4.4.0-develop-3839b5a4 → 4.4.0-develop-d8b38e70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{src → build}/components/core/Basic.js +22 -16
- package/{src → build}/components/core/CoverageMap.js +19 -14
- package/{src → build}/components/core/Editor.js +16 -16
- package/{src → build}/components/core/PhotoViewer.js +30 -29
- package/{src → build}/components/core/Viewer.js +21 -20
- package/build/components/core/index.js +10 -0
- package/build/components/index.js +11 -0
- package/build/components/index_photoviewer.js +6 -0
- package/{src → build}/components/layout/BottomDrawer.js +4 -4
- package/{src → build}/components/layout/CorneredGrid.js +1 -1
- package/{src → build}/components/layout/Mini.js +5 -4
- package/{src → build}/components/layout/Tabs.js +1 -1
- package/build/components/layout/index.js +9 -0
- package/{src → build}/components/menus/LocationPrecisionDoc.js +4 -6
- package/{src → build}/components/menus/MapBackground.js +4 -6
- package/{src → build}/components/menus/MapFilters.js +16 -21
- package/{src → build}/components/menus/MapLayers.js +20 -24
- package/{src → build}/components/menus/MapLegend.js +3 -4
- package/{src → build}/components/menus/MiniPictureLegend.js +3 -4
- package/{src → build}/components/menus/PictureLegend.js +10 -15
- package/{src → build}/components/menus/PictureMetadata.js +12 -19
- package/{src → build}/components/menus/PlayerOptions.js +5 -7
- package/{src → build}/components/menus/QualityScoreDoc.js +3 -4
- package/{src → build}/components/menus/ReportForm.js +8 -9
- package/{src → build}/components/menus/SemanticsDoc.js +3 -4
- package/{src → build}/components/menus/SemanticsDownload.js +3 -3
- package/{src → build}/components/menus/SemanticsFilters.js +7 -8
- package/{src → build}/components/menus/SemanticsList.js +11 -18
- package/{src → build}/components/menus/SemanticsMetadata.js +8 -11
- package/{src → build}/components/menus/Share.js +6 -7
- package/build/components/menus/index.js +22 -0
- package/build/components/menus/index_photoviewer.js +11 -0
- package/{src → build}/components/styles.js +0 -2
- package/{src → build}/components/ui/AnnotationsSwitch.js +6 -8
- package/{src → build}/components/ui/Button.js +1 -1
- package/{src → build}/components/ui/ButtonGroup.js +2 -1
- package/{src → build}/components/ui/CopyButton.js +4 -6
- package/{src → build}/components/ui/Grade.js +5 -5
- package/{src → build}/components/ui/GradeFilter.js +3 -3
- package/{src → build}/components/ui/IconSwitch.js +1 -1
- package/{src → build}/components/ui/LinkButton.js +1 -1
- package/{src → build}/components/ui/ListGroup.js +3 -3
- package/{src → build}/components/ui/ListItem.js +1 -1
- package/{src → build}/components/ui/Loader.js +8 -7
- package/{src → build}/components/ui/Map.js +38 -26
- package/{src → build}/components/ui/MapMore.js +7 -7
- package/{src → build}/components/ui/Photo.js +29 -27
- package/{src → build}/components/ui/Popup.js +4 -4
- package/{src → build}/components/ui/QualityScore.js +4 -4
- package/{src → build}/components/ui/SearchBar.js +6 -7
- package/{src → build}/components/ui/SemanticsEditor.js +14 -15
- package/{src → build}/components/ui/SemanticsTable.js +4 -5
- package/{src → build}/components/ui/Switch.js +1 -1
- package/{src → build}/components/ui/TogglableGroup.js +4 -4
- package/build/components/ui/index.js +29 -0
- package/build/components/ui/index_photoviewer.js +21 -0
- package/{src → build}/components/ui/widgets/CopyCoordinates.js +5 -5
- package/{src → build}/components/ui/widgets/GeoSearch.js +10 -10
- package/{src → build}/components/ui/widgets/Legend.js +9 -8
- package/{src → build}/components/ui/widgets/LevelSelect.js +9 -7
- package/{src → build}/components/ui/widgets/MapFiltersButton.js +5 -5
- package/{src → build}/components/ui/widgets/MapLayersButton.js +5 -5
- package/{src → build}/components/ui/widgets/OSMEditors.js +8 -8
- package/{src → build}/components/ui/widgets/PictureLegendActions.js +4 -4
- package/{src → build}/components/ui/widgets/Player.js +6 -7
- package/{src → build}/components/ui/widgets/SemanticsFiltersButton.js +6 -7
- package/{src → build}/components/ui/widgets/Zoom.js +6 -6
- package/build/components/ui/widgets/index.js +16 -0
- package/build/components/ui/widgets/index_photoviewer.js +7 -0
- package/build/editor.html +94 -10
- package/{src → build}/img/arrow_triangle.svg +0 -1
- package/{src → build}/img/arrow_turn.svg +0 -1
- package/build/index.html +111 -1
- package/build/index.js +6 -95
- package/build/index_photoviewer.js +4 -0
- package/build/map.html +97 -1
- package/build/package.json +141 -0
- package/build/photo.html +85 -1
- package/build/servers.js +3 -4
- package/{src → build}/utils/API.js +33 -33
- package/{src → build}/utils/InitParameters.js +11 -9
- package/{src → build}/utils/MapStyleComposer.js +39 -37
- package/{src → build}/utils/PhotoAdapter.js +1 -0
- package/{src → build}/utils/PresetsManager.js +4 -4
- package/{src → build}/utils/SemanticsMapProtocol.js +3 -4
- package/{src → build}/utils/URLHandler.js +16 -14
- package/{src → build}/utils/geocoder.js +5 -5
- package/{src → build}/utils/i18n.js +21 -20
- package/build/utils/index.js +17 -0
- package/build/utils/index_photoviewer.js +14 -0
- package/{src → build}/utils/indoor.js +9 -5
- package/{src → build}/utils/map.js +15 -11
- package/{src → build}/utils/picture.js +22 -17
- package/{src → build}/utils/semantics.js +9 -5
- package/{src → build}/utils/utils.js +8 -4
- package/{src → build}/utils/widgets.js +2 -2
- package/build/viewer.html +120 -35
- package/build/viewer_indoor.html +90 -8
- package/build/widgets.html +410 -1
- package/package.json +81 -204
- package/.dockerignore +0 -7
- package/.gitlab-ci.yml +0 -78
- package/CHANGELOG.md +0 -853
- package/CODE_OF_CONDUCT.md +0 -134
- package/Dockerfile +0 -14
- package/build/index.css +0 -36
- package/build/index.css.map +0 -1
- package/build/index.js.map +0 -1
- package/build/photoviewer.css +0 -36
- package/build/photoviewer.css.map +0 -1
- package/build/photoviewer.js +0 -86
- package/build/photoviewer.js.map +0 -1
- package/build/static/media/atkinson-hyperlegible-next-latin-400-normal..woff +0 -0
- package/build/static/media/atkinson-hyperlegible-next-latin-400-normal..woff2 +0 -0
- package/build/static/media/atkinson-hyperlegible-next-latin-ext-400-normal..woff +0 -0
- package/build/static/media/atkinson-hyperlegible-next-latin-ext-400-normal..woff2 +0 -0
- package/config/env.js +0 -104
- package/config/getHttpsConfig.js +0 -69
- package/config/getPackageJson.js +0 -25
- package/config/jest/babelTransform.js +0 -29
- package/config/jest/cssTransform.js +0 -14
- package/config/jest/fileTransform.js +0 -40
- package/config/jest/mocks.js +0 -230
- package/config/modules.js +0 -134
- package/config/paths.js +0 -76
- package/config/pnpTs.js +0 -35
- package/config/webpack/persistentCache/createEnvironmentHash.js +0 -9
- package/config/webpack.config.js +0 -825
- package/config/webpackDevServer.config.js +0 -131
- package/docs/03_URL_settings.md +0 -218
- package/docs/05_Compatibility.md +0 -83
- package/docs/09_Develop.md +0 -141
- package/docs/90_Releases.md +0 -27
- package/docs/images/class_diagram.drawio +0 -144
- package/docs/images/class_diagram.jpg +0 -0
- package/docs/images/comparative_3drender.jpg +0 -0
- package/docs/images/indoor_level.png +0 -0
- package/docs/images/screenshot.jpg +0 -0
- package/docs/index.md +0 -159
- package/docs/reference/components/core/Basic.md +0 -211
- package/docs/reference/components/core/CoverageMap.md +0 -220
- package/docs/reference/components/core/Editor.md +0 -252
- package/docs/reference/components/core/PhotoViewer.md +0 -320
- package/docs/reference/components/core/Viewer.md +0 -398
- package/docs/reference/components/layout/BottomDrawer.md +0 -35
- package/docs/reference/components/layout/CorneredGrid.md +0 -29
- package/docs/reference/components/layout/Mini.md +0 -45
- package/docs/reference/components/layout/Tabs.md +0 -46
- package/docs/reference/components/menus/LocationPrecisionDoc.md +0 -15
- package/docs/reference/components/menus/MapBackground.md +0 -32
- package/docs/reference/components/menus/MapFilters.md +0 -37
- package/docs/reference/components/menus/MapLayers.md +0 -15
- package/docs/reference/components/menus/MapLegend.md +0 -32
- package/docs/reference/components/menus/MiniPictureLegend.md +0 -15
- package/docs/reference/components/menus/PictureLegend.md +0 -45
- package/docs/reference/components/menus/PictureMetadata.md +0 -32
- package/docs/reference/components/menus/PlayerOptions.md +0 -15
- package/docs/reference/components/menus/QualityScoreDoc.md +0 -15
- package/docs/reference/components/menus/ReportForm.md +0 -15
- package/docs/reference/components/menus/SemanticsDoc.md +0 -15
- package/docs/reference/components/menus/SemanticsDownload.md +0 -15
- package/docs/reference/components/menus/SemanticsFilters.md +0 -33
- package/docs/reference/components/menus/SemanticsList.md +0 -97
- package/docs/reference/components/menus/SemanticsMetadata.md +0 -15
- package/docs/reference/components/menus/ShareMenu.md +0 -32
- package/docs/reference/components/ui/AnnotationsSwitch.md +0 -32
- package/docs/reference/components/ui/Button.md +0 -40
- package/docs/reference/components/ui/ButtonGroup.md +0 -36
- package/docs/reference/components/ui/CopyButton.md +0 -41
- package/docs/reference/components/ui/Grade.md +0 -32
- package/docs/reference/components/ui/GradeFilter.md +0 -42
- package/docs/reference/components/ui/IconSwitch.md +0 -53
- package/docs/reference/components/ui/LinkButton.md +0 -45
- package/docs/reference/components/ui/ListGroup.md +0 -22
- package/docs/reference/components/ui/ListItem.md +0 -39
- package/docs/reference/components/ui/Loader.md +0 -56
- package/docs/reference/components/ui/Map.md +0 -150
- package/docs/reference/components/ui/MapMore.md +0 -150
- package/docs/reference/components/ui/Photo.md +0 -495
- package/docs/reference/components/ui/Popup.md +0 -56
- package/docs/reference/components/ui/ProgressBar.md +0 -32
- package/docs/reference/components/ui/QualityScore.md +0 -45
- package/docs/reference/components/ui/SearchBar.md +0 -63
- package/docs/reference/components/ui/SemanticsEditor.md +0 -113
- package/docs/reference/components/ui/SemanticsTable.md +0 -32
- package/docs/reference/components/ui/Switch.md +0 -49
- package/docs/reference/components/ui/TogglableGroup.md +0 -39
- package/docs/reference/components/ui/widgets/CopyCoordinates.md +0 -32
- package/docs/reference/components/ui/widgets/GeoSearch.md +0 -36
- package/docs/reference/components/ui/widgets/Legend.md +0 -58
- package/docs/reference/components/ui/widgets/LevelSelect.md +0 -16
- package/docs/reference/components/ui/widgets/MapFiltersButton.md +0 -37
- package/docs/reference/components/ui/widgets/MapLayersButton.md +0 -15
- package/docs/reference/components/ui/widgets/OSMEditors.md +0 -15
- package/docs/reference/components/ui/widgets/PictureLegendActions.md +0 -32
- package/docs/reference/components/ui/widgets/Player.md +0 -34
- package/docs/reference/components/ui/widgets/SemanticsFiltersButton.md +0 -15
- package/docs/reference/components/ui/widgets/Zoom.md +0 -15
- package/docs/reference/utils/API.md +0 -389
- package/docs/reference/utils/InitParameters.md +0 -68
- package/docs/reference/utils/MapStyleComposer.md +0 -408
- package/docs/reference/utils/PanoraMapProtocol.md +0 -28
- package/docs/reference/utils/PresetsManager.md +0 -43
- package/docs/reference/utils/SemanticsMapProtocol.md +0 -43
- package/docs/reference/utils/URLHandler.md +0 -114
- package/docs/reference.md +0 -99
- package/docs/shortcuts.md +0 -11
- package/docs/tutorials/aerial_imagery.md +0 -21
- package/docs/tutorials/authentication.md +0 -10
- package/docs/tutorials/custom_widgets.md +0 -59
- package/docs/tutorials/indoor_maps.md +0 -50
- package/docs/tutorials/map_style.md +0 -83
- package/docs/tutorials/migrate_v4.md +0 -153
- package/docs/tutorials/migrate_v5.md +0 -103
- package/docs/tutorials/semantics_overlays.md +0 -74
- package/docs/tutorials/synced_coverage.md +0 -43
- package/mkdocs.yml +0 -131
- package/public/editor.html +0 -53
- package/public/index.html +0 -70
- package/public/map.html +0 -55
- package/public/photo.html +0 -43
- package/public/servers.js +0 -15
- package/public/viewer.html +0 -79
- package/public/viewer_indoor.html +0 -48
- package/public/widgets.html +0 -366
- package/scripts/build.js +0 -217
- package/scripts/doc.js +0 -79
- package/scripts/start.js +0 -172
- package/scripts/test.js +0 -52
- package/src/components/core/index.js +0 -12
- package/src/components/index.js +0 -13
- package/src/components/index_photoviewer.js +0 -8
- package/src/components/layout/index.js +0 -9
- package/src/components/menus/index.js +0 -22
- package/src/components/menus/index_photoviewer.js +0 -13
- package/src/components/ui/index.js +0 -29
- package/src/components/ui/index_photoviewer.js +0 -23
- package/src/components/ui/widgets/index.js +0 -16
- package/src/components/ui/widgets/index_photoviewer.js +0 -9
- package/src/index.js +0 -8
- package/src/index_photoviewer.js +0 -6
- package/src/utils/index.js +0 -17
- package/src/utils/index_photoviewer.js +0 -16
- package/tests/components/core/Basic.test.js +0 -168
- package/tests/components/core/BasicMock.js +0 -25
- package/tests/components/core/CoverageMap.test.js +0 -20
- package/tests/components/core/Editor.test.js +0 -20
- package/tests/components/core/PhotoViewer.test.js +0 -57
- package/tests/components/core/Viewer.test.js +0 -85
- package/tests/components/core/__snapshots__/PhotoViewer.test.js.snap +0 -96
- package/tests/components/core/__snapshots__/Viewer.test.js.snap +0 -188
- package/tests/components/ui/CopyButton.test.js +0 -52
- package/tests/components/ui/Loader.test.js +0 -55
- package/tests/components/ui/Map.test.js +0 -145
- package/tests/components/ui/Photo.test.js +0 -437
- package/tests/components/ui/Popup.test.js +0 -26
- package/tests/components/ui/QualityScore.test.js +0 -18
- package/tests/components/ui/SearchBar.test.js +0 -110
- package/tests/components/ui/__snapshots__/CopyButton.test.js.snap +0 -33
- package/tests/components/ui/__snapshots__/Loader.test.js.snap +0 -56
- package/tests/components/ui/__snapshots__/Map.test.js.snap +0 -16
- package/tests/components/ui/__snapshots__/Photo.test.js.snap +0 -263
- package/tests/components/ui/__snapshots__/Popup.test.js.snap +0 -29
- package/tests/components/ui/__snapshots__/QualityScore.test.js.snap +0 -11
- package/tests/components/ui/__snapshots__/SearchBar.test.js.snap +0 -65
- package/tests/data/Map_geocoder_ban.json +0 -36
- package/tests/data/Map_geocoder_nominatim.json +0 -41
- package/tests/data/Viewer_pictures_1.json +0 -148
- package/tests/setupTests.js +0 -5
- package/tests/utils/API.test.js +0 -752
- package/tests/utils/InitParameters.test.js +0 -599
- package/tests/utils/MapStyleComposer.test.js +0 -697
- package/tests/utils/PresetsManager.test.js +0 -123
- package/tests/utils/URLHandler.test.js +0 -587
- package/tests/utils/__snapshots__/API.test.js.snap +0 -40
- package/tests/utils/__snapshots__/MapStyleComposer.test.js.snap +0 -767
- package/tests/utils/__snapshots__/URLHandler.test.js.snap +0 -21
- package/tests/utils/__snapshots__/geocoder.test.js.snap +0 -37
- package/tests/utils/__snapshots__/map.test.js.snap +0 -1249
- package/tests/utils/__snapshots__/picture.test.js.snap +0 -327
- package/tests/utils/__snapshots__/widgets.test.js.snap +0 -19
- package/tests/utils/geocoder.test.js +0 -37
- package/tests/utils/i18n.test.js +0 -111
- package/tests/utils/map.test.js +0 -200
- package/tests/utils/picture.test.js +0 -745
- package/tests/utils/semantics.test.js +0 -174
- package/tests/utils/utils.test.js +0 -358
- package/tests/utils/widgets.test.js +0 -31
- /package/{src → build}/components/core/Basic.css +0 -0
- /package/{src → build}/components/core/CoverageMap.css +0 -0
- /package/{src → build}/components/core/Editor.css +0 -0
- /package/{src → build}/components/core/PhotoViewer.css +0 -0
- /package/{src → build}/components/core/Viewer.css +0 -0
- /package/{src → build}/components/ui/ButtonGroup.css +0 -0
- /package/{src → build}/components/ui/Map.css +0 -0
- /package/{src → build}/components/ui/Photo.css +0 -0
- /package/{src → build}/components/ui/ProgressBar.js +0 -0
- /package/{src → build}/components/ui/widgets/GeoSearch.css +0 -0
- /package/{src → build}/components/ui/widgets/LevelSelect.css +0 -0
- /package/{src → build}/components/ui/widgets/Player.css +0 -0
- /package/{public → build}/favicon.ico +0 -0
- /package/{src → build}/img/arrow_360.svg +0 -0
- /package/{src → build}/img/arrow_flat.svg +0 -0
- /package/{src → build}/img/bg_aerial.jpg +0 -0
- /package/{src → build}/img/bg_streets.jpg +0 -0
- /package/{src → build}/img/loader_base.jpg +0 -0
- /package/{src → build}/img/logo_dead.svg +0 -0
- /package/{src → build}/img/marker.svg +0 -0
- /package/{src → build}/img/marker_blue.svg +0 -0
- /package/{src → build}/img/osm.svg +0 -0
- /package/{src → build}/img/panoramax.svg +0 -0
- /package/{src → build}/img/switch_big.svg +0 -0
- /package/{src → build}/img/switch_mini.svg +0 -0
- /package/{src → build}/img/wd.svg +0 -0
- /package/{src → build}/translations/ar.json +0 -0
- /package/{src → build}/translations/be.json +0 -0
- /package/{src → build}/translations/br.json +0 -0
- /package/{src → build}/translations/cy.json +0 -0
- /package/{src → build}/translations/da.json +0 -0
- /package/{src → build}/translations/de.json +0 -0
- /package/{src → build}/translations/en.json +0 -0
- /package/{src → build}/translations/eo.json +0 -0
- /package/{src → build}/translations/es.json +0 -0
- /package/{src → build}/translations/fi.json +0 -0
- /package/{src → build}/translations/fr.json +0 -0
- /package/{src → build}/translations/hu.json +0 -0
- /package/{src → build}/translations/it.json +0 -0
- /package/{src → build}/translations/ja.json +0 -0
- /package/{src → build}/translations/ko.json +0 -0
- /package/{src → build}/translations/nl.json +0 -0
- /package/{src → build}/translations/nn.json +0 -0
- /package/{src → build}/translations/pl.json +0 -0
- /package/{src → build}/translations/pt.json +0 -0
- /package/{src → build}/translations/pt_BR.json +0 -0
- /package/{src → build}/translations/sv.json +0 -0
- /package/{src → build}/translations/ti.json +0 -0
- /package/{src → build}/translations/tr.json +0 -0
- /package/{src → build}/translations/uk.json +0 -0
- /package/{src → build}/translations/zh_Hant.json +0 -0
- /package/{src → build}/utils/PanoraMapProtocol.js +0 -0
- /package/{src → build}/utils/services.js +0 -0
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import PresetsManager from "../../src/utils/PresetsManager";
|
|
2
|
-
|
|
3
|
-
const mockPresets = {
|
|
4
|
-
"osm_traffic_sign": {
|
|
5
|
-
"icon": "fas-directions",
|
|
6
|
-
"tags": {
|
|
7
|
-
"osm|traffic_sign": "*"
|
|
8
|
-
},
|
|
9
|
-
"geometry": [
|
|
10
|
-
"point",
|
|
11
|
-
"vertex"
|
|
12
|
-
]
|
|
13
|
-
},
|
|
14
|
-
"osm_traffic_calming": {
|
|
15
|
-
"icon": "temaki-diamond",
|
|
16
|
-
"tags": {
|
|
17
|
-
"osm|traffic_calming": "*"
|
|
18
|
-
},
|
|
19
|
-
"geometry": [
|
|
20
|
-
"vertex"
|
|
21
|
-
]
|
|
22
|
-
},
|
|
23
|
-
"osm_shop": {
|
|
24
|
-
"icon": "maki-shop",
|
|
25
|
-
"tags": {
|
|
26
|
-
"osm|shop": "*"
|
|
27
|
-
},
|
|
28
|
-
"geometry": [
|
|
29
|
-
"point",
|
|
30
|
-
"area"
|
|
31
|
-
]
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// Mock des appels fetch
|
|
36
|
-
global.fetch = jest.fn(() =>
|
|
37
|
-
Promise.resolve({
|
|
38
|
-
ok: true,
|
|
39
|
-
json: () => Promise.resolve({}),
|
|
40
|
-
})
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
beforeEach(() => {
|
|
44
|
-
fetch.mockClear();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("should initialize with default values", () => {
|
|
48
|
-
const presetsManager = new PresetsManager(null, true);
|
|
49
|
-
expect(presetsManager._ready).toBe(false);
|
|
50
|
-
expect(presetsManager._presets).toBe(null);
|
|
51
|
-
expect(presetsManager._translations).toEqual({});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("should load translations and presets", async () => {
|
|
55
|
-
const mockTranslationsEN = { en: { presets: { preset1: { name: "Preset 1" } } } };
|
|
56
|
-
const mockTranslationsFR = { fr: { presets: { preset1: { name: "Préréglage 1" } } } };
|
|
57
|
-
|
|
58
|
-
fetch.mockImplementationOnce(() =>
|
|
59
|
-
Promise.resolve({
|
|
60
|
-
ok: true,
|
|
61
|
-
json: () => Promise.resolve(mockTranslationsEN),
|
|
62
|
-
})
|
|
63
|
-
).mockImplementationOnce(() =>
|
|
64
|
-
Promise.resolve({
|
|
65
|
-
ok: true,
|
|
66
|
-
json: () => Promise.resolve(mockTranslationsFR),
|
|
67
|
-
})
|
|
68
|
-
).mockImplementationOnce(() =>
|
|
69
|
-
Promise.resolve({
|
|
70
|
-
ok: true,
|
|
71
|
-
json: () => Promise.resolve(mockPresets),
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const presetsManager = new PresetsManager("fr");
|
|
76
|
-
await presetsManager.onceReady();
|
|
77
|
-
|
|
78
|
-
expect(presetsManager._translations.en).toEqual(mockTranslationsEN.en.presets);
|
|
79
|
-
expect(presetsManager._translations.fr).toEqual(mockTranslationsFR.fr.presets);
|
|
80
|
-
expect(presetsManager._presets).toEqual(mockPresets);
|
|
81
|
-
expect(presetsManager._ready).toBe(true);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("should handle errors during load", async () => {
|
|
85
|
-
global.console = { error: jest.fn() };
|
|
86
|
-
|
|
87
|
-
fetch.mockImplementation(() =>
|
|
88
|
-
Promise.resolve({
|
|
89
|
-
ok: false,
|
|
90
|
-
})
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
const presetsManager = new PresetsManager();
|
|
94
|
-
await expect(presetsManager.onceReady()).rejects.toBeUndefined();
|
|
95
|
-
expect(presetsManager._ready).toBe(-1);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("should find the best matching preset", async () => {
|
|
99
|
-
fetch.mockImplementationOnce(() =>
|
|
100
|
-
Promise.resolve({
|
|
101
|
-
ok: true,
|
|
102
|
-
json: () => Promise.resolve({}),
|
|
103
|
-
})
|
|
104
|
-
).mockImplementationOnce(() =>
|
|
105
|
-
Promise.resolve({
|
|
106
|
-
ok: true,
|
|
107
|
-
json: () => Promise.resolve({}),
|
|
108
|
-
})
|
|
109
|
-
).mockImplementationOnce(() =>
|
|
110
|
-
Promise.resolve({
|
|
111
|
-
ok: true,
|
|
112
|
-
json: () => Promise.resolve(mockPresets),
|
|
113
|
-
})
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
const presetsManager = new PresetsManager();
|
|
117
|
-
await presetsManager.onceReady();
|
|
118
|
-
|
|
119
|
-
const feature = { semantics: [{ key: "key1", value: "value1" }, { key: "key2", value: "value2" }] };
|
|
120
|
-
const bestPreset = await presetsManager.getPreset(feature);
|
|
121
|
-
|
|
122
|
-
expect(bestPreset).toEqual(mockPresets.preset2);
|
|
123
|
-
});
|
|
@@ -1,587 +0,0 @@
|
|
|
1
|
-
import URLHandler from "../../src/utils/URLHandler";
|
|
2
|
-
|
|
3
|
-
describe("listenToChanges", () => {
|
|
4
|
-
it("should add event listeners to window, parent, psv, and map", () => {
|
|
5
|
-
window.addEventListener = jest.fn();
|
|
6
|
-
const parent = {
|
|
7
|
-
addEventListener: jest.fn(),
|
|
8
|
-
psv: { addEventListener: jest.fn() },
|
|
9
|
-
map: { on: jest.fn() },
|
|
10
|
-
mapStyleComposer: { addEventListener: jest.fn() },
|
|
11
|
-
};
|
|
12
|
-
const urlHandler = new URLHandler(parent);
|
|
13
|
-
urlHandler.listenToChanges();
|
|
14
|
-
expect(window.addEventListener).toHaveBeenCalledWith("popstate", expect.any(Function), false);
|
|
15
|
-
["focus-changed", "pictures-navigation-changed"].forEach(event => {
|
|
16
|
-
expect(parent.addEventListener).toHaveBeenCalledWith(event, expect.any(Function));
|
|
17
|
-
});
|
|
18
|
-
["position-updated", "zoom-updated", "view-rotated", "picture-loaded", "transition-duration-changed"].forEach(event => {
|
|
19
|
-
expect(parent.psv.addEventListener).toHaveBeenCalledWith(event, expect.any(Function));
|
|
20
|
-
});
|
|
21
|
-
["moveend", "zoomend", "boxzoomend"].forEach(event => {
|
|
22
|
-
expect(parent.map.on).toHaveBeenCalledWith(event, expect.any(Function));
|
|
23
|
-
});
|
|
24
|
-
["filters-changed", "theme-changed", "panoramax-changed", "basemap-changed"].forEach(event => {
|
|
25
|
-
expect(parent.mapStyleComposer.addEventListener).toHaveBeenCalledWith(event, expect.any(Function));
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe("nextURLString", () => {
|
|
31
|
-
it("works without any specific values set", () => {
|
|
32
|
-
const v = {
|
|
33
|
-
addEventListener: jest.fn(),
|
|
34
|
-
psv: {
|
|
35
|
-
getPicturesNavigation: () => null,
|
|
36
|
-
getTransitionDuration: () => null,
|
|
37
|
-
getPictureMetadata: () => null,
|
|
38
|
-
getPictureId: () => null,
|
|
39
|
-
getSelectedAnnotations: () => [],
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
const uh = new URLHandler(v);
|
|
43
|
-
expect(uh.nextURLString()).toBe("?");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("works with picture metadata", () => {
|
|
47
|
-
const v = {
|
|
48
|
-
addEventListener: jest.fn(),
|
|
49
|
-
psv: {
|
|
50
|
-
getPicturesNavigation: () => null,
|
|
51
|
-
getTransitionDuration: () => null,
|
|
52
|
-
getPictureMetadata: () => ({}),
|
|
53
|
-
getPictureId: () => "cbfc3add-8173-4464-98c8-de2a43c6a50f",
|
|
54
|
-
getSelectedAnnotations: () => [],
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
const uh = new URLHandler(v);
|
|
58
|
-
uh.currentPSVString = () => "0/1/2";
|
|
59
|
-
expect(uh.nextURLString()).toBe("?pic=cbfc3add-8173-4464-98c8-de2a43c6a50f&xyz=0/1/2");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("works with map started + wide", () => {
|
|
63
|
-
const v = {
|
|
64
|
-
addEventListener: jest.fn(),
|
|
65
|
-
psv: {
|
|
66
|
-
getPicturesNavigation: () => null,
|
|
67
|
-
getTransitionDuration: () => null,
|
|
68
|
-
getPictureMetadata: () => null,
|
|
69
|
-
getPictureId: () => null,
|
|
70
|
-
getSelectedAnnotations: () => [],
|
|
71
|
-
},
|
|
72
|
-
map: {
|
|
73
|
-
loaded: () => true,
|
|
74
|
-
},
|
|
75
|
-
mapStyleComposer: {
|
|
76
|
-
hasManyBasemaps: () => false,
|
|
77
|
-
basemap: "streets",
|
|
78
|
-
panoramax: "default",
|
|
79
|
-
},
|
|
80
|
-
isMapWide: () => true,
|
|
81
|
-
popup: { hasAttribute: () => false },
|
|
82
|
-
};
|
|
83
|
-
const uh = new URLHandler(v);
|
|
84
|
-
uh.currentMapString = () => "18/0.5/-12";
|
|
85
|
-
expect(uh.nextURLString()).toBe("?focus=map&map=18/0.5/-12&users=default");
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("works with map + picture wide", () => {
|
|
89
|
-
const v = {
|
|
90
|
-
addEventListener: jest.fn(),
|
|
91
|
-
psv: {
|
|
92
|
-
getPicturesNavigation: () => null,
|
|
93
|
-
getTransitionDuration: () => null,
|
|
94
|
-
getPictureMetadata: () => ({}),
|
|
95
|
-
getPictureId: () => "cbfc3add-8173-4464-98c8-de2a43c6a50f",
|
|
96
|
-
getSelectedAnnotations: () => [],
|
|
97
|
-
},
|
|
98
|
-
map: {
|
|
99
|
-
loaded: () => true,
|
|
100
|
-
},
|
|
101
|
-
mapStyleComposer: {
|
|
102
|
-
hasManyBasemaps: () => false,
|
|
103
|
-
basemap: "streets",
|
|
104
|
-
panoramax: "default",
|
|
105
|
-
},
|
|
106
|
-
isMapWide: () => false,
|
|
107
|
-
popup: { hasAttribute: () => false },
|
|
108
|
-
};
|
|
109
|
-
const uh = new URLHandler(v);
|
|
110
|
-
uh.currentPSVString = () => "0/1/2";
|
|
111
|
-
uh.currentMapString = () => "18/0.5/-12";
|
|
112
|
-
expect(uh.nextURLString()).toBe("?focus=pic&map=18/0.5/-12&pic=cbfc3add-8173-4464-98c8-de2a43c6a50f&users=default&xyz=0/1/2");
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("works with map filters", () => {
|
|
116
|
-
const v = {
|
|
117
|
-
addEventListener: jest.fn(),
|
|
118
|
-
psv: {
|
|
119
|
-
getPicturesNavigation: () => null,
|
|
120
|
-
getTransitionDuration: () => null,
|
|
121
|
-
getPictureMetadata: () => null,
|
|
122
|
-
getPictureId: () => null,
|
|
123
|
-
getSelectedAnnotations: () => [],
|
|
124
|
-
},
|
|
125
|
-
map: {
|
|
126
|
-
loaded: () => true,
|
|
127
|
-
},
|
|
128
|
-
mapStyleComposer: {
|
|
129
|
-
hasManyBasemaps: () => false,
|
|
130
|
-
basemap: "streets",
|
|
131
|
-
panoramax: "default",
|
|
132
|
-
panoramaxFilters: {
|
|
133
|
-
"minDate": "2023-01-01",
|
|
134
|
-
"maxDate": "2023-08-08",
|
|
135
|
-
"camera": "sony",
|
|
136
|
-
"pic_type": "flat",
|
|
137
|
-
"theme": "age",
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
isMapWide: () => false,
|
|
141
|
-
popup: { hasAttribute: () => false },
|
|
142
|
-
};
|
|
143
|
-
const uh = new URLHandler(v);
|
|
144
|
-
uh.currentMapString = () => "18/0.5/-12";
|
|
145
|
-
expect(uh.nextURLString()).toBe("?camera=sony&date_from=2023-01-01&date_to=2023-08-08&focus=pic&map=18/0.5/-12&pic_type=flat&theme=age&users=default");
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it("works with speed", () => {
|
|
149
|
-
const v = {
|
|
150
|
-
addEventListener: jest.fn(),
|
|
151
|
-
psv: {
|
|
152
|
-
getPicturesNavigation: () => null,
|
|
153
|
-
getTransitionDuration: () => 250,
|
|
154
|
-
getPictureMetadata: () => null,
|
|
155
|
-
getPictureId: () => null,
|
|
156
|
-
getSelectedAnnotations: () => [],
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
const uh = new URLHandler(v);
|
|
160
|
-
expect(uh.nextURLString()).toBe("?speed=250");
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it("works with popup", () => {
|
|
164
|
-
const v = {
|
|
165
|
-
addEventListener: jest.fn(),
|
|
166
|
-
psv: {
|
|
167
|
-
getPicturesNavigation: () => null,
|
|
168
|
-
getTransitionDuration: () => null,
|
|
169
|
-
getPictureMetadata: () => null,
|
|
170
|
-
getPictureId: () => null,
|
|
171
|
-
getSelectedAnnotations: () => [],
|
|
172
|
-
},
|
|
173
|
-
map: {
|
|
174
|
-
loaded: () => true,
|
|
175
|
-
},
|
|
176
|
-
mapStyleComposer: {
|
|
177
|
-
hasManyBasemaps: () => false,
|
|
178
|
-
basemap: "streets",
|
|
179
|
-
panoramax: "default",
|
|
180
|
-
},
|
|
181
|
-
isMapWide: () => false,
|
|
182
|
-
popup: { hasAttribute: () => true },
|
|
183
|
-
};
|
|
184
|
-
const uh = new URLHandler(v);
|
|
185
|
-
uh.currentMapString = () => "18/0.5/-12";
|
|
186
|
-
expect(uh.nextURLString()).toBe("?focus=pic&map=18/0.5/-12&users=default");
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it("works with nav", () => {
|
|
190
|
-
const v = {
|
|
191
|
-
addEventListener: jest.fn(),
|
|
192
|
-
psv: {
|
|
193
|
-
getPicturesNavigation: () => "pic",
|
|
194
|
-
getTransitionDuration: () => null,
|
|
195
|
-
getPictureMetadata: () => null,
|
|
196
|
-
getPictureId: () => null,
|
|
197
|
-
getSelectedAnnotations: () => [],
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
const uh = new URLHandler(v);
|
|
201
|
-
expect(uh.nextURLString()).toBe("?nav=pic");
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it("works with annotation", () => {
|
|
205
|
-
const v = {
|
|
206
|
-
addEventListener: jest.fn(),
|
|
207
|
-
psv: {
|
|
208
|
-
getPicturesNavigation: () => null,
|
|
209
|
-
getTransitionDuration: () => null,
|
|
210
|
-
getPictureMetadata: () => null,
|
|
211
|
-
getPictureId: () => null,
|
|
212
|
-
getSelectedAnnotations: () => ["123456789"],
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
const uh = new URLHandler(v);
|
|
216
|
-
expect(uh.nextURLString()).toBe("?annot=123456789");
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it("works with overlay", () => {
|
|
220
|
-
const v = {
|
|
221
|
-
addEventListener: jest.fn(),
|
|
222
|
-
psv: {
|
|
223
|
-
getPicturesNavigation: () => null,
|
|
224
|
-
getTransitionDuration: () => null,
|
|
225
|
-
getPictureMetadata: () => null,
|
|
226
|
-
getPictureId: () => null,
|
|
227
|
-
getSelectedAnnotations: () => [],
|
|
228
|
-
},
|
|
229
|
-
map: {
|
|
230
|
-
loaded: () => true,
|
|
231
|
-
getSemanticOverlays: () => [{id: "b1", source: "s1"}, {id: "b2", source: "s2"}],
|
|
232
|
-
},
|
|
233
|
-
mapStyleComposer: {
|
|
234
|
-
hasManyBasemaps: () => false,
|
|
235
|
-
basemap: "streets",
|
|
236
|
-
panoramax: "default",
|
|
237
|
-
dataOverlays: new Set(["s1", "s2"]),
|
|
238
|
-
},
|
|
239
|
-
isMapWide: () => false,
|
|
240
|
-
popup: { hasAttribute: () => false },
|
|
241
|
-
};
|
|
242
|
-
const uh = new URLHandler(v);
|
|
243
|
-
uh.currentMapString = () => "18/0.5/-12";
|
|
244
|
-
expect(uh.nextURLString()).toBe("?focus=pic&map=18/0.5/-12&overlay=b1,b2&users=default");
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it("works with level", () => {
|
|
248
|
-
const v = {
|
|
249
|
-
addEventListener: jest.fn(),
|
|
250
|
-
psv: {
|
|
251
|
-
getPicturesNavigation: () => null,
|
|
252
|
-
getTransitionDuration: () => null,
|
|
253
|
-
getPictureMetadata: () => null,
|
|
254
|
-
getPictureId: () => null,
|
|
255
|
-
getSelectedAnnotations: () => [],
|
|
256
|
-
},
|
|
257
|
-
map: {
|
|
258
|
-
loaded: () => true,
|
|
259
|
-
getSemanticOverlays: () => [{id: "levels", source: "sem-levels"}],
|
|
260
|
-
indoorEqual: {
|
|
261
|
-
level: "3"
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
mapStyleComposer: {
|
|
265
|
-
hasManyBasemaps: () => false,
|
|
266
|
-
basemap: "streets",
|
|
267
|
-
panoramax: "default",
|
|
268
|
-
dataOverlays: new Set(["sem-levels"]),
|
|
269
|
-
},
|
|
270
|
-
isMapWide: () => false,
|
|
271
|
-
popup: { hasAttribute: () => false },
|
|
272
|
-
};
|
|
273
|
-
const uh = new URLHandler(v);
|
|
274
|
-
uh.currentMapString = () => "18/0.5/-12";
|
|
275
|
-
expect(uh.nextURLString()).toBe("?focus=pic&level=3&map=18/0.5/-12&overlay=levels&users=default");
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
it("works with background", () => {
|
|
279
|
-
const v = {
|
|
280
|
-
addEventListener: jest.fn(),
|
|
281
|
-
psv: {
|
|
282
|
-
getPicturesNavigation: () => null,
|
|
283
|
-
getTransitionDuration: () => null,
|
|
284
|
-
getPictureMetadata: () => null,
|
|
285
|
-
getPictureId: () => null,
|
|
286
|
-
getSelectedAnnotations: () => [],
|
|
287
|
-
},
|
|
288
|
-
map: {
|
|
289
|
-
loaded: () => true,
|
|
290
|
-
},
|
|
291
|
-
mapStyleComposer: {
|
|
292
|
-
hasManyBasemaps: () => true,
|
|
293
|
-
basemap: "streets",
|
|
294
|
-
panoramax: "default",
|
|
295
|
-
},
|
|
296
|
-
isMapWide: () => true,
|
|
297
|
-
popup: { hasAttribute: () => false },
|
|
298
|
-
};
|
|
299
|
-
const uh = new URLHandler(v);
|
|
300
|
-
uh.currentMapString = () => "18/0.5/-12";
|
|
301
|
-
expect(uh.nextURLString()).toBe("?background=streets&focus=map&map=18/0.5/-12&users=default");
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
describe("currentURLParams", () => {
|
|
306
|
-
it("works if empty + search", () => {
|
|
307
|
-
delete window.location;
|
|
308
|
-
window.location = { search: "" };
|
|
309
|
-
const v = { addEventListener: jest.fn() };
|
|
310
|
-
const uh = new URLHandler(v);
|
|
311
|
-
expect(uh.currentURLParams()).toStrictEqual({});
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
it("works with single param + search", () => {
|
|
315
|
-
delete window.location;
|
|
316
|
-
window.location = { search: "?nav=pic" };
|
|
317
|
-
const v = { addEventListener: jest.fn() };
|
|
318
|
-
const uh = new URLHandler(v);
|
|
319
|
-
expect(uh.currentURLParams()).toStrictEqual({"nav": "pic"});
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it("works with multiple params + search", () => {
|
|
323
|
-
delete window.location;
|
|
324
|
-
window.location = { search: "?nav=pic&speed=42" };
|
|
325
|
-
const v = { addEventListener: jest.fn() };
|
|
326
|
-
const uh = new URLHandler(v);
|
|
327
|
-
expect(uh.currentURLParams()).toStrictEqual({"nav": "pic", "speed": "42"});
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
it("works with urlEncoded &", () => {
|
|
331
|
-
delete window.location;
|
|
332
|
-
window.location = { search: "?nav=pic&speed=42" };
|
|
333
|
-
const v = { addEventListener: jest.fn() };
|
|
334
|
-
const uh = new URLHandler(v);
|
|
335
|
-
expect(uh.currentURLParams()).toStrictEqual({"nav": "pic", "speed": "42"});
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
it("works if empty + hash", () => {
|
|
339
|
-
delete window.location;
|
|
340
|
-
window.location = { hash: "" };
|
|
341
|
-
const v = { addEventListener: jest.fn() };
|
|
342
|
-
const uh = new URLHandler(v);
|
|
343
|
-
expect(uh.currentURLParams(true)).toStrictEqual({});
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
it("works with single param + hash", () => {
|
|
347
|
-
delete window.location;
|
|
348
|
-
window.location = { hash: "#nav=pic" };
|
|
349
|
-
const v = { addEventListener: jest.fn() };
|
|
350
|
-
const uh = new URLHandler(v);
|
|
351
|
-
expect(uh.currentURLParams(true)).toStrictEqual({"nav": "pic"});
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
it("works with multiple params + hash", () => {
|
|
355
|
-
delete window.location;
|
|
356
|
-
window.location = { hash: "#nav=pic&speed=42" };
|
|
357
|
-
const v = { addEventListener: jest.fn() };
|
|
358
|
-
const uh = new URLHandler(v);
|
|
359
|
-
expect(uh.currentURLParams(true)).toStrictEqual({"nav": "pic", "speed": "42"});
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
it("works with search + hash", () => {
|
|
363
|
-
delete window.location;
|
|
364
|
-
window.location = { hash: "#nav=pic&speed=42", search: "?pic=bla" };
|
|
365
|
-
const v = { addEventListener: jest.fn() };
|
|
366
|
-
const uh = new URLHandler(v);
|
|
367
|
-
expect(uh.currentURLParams()).toStrictEqual({"pic": "bla"});
|
|
368
|
-
expect(uh.currentURLParams(true)).toStrictEqual({"nav": "pic", "speed": "42"});
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
it("skips unmanaged parameters", () => {
|
|
372
|
-
delete window.location;
|
|
373
|
-
window.location = { search: "?a=b" };
|
|
374
|
-
const v = { addEventListener: jest.fn() };
|
|
375
|
-
const uh = new URLHandler(v);
|
|
376
|
-
expect(uh.currentURLParams()).toStrictEqual({});
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
it("works with shortlinks", () => {
|
|
380
|
-
delete window.location;
|
|
381
|
-
window.location = { search: "?s=a123456789;fp;s2;pa0270208-d79d-49a9-85c7-a352bb96962e;c282.09/9.34/30;m17/43.107492/5.868459;va;bs;oblabla;l-1" };
|
|
382
|
-
const v = { addEventListener: jest.fn() };
|
|
383
|
-
const uh = new URLHandler(v);
|
|
384
|
-
expect(uh.currentURLParams()).toStrictEqual({
|
|
385
|
-
"annot": "123456789",
|
|
386
|
-
"focus": "pic",
|
|
387
|
-
"speed": 200,
|
|
388
|
-
"pic": "a0270208-d79d-49a9-85c7-a352bb96962e",
|
|
389
|
-
"xyz": "282.09/9.34/30",
|
|
390
|
-
"map": "17/43.107492/5.868459",
|
|
391
|
-
"theme": "age",
|
|
392
|
-
"background": "streets",
|
|
393
|
-
"camera": undefined,
|
|
394
|
-
"date_from": undefined,
|
|
395
|
-
"date_to": undefined,
|
|
396
|
-
"pic_score": undefined,
|
|
397
|
-
"users": undefined,
|
|
398
|
-
"gps": undefined,
|
|
399
|
-
"overlay": "blabla",
|
|
400
|
-
"level": "-1",
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
it("works with shortlinks urlEncoded", () => {
|
|
405
|
-
delete window.location;
|
|
406
|
-
window.location = { search: "?s=fp%3Bs2%3Bpa0270208-d79d-49a9-85c7-a352bb96962e%3Bc282.09/9.34/30%3Bm17/43.107492/5.868459%3Bva%3Bbs%3Botfsign,blabla%3Bl2" };
|
|
407
|
-
const v = { addEventListener: jest.fn() };
|
|
408
|
-
const uh = new URLHandler(v);
|
|
409
|
-
expect(uh.currentURLParams()).toStrictEqual({
|
|
410
|
-
"annot": undefined,
|
|
411
|
-
"focus": "pic",
|
|
412
|
-
"speed": 200,
|
|
413
|
-
"pic": "a0270208-d79d-49a9-85c7-a352bb96962e",
|
|
414
|
-
"xyz": "282.09/9.34/30",
|
|
415
|
-
"map": "17/43.107492/5.868459",
|
|
416
|
-
"theme": "age",
|
|
417
|
-
"background": "streets",
|
|
418
|
-
"camera": undefined,
|
|
419
|
-
"date_from": undefined,
|
|
420
|
-
"date_to": undefined,
|
|
421
|
-
"pic_score": undefined,
|
|
422
|
-
"users": undefined,
|
|
423
|
-
"gps": undefined,
|
|
424
|
-
"overlay": "tfsign,blabla",
|
|
425
|
-
"level": "2",
|
|
426
|
-
});
|
|
427
|
-
});
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
describe("currentMapString", () => {
|
|
431
|
-
it("works with zoom+center", () => {
|
|
432
|
-
const v = {
|
|
433
|
-
addEventListener: jest.fn(),
|
|
434
|
-
map: {
|
|
435
|
-
loaded: () => true,
|
|
436
|
-
getZoom: () => 18,
|
|
437
|
-
getCenter: () => ({ lng: -12.5, lat: 48.75 }),
|
|
438
|
-
getBearing: () => null,
|
|
439
|
-
getPitch: () => null,
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
const uh = new URLHandler(v);
|
|
443
|
-
expect(uh.currentMapString()).toBe("18/48.75/-12.5");
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
it("works with zoom+center+bearing", () => {
|
|
447
|
-
const v = {
|
|
448
|
-
addEventListener: jest.fn(),
|
|
449
|
-
map: {
|
|
450
|
-
loaded: () => true,
|
|
451
|
-
getZoom: () => 18,
|
|
452
|
-
getCenter: () => ({ lng: -12.5, lat: 48.75 }),
|
|
453
|
-
getBearing: () => 12,
|
|
454
|
-
getPitch: () => null,
|
|
455
|
-
}
|
|
456
|
-
};
|
|
457
|
-
const uh = new URLHandler(v);
|
|
458
|
-
expect(uh.currentMapString()).toBe("18/48.75/-12.5/12");
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
it("works with zoom+center+pitch", () => {
|
|
462
|
-
const v = {
|
|
463
|
-
addEventListener: jest.fn(),
|
|
464
|
-
map: {
|
|
465
|
-
loaded: () => true,
|
|
466
|
-
getZoom: () => 18,
|
|
467
|
-
getCenter: () => ({ lng: -12.5, lat: 48.75 }),
|
|
468
|
-
getBearing: () => null,
|
|
469
|
-
getPitch: () => 65,
|
|
470
|
-
},
|
|
471
|
-
};
|
|
472
|
-
const uh = new URLHandler(v);
|
|
473
|
-
expect(uh.currentMapString()).toBe("18/48.75/-12.5/0/65");
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
it("works with zoom+center+bearing+pitch", () => {
|
|
477
|
-
const v = {
|
|
478
|
-
addEventListener: jest.fn(),
|
|
479
|
-
map: {
|
|
480
|
-
loaded: () => true,
|
|
481
|
-
getZoom: () => 18,
|
|
482
|
-
getCenter: () => ({ lng: -12.5, lat: 48.75 }),
|
|
483
|
-
getBearing: () => 42,
|
|
484
|
-
getPitch: () => 65,
|
|
485
|
-
},
|
|
486
|
-
};
|
|
487
|
-
const uh = new URLHandler(v);
|
|
488
|
-
expect(uh.currentMapString()).toBe("18/48.75/-12.5/42/65");
|
|
489
|
-
});
|
|
490
|
-
});
|
|
491
|
-
|
|
492
|
-
describe("currentPSVString", () => {
|
|
493
|
-
it("works", () => {
|
|
494
|
-
const v = {
|
|
495
|
-
addEventListener: jest.fn(),
|
|
496
|
-
psv: {
|
|
497
|
-
getXYZ: () => ({ x: 12, y: 50, z: 75 }),
|
|
498
|
-
},
|
|
499
|
-
};
|
|
500
|
-
const uh = new URLHandler(v);
|
|
501
|
-
expect(uh.currentPSVString()).toBe("12.00/50.00/75");
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
it("rounds to 2 decimals", () => {
|
|
505
|
-
const v = {
|
|
506
|
-
addEventListener: jest.fn(),
|
|
507
|
-
psv: {
|
|
508
|
-
getXYZ: () => ({ x: 12.123456, y: 50.789456, z: 75 }),
|
|
509
|
-
getPictureId: () => null,
|
|
510
|
-
},
|
|
511
|
-
};
|
|
512
|
-
const uh = new URLHandler(v);
|
|
513
|
-
expect(uh.currentPSVString()).toBe("12.12/50.79/75");
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
it("works without z", () => {
|
|
517
|
-
const v = {
|
|
518
|
-
addEventListener: jest.fn(),
|
|
519
|
-
psv: {
|
|
520
|
-
getXYZ: () => ({ x: 12, y: 50 }),
|
|
521
|
-
getPictureId: () => null,
|
|
522
|
-
},
|
|
523
|
-
};
|
|
524
|
-
const uh = new URLHandler(v);
|
|
525
|
-
expect(uh.currentPSVString()).toBe("12.00/50.00/0");
|
|
526
|
-
});
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
describe("_onParentChange", () => {
|
|
530
|
-
it("works", async () => {
|
|
531
|
-
delete window.history;
|
|
532
|
-
delete window.location;
|
|
533
|
-
|
|
534
|
-
window.history = { replaceState: jest.fn(), state: {} };
|
|
535
|
-
window.location = { href: "http://localhost:5000/?nav=pic&speed=2", search: "?nav=pic&speed=2", hash: "" };
|
|
536
|
-
|
|
537
|
-
const v = { addEventListener: jest.fn() };
|
|
538
|
-
const uh = new URLHandler(v);
|
|
539
|
-
uh.nextURLString = () => "?map=1/2/3";
|
|
540
|
-
uh.dispatchEvent = jest.fn();
|
|
541
|
-
|
|
542
|
-
uh._onParentChange();
|
|
543
|
-
await new Promise((r) => setTimeout(r, 1000));
|
|
544
|
-
|
|
545
|
-
expect(window.history.replaceState.mock.calls.pop()).toEqual([{}, null, "http://localhost:5000/?map=1/2/3"]);
|
|
546
|
-
expect(uh.dispatchEvent.mock.calls).toMatchSnapshot();
|
|
547
|
-
});
|
|
548
|
-
|
|
549
|
-
it("works with pic change", async () => {
|
|
550
|
-
delete window.history;
|
|
551
|
-
delete window.location;
|
|
552
|
-
|
|
553
|
-
window.history = { pushState: jest.fn(), state: {} };
|
|
554
|
-
window.location = { href: "http://localhost:5000/?pic=bla", search: "?pic=bla", hash: "" };
|
|
555
|
-
|
|
556
|
-
const v = { addEventListener: jest.fn() };
|
|
557
|
-
const uh = new URLHandler(v);
|
|
558
|
-
uh.nextURLString = () => "?nav=seq";
|
|
559
|
-
uh.dispatchEvent = jest.fn();
|
|
560
|
-
|
|
561
|
-
uh._onParentChange();
|
|
562
|
-
await new Promise((r) => setTimeout(r, 1000));
|
|
563
|
-
|
|
564
|
-
expect(window.history.pushState.mock.calls.pop()).toEqual([{}, null, "http://localhost:5000/?nav=seq"]);
|
|
565
|
-
expect(uh.dispatchEvent.mock.calls).toMatchSnapshot();
|
|
566
|
-
});
|
|
567
|
-
|
|
568
|
-
it("deduplicates calls", async () => {
|
|
569
|
-
delete window.history;
|
|
570
|
-
delete window.location;
|
|
571
|
-
|
|
572
|
-
window.history = { replaceState: jest.fn(), state: {} };
|
|
573
|
-
window.location = { href: "http://localhost:5000/?speed=1&nav=seq", search: "?speed=1&nav=seq", hash: "" };
|
|
574
|
-
|
|
575
|
-
const v = { addEventListener: jest.fn() };
|
|
576
|
-
const uh = new URLHandler(v);
|
|
577
|
-
uh.nextURLString = () => "?map=1/2/3";
|
|
578
|
-
|
|
579
|
-
for(let i=0; i <= 10; i++) {
|
|
580
|
-
uh._onParentChange();
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
await new Promise((r) => setTimeout(r, 1000));
|
|
584
|
-
|
|
585
|
-
expect(window.history.replaceState.mock.calls).toEqual([[{}, null, "http://localhost:5000/?map=1/2/3"]]);
|
|
586
|
-
});
|
|
587
|
-
});
|