@panoramax/web-viewer 3.2.3 → 4.0.0-develop-39167b4d
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/.gitlab-ci.yml +13 -6
- package/CHANGELOG.md +53 -1
- package/CODE_OF_CONDUCT.md +1 -1
- package/README.md +1 -1
- package/build/editor.html +10 -1
- package/build/index.css +12 -12
- package/build/index.css.map +1 -1
- package/build/index.html +1 -1
- package/build/index.js +2126 -14
- package/build/index.js.map +1 -1
- package/build/map.html +1 -1
- package/build/photo.html +1 -0
- 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/build/viewer.html +12 -1
- package/build/widgets.html +1 -0
- package/config/jest/mocks.js +201 -0
- package/config/paths.js +2 -0
- package/config/webpack.config.js +52 -0
- package/docs/03_URL_settings.md +14 -16
- package/docs/05_Compatibility.md +59 -76
- package/docs/09_Develop.md +46 -11
- package/docs/90_Releases.md +2 -2
- package/docs/images/class_diagram.drawio +60 -45
- package/docs/images/class_diagram.jpg +0 -0
- package/docs/images/screenshot.jpg +0 -0
- package/docs/index.md +135 -0
- package/docs/reference/components/core/Basic.md +196 -0
- package/docs/reference/components/core/CoverageMap.md +210 -0
- package/docs/reference/components/core/Editor.md +224 -0
- package/docs/reference/components/core/PhotoViewer.md +307 -0
- package/docs/reference/components/core/Viewer.md +350 -0
- package/docs/reference/components/layout/BottomDrawer.md +35 -0
- package/docs/reference/components/layout/CorneredGrid.md +29 -0
- package/docs/reference/components/layout/Mini.md +45 -0
- package/docs/reference/components/layout/Tabs.md +45 -0
- package/docs/reference/components/menus/MapBackground.md +32 -0
- package/docs/reference/components/menus/MapFilters.md +15 -0
- package/docs/reference/components/menus/MapLayers.md +15 -0
- package/docs/reference/components/menus/MapLegend.md +15 -0
- package/docs/reference/components/menus/PictureLegend.md +16 -0
- package/docs/reference/components/menus/PictureMetadata.md +15 -0
- package/docs/reference/components/menus/PlayerOptions.md +15 -0
- package/docs/reference/components/menus/QualityScoreDoc.md +15 -0
- package/docs/reference/components/menus/ReportForm.md +15 -0
- package/docs/reference/components/menus/ShareMenu.md +15 -0
- package/docs/reference/components/ui/Button.md +40 -0
- package/docs/reference/components/ui/ButtonGroup.md +36 -0
- package/docs/reference/components/ui/CopyButton.md +38 -0
- package/docs/reference/components/ui/Grade.md +32 -0
- package/docs/reference/components/ui/LinkButton.md +45 -0
- package/docs/reference/components/ui/ListGroup.md +22 -0
- package/docs/reference/components/ui/Loader.md +56 -0
- package/docs/reference/components/ui/Map.md +239 -0
- package/docs/reference/components/ui/MapMore.md +256 -0
- package/docs/reference/components/ui/Photo.md +385 -0
- package/docs/reference/components/ui/Popup.md +56 -0
- package/docs/reference/components/ui/ProgressBar.md +32 -0
- package/docs/reference/components/ui/QualityScore.md +45 -0
- package/docs/reference/components/ui/SearchBar.md +63 -0
- package/docs/reference/components/ui/TogglableGroup.md +39 -0
- package/docs/reference/components/ui/widgets/GeoSearch.md +32 -0
- package/docs/reference/components/ui/widgets/Legend.md +49 -0
- package/docs/reference/components/ui/widgets/MapFiltersButton.md +33 -0
- package/docs/reference/components/ui/widgets/MapLayersButton.md +15 -0
- package/docs/reference/components/ui/widgets/OSMEditors.md +15 -0
- package/docs/reference/components/ui/widgets/PictureLegendActions.md +32 -0
- package/docs/reference/components/ui/widgets/Player.md +33 -0
- package/docs/reference/components/ui/widgets/Zoom.md +15 -0
- package/docs/reference/utils/API.md +334 -0
- package/docs/reference/utils/InitParameters.md +68 -0
- package/docs/reference/utils/URLHandler.md +107 -0
- package/docs/reference.md +79 -0
- package/docs/shortcuts.md +11 -0
- package/docs/tutorials/aerial_imagery.md +19 -0
- package/docs/tutorials/authentication.md +10 -0
- package/docs/tutorials/custom_widgets.md +59 -0
- package/docs/tutorials/map_style.md +39 -0
- package/docs/tutorials/migrate_v4.md +153 -0
- package/docs/tutorials/synced_coverage.md +43 -0
- package/mkdocs.yml +66 -5
- package/package.json +22 -17
- package/public/editor.html +21 -29
- package/public/index.html +17 -12
- package/public/map.html +19 -18
- package/public/photo.html +55 -0
- package/public/viewer.html +22 -26
- package/public/widgets.html +306 -0
- package/scripts/doc.js +79 -0
- package/src/components/core/Basic.css +48 -0
- package/src/components/core/Basic.js +349 -0
- package/src/components/core/CoverageMap.css +9 -0
- package/src/components/core/CoverageMap.js +139 -0
- package/src/components/core/Editor.css +23 -0
- package/src/components/core/Editor.js +390 -0
- package/src/components/core/PhotoViewer.css +48 -0
- package/src/components/core/PhotoViewer.js +499 -0
- package/src/components/core/Viewer.css +98 -0
- package/src/components/core/Viewer.js +564 -0
- package/src/components/core/index.js +12 -0
- package/src/components/index.js +13 -0
- package/src/components/layout/BottomDrawer.js +257 -0
- package/src/components/layout/CorneredGrid.js +112 -0
- package/src/components/layout/Mini.js +117 -0
- package/src/components/layout/Tabs.js +133 -0
- package/src/components/layout/index.js +9 -0
- package/src/components/menus/MapBackground.js +106 -0
- package/src/components/menus/MapFilters.js +400 -0
- package/src/components/menus/MapLayers.js +143 -0
- package/src/components/menus/MapLegend.js +34 -0
- package/src/components/menus/PictureLegend.js +257 -0
- package/src/components/menus/PictureMetadata.js +317 -0
- package/src/components/menus/PlayerOptions.js +95 -0
- package/src/components/menus/QualityScoreDoc.js +36 -0
- package/src/components/menus/ReportForm.js +133 -0
- package/src/components/menus/Share.js +100 -0
- package/src/components/menus/index.js +15 -0
- package/src/components/styles.js +383 -0
- package/src/components/ui/Button.js +77 -0
- package/src/components/ui/ButtonGroup.css +57 -0
- package/src/components/ui/ButtonGroup.js +68 -0
- package/src/components/ui/CopyButton.js +106 -0
- package/src/components/ui/Grade.js +54 -0
- package/src/components/ui/LinkButton.js +67 -0
- package/src/components/ui/ListGroup.js +66 -0
- package/src/components/ui/Loader.js +203 -0
- package/src/components/{Map.css → ui/Map.css} +5 -17
- package/src/components/{Map.js → ui/Map.js} +148 -156
- package/src/components/ui/MapMore.js +324 -0
- package/src/components/{Photo.css → ui/Photo.css} +6 -6
- package/src/components/{Photo.js → ui/Photo.js} +313 -101
- package/src/components/ui/Popup.js +145 -0
- package/src/components/ui/ProgressBar.js +104 -0
- package/src/components/ui/QualityScore.js +147 -0
- package/src/components/ui/SearchBar.js +367 -0
- package/src/components/ui/TogglableGroup.js +157 -0
- package/src/components/ui/index.js +22 -0
- package/src/components/ui/widgets/GeoSearch.css +21 -0
- package/src/components/ui/widgets/GeoSearch.js +139 -0
- package/src/components/ui/widgets/Legend.js +113 -0
- package/src/components/ui/widgets/MapFiltersButton.js +104 -0
- package/src/components/ui/widgets/MapLayersButton.js +79 -0
- package/src/components/ui/widgets/OSMEditors.js +155 -0
- package/src/components/ui/widgets/PictureLegendActions.js +117 -0
- package/src/components/ui/widgets/Player.css +7 -0
- package/src/components/ui/widgets/Player.js +151 -0
- package/src/components/ui/widgets/Zoom.js +82 -0
- package/src/components/ui/widgets/index.js +13 -0
- package/src/img/loader_base.jpg +0 -0
- package/src/img/panoramax.svg +13 -0
- package/src/img/switch_big.svg +20 -10
- package/src/index.js +7 -9
- package/src/translations/br.json +1 -0
- package/src/translations/da.json +38 -15
- package/src/translations/de.json +5 -3
- package/src/translations/en.json +35 -15
- package/src/translations/eo.json +38 -15
- package/src/translations/es.json +1 -1
- package/src/translations/fr.json +36 -16
- package/src/translations/hu.json +1 -1
- package/src/translations/it.json +39 -16
- package/src/translations/ja.json +182 -1
- package/src/translations/nl.json +106 -6
- package/src/translations/pl.json +1 -1
- package/src/translations/sv.json +182 -0
- package/src/translations/zh_Hant.json +35 -14
- package/src/utils/API.js +109 -49
- package/src/utils/InitParameters.js +388 -0
- package/src/utils/PhotoAdapter.js +1 -0
- package/src/utils/URLHandler.js +362 -0
- package/src/utils/geocoder.js +152 -0
- package/src/utils/{I18n.js → i18n.js} +7 -3
- package/src/utils/index.js +11 -0
- package/src/utils/{Map.js → map.js} +256 -77
- package/src/utils/picture.js +442 -0
- package/src/utils/utils.js +324 -0
- package/src/utils/widgets.js +55 -0
- package/tests/components/core/Basic.test.js +121 -0
- package/tests/components/core/BasicMock.js +25 -0
- package/tests/components/core/CoverageMap.test.js +20 -0
- package/tests/components/core/Editor.test.js +20 -0
- package/tests/components/core/PhotoViewer.test.js +57 -0
- package/tests/components/core/Viewer.test.js +84 -0
- package/tests/components/core/__snapshots__/PhotoViewer.test.js.snap +73 -0
- package/tests/components/core/__snapshots__/Viewer.test.js.snap +145 -0
- package/tests/components/ui/CopyButton.test.js +52 -0
- package/tests/components/ui/Loader.test.js +55 -0
- package/tests/components/{Map.test.js → ui/Map.test.js} +73 -61
- package/tests/components/{Photo.test.js → ui/Photo.test.js} +97 -63
- package/tests/components/ui/Popup.test.js +26 -0
- package/tests/components/ui/QualityScore.test.js +18 -0
- package/tests/components/ui/SearchBar.test.js +110 -0
- package/tests/components/ui/__snapshots__/CopyButton.test.js.snap +33 -0
- package/tests/components/ui/__snapshots__/Loader.test.js.snap +56 -0
- package/tests/components/{__snapshots__ → ui/__snapshots__}/Map.test.js.snap +11 -38
- package/tests/components/{__snapshots__ → ui/__snapshots__}/Photo.test.js.snap +70 -6
- package/tests/components/ui/__snapshots__/Popup.test.js.snap +29 -0
- package/tests/components/ui/__snapshots__/QualityScore.test.js.snap +11 -0
- package/tests/components/ui/__snapshots__/SearchBar.test.js.snap +65 -0
- package/tests/utils/API.test.js +83 -83
- package/tests/utils/InitParameters.test.js +499 -0
- package/tests/utils/URLHandler.test.js +401 -0
- package/tests/utils/__snapshots__/API.test.js.snap +10 -0
- package/tests/utils/__snapshots__/URLHandler.test.js.snap +21 -0
- package/tests/utils/__snapshots__/{Map.test.js.snap → geocoder.test.js.snap} +1 -1
- package/tests/utils/__snapshots__/map.test.js.snap +11 -0
- package/tests/utils/__snapshots__/picture.test.js.snap +327 -0
- package/tests/utils/__snapshots__/widgets.test.js.snap +19 -0
- package/tests/utils/geocoder.test.js +37 -0
- package/tests/utils/{I18n.test.js → i18n.test.js} +8 -8
- package/tests/utils/map.test.js +126 -0
- package/tests/utils/picture.test.js +745 -0
- package/tests/utils/utils.test.js +288 -0
- package/tests/utils/widgets.test.js +31 -0
- package/docs/01_Start.md +0 -149
- package/docs/02_Usage.md +0 -831
- package/docs/04_Advanced_examples.md +0 -216
- package/src/Editor.css +0 -37
- package/src/Editor.js +0 -361
- package/src/StandaloneMap.js +0 -114
- package/src/Viewer.css +0 -203
- package/src/Viewer.js +0 -1246
- package/src/components/CoreView.css +0 -70
- package/src/components/CoreView.js +0 -175
- package/src/components/Loader.css +0 -74
- package/src/components/Loader.js +0 -120
- package/src/img/loader_hd.jpg +0 -0
- package/src/utils/Exif.js +0 -193
- package/src/utils/Utils.js +0 -631
- package/src/utils/Widgets.js +0 -562
- package/src/viewer/URLHash.js +0 -469
- package/src/viewer/Widgets.css +0 -880
- package/src/viewer/Widgets.js +0 -1470
- package/tests/Editor.test.js +0 -126
- package/tests/StandaloneMap.test.js +0 -45
- package/tests/Viewer.test.js +0 -366
- package/tests/__snapshots__/Editor.test.js.snap +0 -298
- package/tests/__snapshots__/StandaloneMap.test.js.snap +0 -30
- package/tests/__snapshots__/Viewer.test.js.snap +0 -195
- package/tests/components/CoreView.test.js +0 -92
- package/tests/components/Loader.test.js +0 -38
- package/tests/components/__snapshots__/Loader.test.js.snap +0 -15
- package/tests/utils/Exif.test.js +0 -124
- package/tests/utils/Map.test.js +0 -113
- package/tests/utils/Utils.test.js +0 -300
- package/tests/utils/Widgets.test.js +0 -107
- package/tests/utils/__snapshots__/Exif.test.js.snap +0 -43
- package/tests/utils/__snapshots__/Utils.test.js.snap +0 -41
- package/tests/utils/__snapshots__/Widgets.test.js.snap +0 -44
- package/tests/viewer/URLHash.test.js +0 -559
- package/tests/viewer/Widgets.test.js +0 -127
- package/tests/viewer/__snapshots__/URLHash.test.js.snap +0 -108
- package/tests/viewer/__snapshots__/Widgets.test.js.snap +0 -403
package/tests/utils/Exif.test.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import * as Exif from "../../src/utils/Exif";
|
|
2
|
-
|
|
3
|
-
describe("getExifFloat", () => {
|
|
4
|
-
it.each([
|
|
5
|
-
[undefined, undefined],
|
|
6
|
-
[null, undefined],
|
|
7
|
-
["", undefined],
|
|
8
|
-
[" ", undefined],
|
|
9
|
-
[1, 1],
|
|
10
|
-
[1.4, 1.4],
|
|
11
|
-
["1", 1],
|
|
12
|
-
["-1.4", -1.4],
|
|
13
|
-
["-104/10", -10.4],
|
|
14
|
-
["-104.12/-12.12", 8.590759075907592],
|
|
15
|
-
])("works with %s", (input, expected) => {
|
|
16
|
-
expect(Exif.getExifFloat(input)).toBe(expected);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe("getGPSPrecision", () => {
|
|
21
|
-
it.each([
|
|
22
|
-
[undefined, "❓"],
|
|
23
|
-
[0.4, "0.4 m"],
|
|
24
|
-
[0.9, "0.9 m"],
|
|
25
|
-
[2.9, "2.9 m"],
|
|
26
|
-
[6.9, "6.9 m"],
|
|
27
|
-
[9.9, "9.9 m"],
|
|
28
|
-
[20, "20 m"],
|
|
29
|
-
["9/10", "0.9 m"],
|
|
30
|
-
["99/10", "9.9 m"],
|
|
31
|
-
])("handles GPSHPos %s > %s", (input, expected) => {
|
|
32
|
-
const p = { properties: { exif: { "Exif.GPSInfo.GPSHPositioningError": input, "Exif.GPSInfo.GPSDOP": input } } };
|
|
33
|
-
expect(Exif.getGPSPrecision(p)).toBe(expected);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it.each([
|
|
37
|
-
[undefined, "❓"],
|
|
38
|
-
[0.9, "ideal"],
|
|
39
|
-
[1.9, "excellent"],
|
|
40
|
-
[4.9, "good"],
|
|
41
|
-
[9.9, "moderate"],
|
|
42
|
-
[19.9, "fair"],
|
|
43
|
-
[20, "poor"],
|
|
44
|
-
["1/1", "excellent"],
|
|
45
|
-
["15/10", "excellent"],
|
|
46
|
-
])("handles GPSDOP %s > %s", (input, expected) => {
|
|
47
|
-
const p = { properties: { exif: { "Exif.GPSInfo.GPSDOP": input } } };
|
|
48
|
-
expect(Exif.getGPSPrecision(p)).toBe(expected);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe("getSphereCorrection", () => {
|
|
53
|
-
it("works with API props", () => {
|
|
54
|
-
const p = { properties: {
|
|
55
|
-
"view:azimuth": 50,
|
|
56
|
-
"pers:yaw": 42,
|
|
57
|
-
"pers:pitch": -30,
|
|
58
|
-
"pers:roll": 72.2
|
|
59
|
-
} };
|
|
60
|
-
expect(Exif.getSphereCorrection(p)).toMatchSnapshot();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("works with exif tags", () => {
|
|
64
|
-
const p = { properties: {
|
|
65
|
-
exif: {
|
|
66
|
-
"Xmp.Camera.Pitch": "-30/1",
|
|
67
|
-
"Xmp.GPano.PoseRollDegrees": 72.2,
|
|
68
|
-
"Exif.MpfInfo.MPFYawAngle": 42,
|
|
69
|
-
},
|
|
70
|
-
"view:azimuth": 50,
|
|
71
|
-
} };
|
|
72
|
-
expect(Exif.getSphereCorrection(p)).toMatchSnapshot();
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
describe("getCroppedPanoData", () => {
|
|
77
|
-
it("works with API props", () => {
|
|
78
|
-
const p = { properties: {
|
|
79
|
-
"pers:interior_orientation": {
|
|
80
|
-
"sensor_array_dimensions": [15872,7936],
|
|
81
|
-
"visible_area": [0,2538,0,2792]
|
|
82
|
-
}
|
|
83
|
-
} };
|
|
84
|
-
expect(Exif.getCroppedPanoData(p)).toMatchSnapshot();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("works with exif tags", () => {
|
|
88
|
-
const p = { properties: {
|
|
89
|
-
exif: {
|
|
90
|
-
"Xmp.GPano.CroppedAreaImageHeightPixels": "2606",
|
|
91
|
-
"Xmp.GPano.CroppedAreaImageWidthPixels": "15872",
|
|
92
|
-
"Xmp.GPano.CroppedAreaLeftPixels": "0",
|
|
93
|
-
"Xmp.GPano.CroppedAreaTopPixels": "2538",
|
|
94
|
-
"Xmp.GPano.FullPanoHeightPixels": "7936",
|
|
95
|
-
"Xmp.GPano.FullPanoWidthPixels": "15872",
|
|
96
|
-
},
|
|
97
|
-
} };
|
|
98
|
-
expect(Exif.getCroppedPanoData(p)).toMatchSnapshot();
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("works with API props and unneeded", () => {
|
|
102
|
-
const p = { properties: {
|
|
103
|
-
"pers:interior_orientation": {
|
|
104
|
-
"sensor_array_dimensions": [15872,7936],
|
|
105
|
-
"visible_area": [0,0,0,0]
|
|
106
|
-
}
|
|
107
|
-
} };
|
|
108
|
-
expect(Exif.getCroppedPanoData(p)).toMatchSnapshot();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("works with exif tags and unneeded", () => {
|
|
112
|
-
const p = { properties: {
|
|
113
|
-
exif: {
|
|
114
|
-
"Xmp.GPano.CroppedAreaImageHeightPixels": "7936",
|
|
115
|
-
"Xmp.GPano.CroppedAreaImageWidthPixels": "15872",
|
|
116
|
-
"Xmp.GPano.CroppedAreaLeftPixels": "0",
|
|
117
|
-
"Xmp.GPano.CroppedAreaTopPixels": "0",
|
|
118
|
-
"Xmp.GPano.FullPanoHeightPixels": "7936",
|
|
119
|
-
"Xmp.GPano.FullPanoWidthPixels": "15872",
|
|
120
|
-
},
|
|
121
|
-
} };
|
|
122
|
-
expect(Exif.getCroppedPanoData(p)).toMatchSnapshot();
|
|
123
|
-
});
|
|
124
|
-
});
|
package/tests/utils/Map.test.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import * as Map from "../../src/utils/Map";
|
|
2
|
-
import GEOCODER_NOMINATIM from "../data/Map_geocoder_nominatim.json";
|
|
3
|
-
import GEOCODER_BAN from "../data/Map_geocoder_ban.json";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
jest.mock("maplibre-gl", () => ({
|
|
7
|
-
addProtocol: jest.fn(),
|
|
8
|
-
Popup: function() {
|
|
9
|
-
return {
|
|
10
|
-
on: jest.fn(),
|
|
11
|
-
};
|
|
12
|
-
},
|
|
13
|
-
LngLat: function() {
|
|
14
|
-
return { lng: -1.7, lat: 47.8 };
|
|
15
|
-
},
|
|
16
|
-
LngLatBounds: function() {
|
|
17
|
-
return { sw: { lng: -1.7, lat: 47.8 }, ne: { lng: -1.7, lat: 47.8 } };
|
|
18
|
-
},
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
describe("getThumbGif", () => {
|
|
23
|
-
it("works", () => {
|
|
24
|
-
const lang = { loading: "Loading..." };
|
|
25
|
-
const res = Map.getThumbGif(lang);
|
|
26
|
-
expect(res).toBeDefined();
|
|
27
|
-
expect(res.tagName).toBe("IMG");
|
|
28
|
-
expect(res.alt).toBe(lang.loading);
|
|
29
|
-
expect(res.title).toBe(lang.loading);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe("getUserLayerId", () => {
|
|
34
|
-
it("works with default tiles", () => {
|
|
35
|
-
expect(Map.getUserLayerId("geovisio", "pictures")).toBe("geovisio_pictures");
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("works with specific user tiles", () => {
|
|
39
|
-
expect(Map.getUserLayerId("toto", "pictures")).toBe("geovisio_toto_pictures");
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe("getUserSourceId", () => {
|
|
44
|
-
it("works with default tiles", () => {
|
|
45
|
-
expect(Map.getUserSourceId("geovisio")).toBe("geovisio");
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("works with specific user tiles", () => {
|
|
49
|
-
expect(Map.getUserSourceId("toto")).toBe("geovisio_toto");
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe("switchCoefValue", () => {
|
|
54
|
-
it("works", () => {
|
|
55
|
-
const l = {id: "bla", paint: { "circle-radius": ["bla", ["get", "coef"]]}, layout: {"circle-sort": "coef"}};
|
|
56
|
-
const res = Map.switchCoefValue(l, "coef_360");
|
|
57
|
-
expect(res).toEqual({id: "bla", paint: { "circle-radius": ["bla", ["get", "coef_360"]]}, layout: {"circle-sort": "coef_360"}})
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe("geocoderParamsToURLString", () => {
|
|
62
|
-
it("works", () => {
|
|
63
|
-
const p = { bla: "blorg", you: 1 };
|
|
64
|
-
const r = Map.geocoderParamsToURLString(p);
|
|
65
|
-
expect(r).toEqual("bla=blorg&you=1");
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("handles special characters", () => {
|
|
69
|
-
const p = { bbox: "12,14,-45,78" };
|
|
70
|
-
const r = Map.geocoderParamsToURLString(p);
|
|
71
|
-
expect(r).toEqual("bbox=12%2C14%2C-45%2C78");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("filters nulls", () => {
|
|
75
|
-
const p = { val1: undefined, val2: null, val3: 0 };
|
|
76
|
-
const r = Map.geocoderParamsToURLString(p);
|
|
77
|
-
expect(r).toEqual("val3=0");
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
describe("forwardGeocodingNominatim", () => {
|
|
82
|
-
it("works", () => {
|
|
83
|
-
// Mock API search
|
|
84
|
-
global.fetch = jest.fn(() => Promise.resolve({
|
|
85
|
-
json: () => GEOCODER_NOMINATIM
|
|
86
|
-
}));
|
|
87
|
-
|
|
88
|
-
// Search config
|
|
89
|
-
const cfg = { query: "bla", limit: 5, bbox: "17.7,-45.2,17.8,-45.1" };
|
|
90
|
-
|
|
91
|
-
return Map.forwardGeocodingNominatim(cfg).then(res => {
|
|
92
|
-
expect(global.fetch.mock.calls).toEqual([["https://nominatim.openstreetmap.org/search?q=bla&limit=5&viewbox=17.7%2C-45.2%2C17.8%2C-45.1&format=geojson&polygon_geojson=1&addressdetails=1"]]);
|
|
93
|
-
expect(res).toMatchSnapshot();
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe("forwardGeocodingBAN", () => {
|
|
99
|
-
it("works", () => {
|
|
100
|
-
// Mock API search
|
|
101
|
-
global.fetch = jest.fn(() => Promise.resolve({
|
|
102
|
-
json: () => GEOCODER_BAN
|
|
103
|
-
}));
|
|
104
|
-
|
|
105
|
-
// Search config
|
|
106
|
-
const cfg = { query: "bla", limit: 5, proximity: "17.7,-45.2" };
|
|
107
|
-
|
|
108
|
-
return Map.forwardGeocodingBAN(cfg).then(res => {
|
|
109
|
-
expect(global.fetch.mock.calls).toEqual([["https://api-adresse.data.gouv.fr/search/?q=bla&limit=5&lat=17.7&lon=-45.2"]]);
|
|
110
|
-
expect(res).toMatchSnapshot();
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
});
|
|
@@ -1,300 +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("getDistance", () => {
|
|
10
|
-
it("works", () => {
|
|
11
|
-
const p1 = [1,1];
|
|
12
|
-
const p2 = [2,2];
|
|
13
|
-
const res = Utils.getDistance(p1, p2);
|
|
14
|
-
expect(res).toBe(Math.sqrt(2));
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
describe("sortPicturesInDirection", () => {
|
|
19
|
-
it("works with next/prev links", () => {
|
|
20
|
-
const sort = Utils.sortPicturesInDirection([0,0]);
|
|
21
|
-
let res = sort({rel: "prev"}, {rel: "next"});
|
|
22
|
-
expect(res).toBe(0);
|
|
23
|
-
res = sort({rel: "prev"}, {rel: "related"});
|
|
24
|
-
expect(res).toBe(-1);
|
|
25
|
-
res = sort({rel: "related"}, {rel: "next"});
|
|
26
|
-
expect(res).toBe(1);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("works with related at different dates", () => {
|
|
30
|
-
const sort = Utils.sortPicturesInDirection([0,0]);
|
|
31
|
-
let res = sort(
|
|
32
|
-
{rel: "related", date: "2023-01-01"},
|
|
33
|
-
{rel: "related", date: "2022-01-01"}
|
|
34
|
-
);
|
|
35
|
-
expect(res).toBe(-1); // Most recent goes first
|
|
36
|
-
res = sort(
|
|
37
|
-
{rel: "related", date: "2022-01-01"},
|
|
38
|
-
{rel: "related", date: "2023-01-01"}
|
|
39
|
-
);
|
|
40
|
-
expect(res).toBe(1);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("works with related at same date", () => {
|
|
44
|
-
const sort = Utils.sortPicturesInDirection([0,0]);
|
|
45
|
-
let res = sort(
|
|
46
|
-
{rel: "related", date: "2023-01-01", geometry: {coordinates: [0.1,0.1]}},
|
|
47
|
-
{rel: "related", date: "2023-01-01", geometry: {coordinates: [0.5,0.5]}}
|
|
48
|
-
);
|
|
49
|
-
expect(res).toBeLessThan(0); // Nearest goes first
|
|
50
|
-
res = sort(
|
|
51
|
-
{rel: "related", date: "2023-01-01", geometry: {coordinates: [0.5,0.5]}},
|
|
52
|
-
{rel: "related", date: "2023-01-01", geometry: {coordinates: [0.1,0.1]}}
|
|
53
|
-
);
|
|
54
|
-
expect(res).toBeGreaterThan(0);
|
|
55
|
-
res = sort(
|
|
56
|
-
{rel: "related", date: "2023-01-01", geometry: {coordinates: [0.1,0.1]}},
|
|
57
|
-
{rel: "related", date: "2023-01-01", geometry: {coordinates: [0.1,0.1]}}
|
|
58
|
-
);
|
|
59
|
-
expect(res).toBe(0);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe("getAzimuth", () => {
|
|
64
|
-
it("works with 0 + NE", () => {
|
|
65
|
-
const pointDepart = [0, 0];
|
|
66
|
-
const pointArrivee = [1, 1];
|
|
67
|
-
const azimuth = Utils.getAzimuth(pointDepart, pointArrivee);
|
|
68
|
-
expect(azimuth).toBe(45);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("works with 0 + SE", () => {
|
|
72
|
-
const pointDepart = [0, 0];
|
|
73
|
-
const pointArrivee = [1, -1];
|
|
74
|
-
const azimuth = Utils.getAzimuth(pointDepart, pointArrivee);
|
|
75
|
-
expect(azimuth).toBe(135);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("works with 0 + N", () => {
|
|
79
|
-
const pointDepart = [0, 0];
|
|
80
|
-
const pointArrivee = [0, 1];
|
|
81
|
-
const azimuth = Utils.getAzimuth(pointDepart, pointArrivee);
|
|
82
|
-
expect(azimuth).toBe(0);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("works with 0 + S", () => {
|
|
86
|
-
const pointDepart = [0, 0];
|
|
87
|
-
const pointArrivee = [0, -1];
|
|
88
|
-
const azimuth = Utils.getAzimuth(pointDepart, pointArrivee);
|
|
89
|
-
expect(azimuth).toBe(180);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe("getRelativeHeading", () => {
|
|
94
|
-
it("should throw an error if no picture selected", () => {
|
|
95
|
-
expect(() => Utils.getRelativeHeading()).toThrow("No picture selected");
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("should calculate relative heading correctly", () => {
|
|
99
|
-
const pictureMetadata = {
|
|
100
|
-
properties: { "view:azimuth": 30 },
|
|
101
|
-
sequence: { prevPic: "prevPictureId", nextPic: "nextPictureId" },
|
|
102
|
-
links: [
|
|
103
|
-
{ nodeId: "prevPictureId", gps: [0, 0] },
|
|
104
|
-
{ nodeId: "nextPictureId", gps: [2, 2] }
|
|
105
|
-
],
|
|
106
|
-
gps: [1, 1]
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
expect(Utils.getRelativeHeading(pictureMetadata)).toBe(-15);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("works looking behind", () => {
|
|
113
|
-
const pictureMetadata = {
|
|
114
|
-
properties: { "view:azimuth": 226 },
|
|
115
|
-
sequence: { prevPic: "prevPictureId", nextPic: "nextPictureId" },
|
|
116
|
-
links: [
|
|
117
|
-
{ nodeId: "prevPictureId", gps: [0, 0] },
|
|
118
|
-
{ nodeId: "nextPictureId", gps: [2, 2] }
|
|
119
|
-
],
|
|
120
|
-
gps: [1, 1]
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
expect(Utils.getRelativeHeading(pictureMetadata)).toBe(-179);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("works with distorted path", () => {
|
|
127
|
-
const pictureMetadata = {
|
|
128
|
-
properties: { "view:azimuth": 100 },
|
|
129
|
-
sequence: { prevPic: "prevPictureId", nextPic: "nextPictureId" },
|
|
130
|
-
links: [
|
|
131
|
-
{ nodeId: "prevPictureId", gps: [0, 0] },
|
|
132
|
-
{ nodeId: "nextPictureId", gps: [2, 1] }
|
|
133
|
-
],
|
|
134
|
-
gps: [1, 0]
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
expect(Utils.getRelativeHeading(pictureMetadata)).toBe(10);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("works without previous link", () => {
|
|
141
|
-
const pictureMetadata = {
|
|
142
|
-
properties: { "view:azimuth": 100 },
|
|
143
|
-
sequence: { nextPic: "nextPictureId" },
|
|
144
|
-
links: [
|
|
145
|
-
{ nodeId: "nextPictureId", gps: [2, 1] }
|
|
146
|
-
],
|
|
147
|
-
gps: [1, 1]
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
expect(Utils.getRelativeHeading(pictureMetadata)).toBe(10);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("should handle missing prevPic or nextPic", () => {
|
|
154
|
-
const metadataWithoutPrevNext = {
|
|
155
|
-
properties: { "view:azimuth": 30 },
|
|
156
|
-
gps: [0, 0]
|
|
157
|
-
};
|
|
158
|
-
expect(Utils.getRelativeHeading(metadataWithoutPrevNext)).toBe(0);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
describe("getSimplifiedAngle", () => {
|
|
163
|
-
it("returns \"N\"", () => {
|
|
164
|
-
expect(Utils.getSimplifiedAngle([0, 0], [0, 1])).toBe("N");
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it("returns \"ENE\"", () => {
|
|
168
|
-
expect(Utils.getSimplifiedAngle([0, 0], [1, 1])).toBe("ENE");
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("returns \"ESE\"", () => {
|
|
172
|
-
expect(Utils.getSimplifiedAngle([0, 0], [1, -1])).toBe("ESE");
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it("returns \"S\"", () => {
|
|
176
|
-
expect(Utils.getSimplifiedAngle([0, 0], [0, -1])).toBe("S");
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it("returns \"WNW\"", () => {
|
|
180
|
-
expect(Utils.getSimplifiedAngle([0, 0], [-1, 1])).toBe("WNW");
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it("returns \"WSW\"", () => {
|
|
184
|
-
expect(Utils.getSimplifiedAngle([0, 0], [-1, -1])).toBe("WSW");
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
describe("positionToXYZ", () => {
|
|
189
|
-
it("works with xy", () => {
|
|
190
|
-
const r = Utils.positionToXYZ({ pitch: 10, yaw: -5 });
|
|
191
|
-
expect(r).toEqual({ x: -286.4788975654116, y: 572.9577951308232 });
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it("works with xyz", () => {
|
|
195
|
-
const r = Utils.positionToXYZ({ pitch: 10, yaw: -5 }, 15);
|
|
196
|
-
expect(r).toEqual({ x: -286.4788975654116, y: 572.9577951308232, z: 15 });
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
describe("xyzToPosition", () => {
|
|
201
|
-
it("works with xyz", () => {
|
|
202
|
-
const r = Utils.xyzToPosition(-286.4788975654116, 572.9577951308232, 15);
|
|
203
|
-
expect(r).toEqual({ pitch: 10, yaw: -5, zoom: 15 });
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
describe("getNodeCaption", () => {
|
|
208
|
-
it("works with date", () => {
|
|
209
|
-
const m = { properties: { datetime: "2022-02-01T12:15:36Z" } };
|
|
210
|
-
global.Date = jest.fn(() => ({ toLocaleDateString: () => "February 2 2022" }));
|
|
211
|
-
const res = Utils.getNodeCaption(m, { gvs: { metadata_general_license_link: "" }});
|
|
212
|
-
expect(res).toMatchSnapshot();
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
it("works with date+tz", () => {
|
|
216
|
-
const m = { properties: { datetimetz: "2022-02-01T12:15:36-03:00" } };
|
|
217
|
-
global.Date = jest.fn(() => ({ toLocaleDateString: () => "February 2 2022" }));
|
|
218
|
-
const res = Utils.getNodeCaption(m, { gvs: { metadata_general_license_link: "" }});
|
|
219
|
-
expect(res).toMatchSnapshot();
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it("works with producer", () => {
|
|
223
|
-
const m = { providers: [ { name: "PanierAvide", roles: ["producer", "licensor"] } ] };
|
|
224
|
-
const res = Utils.getNodeCaption(m, { gvs: { metadata_general_license_link: "" }});
|
|
225
|
-
expect(res).toMatchSnapshot();
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
it("works with date + producer", () => {
|
|
229
|
-
const m = { properties: { datetime: "2022-02-01T12:15:36Z" }, providers: [ { name: "PanierAvide", roles: ["producer", "licensor"] } ] };
|
|
230
|
-
global.Date = jest.fn(() => ({ toLocaleDateString: () => "February 2 2022" }));
|
|
231
|
-
const res = Utils.getNodeCaption(m, { gvs: { metadata_general_license_link: "" }});
|
|
232
|
-
expect(res).toMatchSnapshot();
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it("works with date + 2 producers", () => {
|
|
236
|
-
const m = {
|
|
237
|
-
properties: { datetime: "2022-02-01T12:15:36Z" },
|
|
238
|
-
providers: [
|
|
239
|
-
{ name: "GeoVisio Corp.", roles: ["producer", "licensor"] },
|
|
240
|
-
{ name: "PanierAvide", roles: ["producer"] },
|
|
241
|
-
]
|
|
242
|
-
};
|
|
243
|
-
global.Date = jest.fn(() => ({ toLocaleDateString: () => "February 2 2022" }));
|
|
244
|
-
const res = Utils.getNodeCaption(m, { gvs: { metadata_general_license_link: "" }});
|
|
245
|
-
expect(res).toMatchSnapshot();
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
describe("getCookie", () => {
|
|
250
|
-
it("should return the value of the specified cookie", () => {
|
|
251
|
-
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("session=abc123");
|
|
252
|
-
expect(Utils.getCookie("session")).toBe("abc123");
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
it("should return null if the cookie is not found", () => {
|
|
256
|
-
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("session=abc123");
|
|
257
|
-
expect(Utils.getCookie("user_id")).toBeUndefined();
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
it("should return the correct value when multiple cookies are set", () => {
|
|
261
|
-
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("session=abc123; user_id=789; user_name=John");
|
|
262
|
-
expect(Utils.getCookie("user_id")).toBe("789");
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
it("should return null if cookie with the specified name has no value", () => {
|
|
266
|
-
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("session=; user_id=789");
|
|
267
|
-
expect(Utils.getCookie("session")).toBe("");
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it("should return the correct value when the cookie contains =", () => {
|
|
271
|
-
jest.spyOn(document, "cookie", "get").mockReturnValueOnce("custom_cookie=abc=123");
|
|
272
|
-
expect(Utils.getCookie("custom_cookie")).toBe("abc=123");
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
describe("getUserAccount", () => {
|
|
277
|
-
it("should return an object with user id and name when all cookies are present", () => {
|
|
278
|
-
jest.spyOn(document, "cookie", "get").mockReturnValue("session=abc123; user_id=789; user_name=John");
|
|
279
|
-
expect(Utils.getUserAccount()).toEqual({ id: "789", name: "John" });
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it("should return null if session cookie is missing", () => {
|
|
283
|
-
jest.spyOn(document, "cookie", "get").mockReturnValue("user_id=789; user_name=John");
|
|
284
|
-
expect(Utils.getUserAccount()).toBeNull();
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it("should return null if user_id cookie is missing", () => {
|
|
288
|
-
jest.spyOn(document, "cookie", "get").mockReturnValue("session=abc123; user_name=John");
|
|
289
|
-
expect(Utils.getUserAccount()).toBeNull();
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
it("should return null if user_name cookie is missing", () => {
|
|
293
|
-
jest.spyOn(document, "cookie", "get").mockReturnValue("session=abc123; user_id=789");
|
|
294
|
-
expect(Utils.getUserAccount()).toBeNull();
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
it("should return null if all cookies are missing", () => {
|
|
298
|
-
expect(Utils.getUserAccount()).toBeNull();
|
|
299
|
-
});
|
|
300
|
-
});
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { faChevronDown } from "@fortawesome/free-solid-svg-icons/faChevronDown";
|
|
2
|
-
import * as Widgets from "../../src/utils/Widgets";
|
|
3
|
-
|
|
4
|
-
describe("createButton", () => {
|
|
5
|
-
it("works", () => {
|
|
6
|
-
const child = document.createElement("span");
|
|
7
|
-
const btn = Widgets.createButton("mybtn", child, "blabla", ["gvs-blabla"]);
|
|
8
|
-
expect(btn.className).toBe("gvs-btn gvs-widget-bg gvs-blabla");
|
|
9
|
-
expect(btn.id).toBe("mybtn");
|
|
10
|
-
expect(btn.children[0]).toBe(child);
|
|
11
|
-
expect(btn.title).toBe("blabla");
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("works without options", () => {
|
|
15
|
-
const child = document.createElement("span");
|
|
16
|
-
const btn = Widgets.createButton("mybtn");
|
|
17
|
-
expect(btn.className).toBe("gvs-btn gvs-widget-bg");
|
|
18
|
-
expect(btn.id).toBe("mybtn");
|
|
19
|
-
expect(btn.children.length).toBe(0);
|
|
20
|
-
expect(btn.title).toBe("");
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
describe("createExpandableButton", () => {
|
|
25
|
-
it("works with large container", () => {
|
|
26
|
-
const container = { _viewer: { isWidthSmall: () => false } };
|
|
27
|
-
const btn = Widgets.createExpandableButton("mybtn", faChevronDown, "blabla", container, ["gvs-blabla"]);
|
|
28
|
-
expect(btn.className).toBe("gvs-btn gvs-widget-bg gvs-btn-expandable gvs-blabla");
|
|
29
|
-
expect(btn.innerHTML).toMatchSnapshot();
|
|
30
|
-
expect(btn.id).toBe("mybtn");
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("works with small container", () => {
|
|
34
|
-
const container = { _viewer: { isWidthSmall: () => true } };
|
|
35
|
-
const btn = Widgets.createExpandableButton("mybtn", faChevronDown, "blabla", container, ["gvs-blabla"]);
|
|
36
|
-
expect(btn.className).toBe("gvs-btn gvs-widget-bg gvs-btn-expandable gvs-blabla");
|
|
37
|
-
expect(btn.innerHTML).toMatchSnapshot();
|
|
38
|
-
expect(btn.id).toBe("mybtn");
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe("createSearchBar", () => {
|
|
43
|
-
it("works", () => {
|
|
44
|
-
const container = { _t: {} };
|
|
45
|
-
const btn = Widgets.createSearchBar("mysrch", "no res", jest.fn(), jest.fn(), container);
|
|
46
|
-
expect(btn.className).toBe("gvs-widget-bg gvs-search-bar");
|
|
47
|
-
expect(btn.innerHTML).toMatchSnapshot();
|
|
48
|
-
expect(btn.id).toBe("mysrch");
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe("createPanel", () => {
|
|
53
|
-
it("works", () => {
|
|
54
|
-
const btn = document.createElement("button");
|
|
55
|
-
btn.id = "btngvs";
|
|
56
|
-
btn.addEventListener = jest.fn();
|
|
57
|
-
const child = document.createElement("span");
|
|
58
|
-
const pnl = Widgets.createPanel({}, btn, [child], ["gvs-blabla"]);
|
|
59
|
-
expect(pnl.id).toBe("btngvs-panel");
|
|
60
|
-
expect(pnl.className).toBe("gvs-panel gvs-widget-bg gvs-hidden gvs-blabla");
|
|
61
|
-
expect(pnl.innerHTML).toMatchSnapshot();
|
|
62
|
-
expect(btn.addEventListener.mock.calls).toMatchSnapshot();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
describe("createGroup", () => {
|
|
67
|
-
it("works", () => {
|
|
68
|
-
const container = { _corners: { "main-top-left": document.createElement("div") } };
|
|
69
|
-
const child = document.createElement("span");
|
|
70
|
-
const grp = Widgets.createGroup("grp", "main-top-left", container, [child], ["gvs-blabla"]);
|
|
71
|
-
expect(grp.className).toBe("gvs-group gvs-blabla");
|
|
72
|
-
expect(grp.innerHTML).toMatchSnapshot();
|
|
73
|
-
expect(grp.id).toBe("grp");
|
|
74
|
-
expect(container._corners["main-top-left"].children[0]).toBe(grp);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
describe("enableButton", () => {
|
|
79
|
-
it("works", () => {
|
|
80
|
-
const btn = document.createElement("button");
|
|
81
|
-
btn.setAttribute("disabled", "");
|
|
82
|
-
Widgets.enableButton(btn);
|
|
83
|
-
expect(btn.getAttribute("disabled")).toBeNull();
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
describe("disableButton", () => {
|
|
88
|
-
it("works", () => {
|
|
89
|
-
const btn = document.createElement("button");
|
|
90
|
-
Widgets.disableButton(btn);
|
|
91
|
-
expect(btn.getAttribute("disabled")).toBe("");
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
describe("fa", () => {
|
|
96
|
-
it("works", () => {
|
|
97
|
-
const res = Widgets.fa(faChevronDown);
|
|
98
|
-
expect(res).toMatchSnapshot();
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
describe("fat", () => {
|
|
103
|
-
it("works", () => {
|
|
104
|
-
const res = Widgets.fat(faChevronDown);
|
|
105
|
-
expect(res).toMatchSnapshot();
|
|
106
|
-
});
|
|
107
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`getCroppedPanoData works with API props 1`] = `
|
|
4
|
-
Object {
|
|
5
|
-
"croppedHeight": 2606,
|
|
6
|
-
"croppedWidth": 15872,
|
|
7
|
-
"croppedX": 0,
|
|
8
|
-
"croppedY": 2538,
|
|
9
|
-
"fullHeight": 7936,
|
|
10
|
-
"fullWidth": 15872,
|
|
11
|
-
}
|
|
12
|
-
`;
|
|
13
|
-
|
|
14
|
-
exports[`getCroppedPanoData works with API props and unneeded 1`] = `Object {}`;
|
|
15
|
-
|
|
16
|
-
exports[`getCroppedPanoData works with exif tags 1`] = `
|
|
17
|
-
Object {
|
|
18
|
-
"croppedHeight": 2606,
|
|
19
|
-
"croppedWidth": 15872,
|
|
20
|
-
"croppedX": 0,
|
|
21
|
-
"croppedY": 2538,
|
|
22
|
-
"fullHeight": 7936,
|
|
23
|
-
"fullWidth": 15872,
|
|
24
|
-
}
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
exports[`getCroppedPanoData works with exif tags and unneeded 1`] = `Object {}`;
|
|
28
|
-
|
|
29
|
-
exports[`getSphereCorrection works with API props 1`] = `
|
|
30
|
-
Object {
|
|
31
|
-
"pan": 0.7330382858376184,
|
|
32
|
-
"roll": 1.260127719939906,
|
|
33
|
-
"tilt": -0.5235987755982988,
|
|
34
|
-
}
|
|
35
|
-
`;
|
|
36
|
-
|
|
37
|
-
exports[`getSphereCorrection works with exif tags 1`] = `
|
|
38
|
-
Object {
|
|
39
|
-
"pan": 0.7330382858376184,
|
|
40
|
-
"roll": 1.260127719939906,
|
|
41
|
-
"tilt": -0.5235987755982988,
|
|
42
|
-
}
|
|
43
|
-
`;
|