@panoramax/web-viewer 4.4.0-develop-3839b5a4 → 4.4.0-develop-f91f6758
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,174 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
decodeKey, decodeBasicTag, computeDiffTags, groupByPrefix
|
|
3
|
-
} from "../../src/utils/semantics";
|
|
4
|
-
|
|
5
|
-
describe("decodeBasicTag", () => {
|
|
6
|
-
it("should return null if no equal sign is present", () => {
|
|
7
|
-
expect(decodeBasicTag("key")).toBeNull();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("should correctly decode a tag with an equal sign", () => {
|
|
11
|
-
expect(decodeBasicTag("key=value")).toEqual({
|
|
12
|
-
key: { key: "key", prefix: "", subkey: "key", qualifies: null },
|
|
13
|
-
value: "value"
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should correctly decode a tag with a prefix", () => {
|
|
18
|
-
expect(decodeBasicTag("osm|key=value")).toEqual({
|
|
19
|
-
key: { key: "osm|key", prefix: "osm", subkey: "key", qualifies: null },
|
|
20
|
-
value: "value"
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe("decodeKey", () => {
|
|
26
|
-
it("should return default structure if key does not match regex", () => {
|
|
27
|
-
expect(decodeKey("panoKey")).toEqual({
|
|
28
|
-
key: "panoKey",
|
|
29
|
-
prefix: "",
|
|
30
|
-
subkey: "panoKey",
|
|
31
|
-
qualifies: null
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("should correctly decode a key with a prefix", () => {
|
|
36
|
-
expect(decodeKey("osm|traffic_sign")).toEqual({
|
|
37
|
-
key: "osm|traffic_sign",
|
|
38
|
-
prefix: "osm",
|
|
39
|
-
subkey: "traffic_sign",
|
|
40
|
-
qualifies: null
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("should correctly decode a key with qualifiers", () => {
|
|
45
|
-
expect(decodeKey("detection_model[camera_mount=pole]")).toEqual({
|
|
46
|
-
key: "detection_model[camera_mount=pole]",
|
|
47
|
-
prefix: "",
|
|
48
|
-
subkey: "detection_model",
|
|
49
|
-
qualifies: { key: { key: "camera_mount", prefix: "", subkey: "camera_mount", qualifies: null }, value: "pole" }
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("should correctly decode a key with a prefix and qualifiers", () => {
|
|
54
|
-
expect(decodeKey("osm|source[osm|traffic_sign=stop]")).toEqual({
|
|
55
|
-
key: "osm|source[osm|traffic_sign=stop]",
|
|
56
|
-
prefix: "osm",
|
|
57
|
-
subkey: "source",
|
|
58
|
-
qualifies: { key: { key: "osm|traffic_sign", prefix: "osm", subkey: "traffic_sign", qualifies: null }, value: "stop" }
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe("computeDiffTags", () => {
|
|
64
|
-
it("should return new set of tags when no tag is missing in next", () => {
|
|
65
|
-
const prev = [{key: "tag1", value: "value1"}, {key: "tag2", value: "value2"}];
|
|
66
|
-
const next = [{key: "tag1", value: "value1"}, {key: "tag2", value: "value2"}, {key: "tag3", value: "value3"}];
|
|
67
|
-
|
|
68
|
-
expect(computeDiffTags(prev, next)).toEqual([{key: "tag3", value: "value3", action: "add"}]);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("should return new set of tags with missing tags marked as delete when some tag is missing in next", () => {
|
|
72
|
-
const prev = [{key: "tag1", value: "value1"}, {key: "tag2", value: "value2"}];
|
|
73
|
-
const next = [{key: "tag1", value: "value1"}];
|
|
74
|
-
|
|
75
|
-
expect(computeDiffTags(prev, next)).toEqual([{key: "tag2", value: "value2", action: "delete"}]);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("should return new set of tags with all tags marked as delete when all tags are missing in next", () => {
|
|
79
|
-
const prev = [{key: "tag1", value: "value1"}, {key: "tag2", value: "value2"}];
|
|
80
|
-
const next = [];
|
|
81
|
-
|
|
82
|
-
expect(computeDiffTags(prev, next)).toEqual([{key: "tag1", value: "value1", action: "delete"}, {key: "tag2", value: "value2", action: "delete"}]);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
describe("groupByPrefix", () => {
|
|
87
|
-
it("should group tags by prefix", () => {
|
|
88
|
-
const tags = [
|
|
89
|
-
{ key: "osm|highway", value: "residential" },
|
|
90
|
-
{ key: "wd|P31", value: "Q5" },
|
|
91
|
-
{ key: "exif|model", value: "CameraModel" }
|
|
92
|
-
];
|
|
93
|
-
|
|
94
|
-
const expected = [
|
|
95
|
-
{
|
|
96
|
-
prefix: "osm",
|
|
97
|
-
title: "OpenStreetMap",
|
|
98
|
-
tags: [{ key: "highway", value: "residential" }],
|
|
99
|
-
key_transform: expect.any(Function),
|
|
100
|
-
logo: "osm.svg",
|
|
101
|
-
value_transform: expect.any(Function)
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
prefix: "wd",
|
|
105
|
-
title: "Wikidata",
|
|
106
|
-
tags: [{ key: "P31", value: "Q5" }],
|
|
107
|
-
key_transform: expect.any(Function),
|
|
108
|
-
logo: "wd.svg",
|
|
109
|
-
value_transform: expect.any(Function)
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
prefix: "exif",
|
|
113
|
-
title: "EXIF",
|
|
114
|
-
tags: [{ key: "model", value: "CameraModel" }]
|
|
115
|
-
}
|
|
116
|
-
];
|
|
117
|
-
|
|
118
|
-
expect(groupByPrefix(tags)).toEqual(expected);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it("should handle qualifiers without prefix correctly", () => {
|
|
122
|
-
const tags = [
|
|
123
|
-
{ key: "transport", value: "bike" },
|
|
124
|
-
{ key: "source[transport=bike]", value: "author" }
|
|
125
|
-
];
|
|
126
|
-
|
|
127
|
-
const expected = [{
|
|
128
|
-
prefix: "",
|
|
129
|
-
title: "Panoramax",
|
|
130
|
-
tags: [{
|
|
131
|
-
key: "transport",
|
|
132
|
-
value: "bike",
|
|
133
|
-
qualifiers: [{ key: "source[transport=bike]", prefix: "", subkey: "source", value: "author" }]
|
|
134
|
-
}],
|
|
135
|
-
value_transform: expect.any(Function)
|
|
136
|
-
}];
|
|
137
|
-
|
|
138
|
-
expect(groupByPrefix(tags)).toEqual(expected);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("should handle qualifiers with prefix correctly", () => {
|
|
142
|
-
const tags = [
|
|
143
|
-
{ key: "osm|highway", value: "residential" },
|
|
144
|
-
{ key: "osm|source[osm|highway=residential]", value: "opendata" }
|
|
145
|
-
];
|
|
146
|
-
|
|
147
|
-
const expected = [{
|
|
148
|
-
prefix: "osm",
|
|
149
|
-
title: "OpenStreetMap",
|
|
150
|
-
tags: [{
|
|
151
|
-
key: "highway",
|
|
152
|
-
value: "residential",
|
|
153
|
-
qualifiers: [{ key: "osm|source[osm|highway=residential]", prefix: "osm", subkey: "source", value: "opendata" }]
|
|
154
|
-
}],
|
|
155
|
-
key_transform: expect.any(Function),
|
|
156
|
-
logo: "osm.svg",
|
|
157
|
-
value_transform: expect.any(Function)
|
|
158
|
-
}];
|
|
159
|
-
|
|
160
|
-
expect(groupByPrefix(tags)).toEqual(expected);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it("should handle unknown prefixes", () => {
|
|
164
|
-
const tags = [ { key: "unknown|key", value: "value" } ];
|
|
165
|
-
|
|
166
|
-
const expected = [{
|
|
167
|
-
prefix: "unknown",
|
|
168
|
-
title: "unknown",
|
|
169
|
-
tags: [{ key: "key", value: "value" }]
|
|
170
|
-
}];
|
|
171
|
-
|
|
172
|
-
expect(groupByPrefix(tags)).toEqual(expected);
|
|
173
|
-
});
|
|
174
|
-
});
|
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
import * as utils from "../../src/utils/utils";
|
|
2
|
-
|
|
3
|
-
jest.mock("../../src/utils/map", () => ({
|
|
4
|
-
COLORS_HEX: {
|
|
5
|
-
SELECTED: 0x0000ff,
|
|
6
|
-
}
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
describe("getGrade", () => {
|
|
10
|
-
it("works with null-like", () => {
|
|
11
|
-
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, null)).toBeNull();
|
|
12
|
-
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, undefined)).toBeNull();
|
|
13
|
-
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, "")).toBeNull();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("works with grade values", () => {
|
|
17
|
-
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, 0)).toBe(1);
|
|
18
|
-
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, 5)).toBe(1);
|
|
19
|
-
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, 12)).toBe(2);
|
|
20
|
-
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, 25)).toBe(3);
|
|
21
|
-
expect(utils.getGrade(utils.QUALITYSCORE_RES_FLAT_VALUES, 40)).toBe(4);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe("getDistance", () => {
|
|
26
|
-
it("works", () => {
|
|
27
|
-
const p1 = [1,1];
|
|
28
|
-
const p2 = [2,2];
|
|
29
|
-
const res = utils.getDistance(p1, p2);
|
|
30
|
-
expect(res).toBe(Math.sqrt(2));
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe("svgToPSVLink", () => {
|
|
35
|
-
it("works", () => {
|
|
36
|
-
const base64Svg = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnPjxjaXJjbGUgY3g9JzUnIGN5PSc1JyByPSc1JyBmaWxsPScjMDAwJy8+PC9zdmc+";
|
|
37
|
-
const fillColor = "red";
|
|
38
|
-
const result = utils.svgToPSVLink(base64Svg, fillColor);
|
|
39
|
-
|
|
40
|
-
expect(result).toBeInstanceOf(HTMLButtonElement);
|
|
41
|
-
expect(result.classList.contains("pnx-psv-tour-arrows")).toBe(true);
|
|
42
|
-
expect(result.style.color).toBe(fillColor);
|
|
43
|
-
expect(result.querySelector("svg")).not.toBeNull();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("works with invalid input", () => {
|
|
47
|
-
const invalidBase64Svg = "http://test.net/invalid_string";
|
|
48
|
-
const result = utils.svgToPSVLink(invalidBase64Svg, "blue");
|
|
49
|
-
|
|
50
|
-
expect(result).toBeInstanceOf(HTMLImageElement);
|
|
51
|
-
expect(result.src).toBe(invalidBase64Svg);
|
|
52
|
-
expect(result.alt).toBe("");
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe("getAzimuth", () => {
|
|
57
|
-
it("works with 0 + NE", () => {
|
|
58
|
-
const pointDepart = [0, 0];
|
|
59
|
-
const pointArrivee = [1, 1];
|
|
60
|
-
const azimuth = utils.getAzimuth(pointDepart, pointArrivee);
|
|
61
|
-
expect(azimuth).toBe(45);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("works with 0 + SE", () => {
|
|
65
|
-
const pointDepart = [0, 0];
|
|
66
|
-
const pointArrivee = [1, -1];
|
|
67
|
-
const azimuth = utils.getAzimuth(pointDepart, pointArrivee);
|
|
68
|
-
expect(azimuth).toBe(135);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("works with 0 + N", () => {
|
|
72
|
-
const pointDepart = [0, 0];
|
|
73
|
-
const pointArrivee = [0, 1];
|
|
74
|
-
const azimuth = utils.getAzimuth(pointDepart, pointArrivee);
|
|
75
|
-
expect(azimuth).toBe(0);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("works with 0 + S", () => {
|
|
79
|
-
const pointDepart = [0, 0];
|
|
80
|
-
const pointArrivee = [0, -1];
|
|
81
|
-
const azimuth = utils.getAzimuth(pointDepart, pointArrivee);
|
|
82
|
-
expect(azimuth).toBe(180);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
describe("getRoadAbsoluteHeading", () => {
|
|
87
|
-
it("works with single picture", () => {
|
|
88
|
-
const pm = {
|
|
89
|
-
gps: [0, 0]
|
|
90
|
-
};
|
|
91
|
-
expect(utils.getRoadAbsoluteHeading(pm)).toEqual(0);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it("works with first picture", () => {
|
|
95
|
-
const pm = {
|
|
96
|
-
sequence: { nextPic: "nextPictureId" },
|
|
97
|
-
links: [
|
|
98
|
-
{ nodeId: "nextPictureId", gps: [0, 2] }
|
|
99
|
-
],
|
|
100
|
-
gps: [1, 1]
|
|
101
|
-
};
|
|
102
|
-
expect(utils.getRoadAbsoluteHeading(pm)).toEqual(315);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("works with last picture", () => {
|
|
106
|
-
const pm = {
|
|
107
|
-
sequence: { prevPic: "prevPictureId" },
|
|
108
|
-
links: [
|
|
109
|
-
{ nodeId: "prevPictureId", gps: [0, 0] }
|
|
110
|
-
],
|
|
111
|
-
gps: [0, -1]
|
|
112
|
-
};
|
|
113
|
-
expect(utils.getRoadAbsoluteHeading(pm)).toEqual(180);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("works with middle picture", () => {
|
|
117
|
-
const pm = {
|
|
118
|
-
sequence: { prevPic: "prevPictureId", nextPic: "nextPictureId" },
|
|
119
|
-
links: [
|
|
120
|
-
{ nodeId: "prevPictureId", gps: [0, 0] },
|
|
121
|
-
{ nodeId: "nextPictureId", gps: [2, 2] }
|
|
122
|
-
],
|
|
123
|
-
gps: [1, 1]
|
|
124
|
-
};
|
|
125
|
-
expect(utils.getRoadAbsoluteHeading(pm)).toEqual(45);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
describe("getRelativeHeading", () => {
|
|
130
|
-
it("should throw an error if no picture selected", () => {
|
|
131
|
-
expect(() => utils.getRelativeHeading()).toThrow("No picture selected");
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("should calculate relative heading correctly", () => {
|
|
135
|
-
const pictureMetadata = {
|
|
136
|
-
properties: { "view:azimuth": 30 },
|
|
137
|
-
sequence: { prevPic: "prevPictureId", nextPic: "nextPictureId" },
|
|
138
|
-
links: [
|
|
139
|
-
{ nodeId: "prevPictureId", gps: [0, 0] },
|
|
140
|
-
{ nodeId: "nextPictureId", gps: [2, 2] }
|
|
141
|
-
],
|
|
142
|
-
gps: [1, 1]
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
expect(utils.getRelativeHeading(pictureMetadata)).toBe(-15);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it("works looking behind", () => {
|
|
149
|
-
const pictureMetadata = {
|
|
150
|
-
properties: { "view:azimuth": 226 },
|
|
151
|
-
sequence: { prevPic: "prevPictureId", nextPic: "nextPictureId" },
|
|
152
|
-
links: [
|
|
153
|
-
{ nodeId: "prevPictureId", gps: [0, 0] },
|
|
154
|
-
{ nodeId: "nextPictureId", gps: [2, 2] }
|
|
155
|
-
],
|
|
156
|
-
gps: [1, 1]
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
expect(utils.getRelativeHeading(pictureMetadata)).toBe(-179);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("works with distorted path", () => {
|
|
163
|
-
const pictureMetadata = {
|
|
164
|
-
properties: { "view:azimuth": 100 },
|
|
165
|
-
sequence: { prevPic: "prevPictureId", nextPic: "nextPictureId" },
|
|
166
|
-
links: [
|
|
167
|
-
{ nodeId: "prevPictureId", gps: [0, 0] },
|
|
168
|
-
{ nodeId: "nextPictureId", gps: [2, 1] }
|
|
169
|
-
],
|
|
170
|
-
gps: [1, 0]
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
expect(utils.getRelativeHeading(pictureMetadata)).toBe(10);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it("works without previous link", () => {
|
|
177
|
-
const pictureMetadata = {
|
|
178
|
-
properties: { "view:azimuth": 100 },
|
|
179
|
-
sequence: { nextPic: "nextPictureId" },
|
|
180
|
-
links: [
|
|
181
|
-
{ nodeId: "nextPictureId", gps: [2, 1] }
|
|
182
|
-
],
|
|
183
|
-
gps: [1, 1]
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
expect(utils.getRelativeHeading(pictureMetadata)).toBe(10);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it("should handle missing prevPic or nextPic", () => {
|
|
190
|
-
const metadataWithoutPrevNext = {
|
|
191
|
-
properties: { "view:azimuth": 30 },
|
|
192
|
-
gps: [0, 0]
|
|
193
|
-
};
|
|
194
|
-
expect(utils.getRelativeHeading(metadataWithoutPrevNext)).toBe(0);
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
describe("getSimplifiedAngle", () => {
|
|
199
|
-
it("returns \"N\"", () => {
|
|
200
|
-
expect(utils.getSimplifiedAngle([0, 0], [0, 1])).toBe("N");
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it("returns \"ENE\"", () => {
|
|
204
|
-
expect(utils.getSimplifiedAngle([0, 0], [1, 1])).toBe("ENE");
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it("returns \"ESE\"", () => {
|
|
208
|
-
expect(utils.getSimplifiedAngle([0, 0], [1, -1])).toBe("ESE");
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it("returns \"S\"", () => {
|
|
212
|
-
expect(utils.getSimplifiedAngle([0, 0], [0, -1])).toBe("S");
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
it("returns \"WNW\"", () => {
|
|
216
|
-
expect(utils.getSimplifiedAngle([0, 0], [-1, 1])).toBe("WNW");
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it("returns \"WSW\"", () => {
|
|
220
|
-
expect(utils.getSimplifiedAngle([0, 0], [-1, -1])).toBe("WSW");
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
describe("positionToXYZ", () => {
|
|
225
|
-
it("works with xy", () => {
|
|
226
|
-
const r = utils.positionToXYZ({ pitch: 10, yaw: -5 });
|
|
227
|
-
expect(r).toEqual({ x: -286.4788975654116, y: 572.9577951308232 });
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it("works with xyz", () => {
|
|
231
|
-
const r = utils.positionToXYZ({ pitch: 10, yaw: -5 }, 15);
|
|
232
|
-
expect(r).toEqual({ x: -286.4788975654116, y: 572.9577951308232, z: 15 });
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
describe("xyzToPosition", () => {
|
|
237
|
-
it("works with xyz", () => {
|
|
238
|
-
const r = utils.xyzToPosition(-286.4788975654116, 572.9577951308232, 15);
|
|
239
|
-
expect(r).toEqual({ pitch: 10, yaw: -5, zoom: 15 });
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
describe("degToDms", () => {
|
|
244
|
-
it("converts positive decimal degrees to DMS correctly", () => {
|
|
245
|
-
const result = utils.degToDms(45.7896541);
|
|
246
|
-
expect(result).toEqual({ d: 45, m: 47, s: 22.755 });
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it("converts negative decimal degrees to DMS correctly 1", () => {
|
|
250
|
-
const result = utils.degToDms(-12.751234);
|
|
251
|
-
expect(result).toEqual({ d: -12, m: 45, s: 4.442 });
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it("converts negative decimal degrees to DMS correctly 2", () => {
|
|
255
|
-
const result = utils.degToDms(-21.007598);
|
|
256
|
-
expect(result).toEqual({ d: -21, m: 0, s: 27.353 });
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
it("converts zero degrees to DMS correctly", () => {
|
|
260
|
-
const result = utils.degToDms(0);
|
|
261
|
-
expect(result).toEqual({ d: 0, m: 0, s: 0 });
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it("handles integer degrees correctly", () => {
|
|
265
|
-
const result = utils.degToDms(90);
|
|
266
|
-
expect(result).toEqual({ d: 90, m: 0, s: 0 });
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
describe("josmBboxParameters", () => {
|
|
271
|
-
it("works with null-like", () => {
|
|
272
|
-
expect(utils.josmBboxParameters(null)).toBeNull();
|
|
273
|
-
expect(utils.josmBboxParameters(undefined)).toBeNull();
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
it("works without azimuth", () => {
|
|
277
|
-
const meta = { gps: [2.3522, 48.8566] };
|
|
278
|
-
const result = utils.josmBboxParameters(meta);
|
|
279
|
-
expect(result).toBe("left=2.3522&right=2.3522&top=48.8566&bottom=48.8566&changeset_source=Panoramax");
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it("works with azimuth = 0", () => {
|
|
283
|
-
const meta = { gps: [2.3522, 48.8566], properties: { "view:azimuth": 0 } };
|
|
284
|
-
const result = utils.josmBboxParameters(meta);
|
|
285
|
-
expect(result).toBe("left=2.3522&right=2.3524&top=48.8568&bottom=48.8566&changeset_source=Panoramax");
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
it("works with azimuth = 180", () => {
|
|
289
|
-
const meta = { gps: [2.3522, 48.8566], properties: { "view:azimuth": 180 } };
|
|
290
|
-
const result = utils.josmBboxParameters(meta);
|
|
291
|
-
expect(result).toBe("left=2.352&right=2.3524&top=48.8566&bottom=48.8564&changeset_source=Panoramax");
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it("works with azimuth = 90", () => {
|
|
295
|
-
const meta = { gps: [2.3522, 48.8566], properties: { "view:azimuth": 90 } };
|
|
296
|
-
const result = utils.josmBboxParameters(meta);
|
|
297
|
-
expect(result).toBe("left=2.3522&right=2.3524&top=48.8568&bottom=48.8564&changeset_source=Panoramax");
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
it("works with azimuth = 270", () => {
|
|
301
|
-
const meta = { gps: [2.3522, 48.8566], properties: { "view:azimuth": 270 } };
|
|
302
|
-
const result = utils.josmBboxParameters(meta);
|
|
303
|
-
expect(result).toBe("left=2.352&right=2.3522&top=48.8568&bottom=48.8564&changeset_source=Panoramax");
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
describe("getCookie", () => {
|
|
308
|
-
it("should return the value of the specified cookie", () => {
|
|
309
|
-
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("session=abc123");
|
|
310
|
-
expect(utils.getCookie("session")).toBe("abc123");
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
it("should return null if the cookie is not found", () => {
|
|
314
|
-
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("session=abc123");
|
|
315
|
-
expect(utils.getCookie("user_id")).toBeUndefined();
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it("should return the correct value when multiple cookies are set", () => {
|
|
319
|
-
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("session=abc123; user_id=789; user_name=John");
|
|
320
|
-
expect(utils.getCookie("user_id")).toBe("789");
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
it("should return null if cookie with the specified name has no value", () => {
|
|
324
|
-
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("session=; user_id=789");
|
|
325
|
-
expect(utils.getCookie("session")).toBe("");
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
it("should return the correct value when the cookie contains =", () => {
|
|
329
|
-
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("custom_cookie=abc=123");
|
|
330
|
-
expect(utils.getCookie("custom_cookie")).toBe("abc=123");
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
describe("getUserAccount", () => {
|
|
335
|
-
it("should return an object with user id and name when all cookies are present", () => {
|
|
336
|
-
jest.spyOn(document, "cookie", "get").mockReturnValue("session=abc123; user_id=789; user_name=John");
|
|
337
|
-
expect(utils.getUserAccount()).toEqual({ id: "789", name: "John" });
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
it("should return null if session cookie is missing", () => {
|
|
341
|
-
jest.spyOn(document, "cookie", "get").mockReturnValue("user_id=789; user_name=John");
|
|
342
|
-
expect(utils.getUserAccount()).toBeNull();
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
it("should return null if user_id cookie is missing", () => {
|
|
346
|
-
jest.spyOn(document, "cookie", "get").mockReturnValue("session=abc123; user_name=John");
|
|
347
|
-
expect(utils.getUserAccount()).toBeNull();
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
it("should return null if user_name cookie is missing", () => {
|
|
351
|
-
jest.spyOn(document, "cookie", "get").mockReturnValue("session=abc123; user_id=789");
|
|
352
|
-
expect(utils.getUserAccount()).toBeNull();
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
it("should return null if all cookies are missing", () => {
|
|
356
|
-
expect(utils.getUserAccount()).toBeNull();
|
|
357
|
-
});
|
|
358
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { faChevronDown } from "@fortawesome/free-solid-svg-icons/faChevronDown";
|
|
2
|
-
import * as widgets from "../../src/utils/widgets";
|
|
3
|
-
|
|
4
|
-
describe("fa", () => {
|
|
5
|
-
it("works", () => {
|
|
6
|
-
const res = widgets.fa(faChevronDown);
|
|
7
|
-
expect(res).toMatchSnapshot();
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
describe("createWebComp", () => {
|
|
12
|
-
it("works", () => {
|
|
13
|
-
const tag = "custom-element";
|
|
14
|
-
const props = {
|
|
15
|
-
id: "test-id",
|
|
16
|
-
class: "test-class",
|
|
17
|
-
_customProp: "secret",
|
|
18
|
-
fnDoSomething: jest.fn(),
|
|
19
|
-
onClick: jest.fn(),
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const wc = widgets.createWebComp(tag, props);
|
|
23
|
-
|
|
24
|
-
expect(wc).toBeInstanceOf(HTMLElement);
|
|
25
|
-
expect(wc.tagName.toLowerCase()).toBe(tag);
|
|
26
|
-
expect(wc.getAttribute("id")).toBe(props.id);
|
|
27
|
-
expect(wc.getAttribute("class")).toBe(props.class);
|
|
28
|
-
expect(wc._customProp).toBe(props._customProp);
|
|
29
|
-
expect(wc.DoSomething).toBe(props.fnDoSomething);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|