@panoramax/web-viewer 3.2.3-develop-83778bdd → 3.2.3-develop-04898f19
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/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/core/PhotoViewer.js +1 -1
- package/src/components/core/Viewer.js +1 -1
- package/tests/components/core/BasicMock.js +1 -0
- package/tests/components/core/PhotoViewer.test.js +37 -0
- package/tests/components/core/Viewer.test.js +60 -0
- package/tests/components/core/__snapshots__/PhotoViewer.test.js.snap +91 -0
- package/tests/components/core/__snapshots__/Viewer.test.js.snap +163 -0
package/package.json
CHANGED
|
@@ -118,7 +118,7 @@ export default class PhotoViewer extends Basic {
|
|
|
118
118
|
|
|
119
119
|
/** @private */
|
|
120
120
|
_initWidgets() {
|
|
121
|
-
if(this._initParams.
|
|
121
|
+
if(this._initParams.getParentPostInit().widgets !== "false") {
|
|
122
122
|
if(!this.isWidthSmall()) {
|
|
123
123
|
this.grid.appendChild(createWebComp("pnx-widget-zoom", {
|
|
124
124
|
slot: "bottom-right",
|
|
@@ -133,7 +133,7 @@ export default class Viewer extends PhotoViewer {
|
|
|
133
133
|
|
|
134
134
|
/** @private */
|
|
135
135
|
_initWidgets() {
|
|
136
|
-
if(this._initParams.
|
|
136
|
+
if(this._initParams.getParentPostInit().widgets !== "false") {
|
|
137
137
|
this.grid.appendChild(createWebComp("pnx-widget-zoom", {
|
|
138
138
|
slot: this.isWidthSmall() ? "top-left" : "bottom-right",
|
|
139
139
|
class: this.isWidthSmall() ? "pnx-only-map pnx-print-hidden" : "pnx-print-hidden",
|
|
@@ -7,6 +7,43 @@ global.console = { info: jest.fn(), error: jest.fn(), warn: jest.fn(), log: glob
|
|
|
7
7
|
beforeEach(() => comp = new PhotoViewer());
|
|
8
8
|
afterEach(() => jest.clearAllMocks());
|
|
9
9
|
|
|
10
|
+
|
|
11
|
+
describe("_initWidgets", () => {
|
|
12
|
+
let initParamsMock;
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
comp.grid.appendChild = jest.fn();
|
|
16
|
+
|
|
17
|
+
// Mock the return value of getParentPostInit
|
|
18
|
+
initParamsMock = {
|
|
19
|
+
widgets: "true",
|
|
20
|
+
focus: "pic",
|
|
21
|
+
picture: "somePicture",
|
|
22
|
+
};
|
|
23
|
+
comp._createInitParamsHandler();
|
|
24
|
+
comp._initParams.getParentPostInit = jest.fn();
|
|
25
|
+
comp._initParams.getParentPostInit.mockReturnValue(initParamsMock);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should not add widgets if widgets is false", () => {
|
|
29
|
+
initParamsMock.widgets = "false";
|
|
30
|
+
comp._initWidgets();
|
|
31
|
+
expect(comp.grid.appendChild).not.toHaveBeenCalled();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should handle widgets if width is not small", () => {
|
|
35
|
+
comp.isWidthSmall = () => false;
|
|
36
|
+
comp._initWidgets();
|
|
37
|
+
expect(comp.grid.appendChild).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should handle widgets if width is small", () => {
|
|
41
|
+
comp.isWidthSmall = () => true;
|
|
42
|
+
comp._initWidgets();
|
|
43
|
+
expect(comp.grid.appendChild).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
10
47
|
describe("getClassName", () => {
|
|
11
48
|
it("works", () => {
|
|
12
49
|
expect(comp.getClassName()).toBe("PhotoViewer");
|
|
@@ -1,12 +1,72 @@
|
|
|
1
1
|
import Viewer from "../../../src/components/core/Viewer";
|
|
2
2
|
import "./BasicMock";
|
|
3
3
|
|
|
4
|
+
jest.mock("../../../src/components/core/PhotoViewer", () => (
|
|
5
|
+
class PhotoViewer extends EventTarget {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.loader = { setAttribute: jest.fn() };
|
|
9
|
+
this.api = {
|
|
10
|
+
getMapStyle: () => ({}),
|
|
11
|
+
_getMapRequestTransform: () => ({}),
|
|
12
|
+
_endpoints: {},
|
|
13
|
+
};
|
|
14
|
+
this._t = { maplibre: {}, psv: {} };
|
|
15
|
+
this.grid = { appendChild: jest.fn() };
|
|
16
|
+
}
|
|
17
|
+
getAttribute() { return null; }
|
|
18
|
+
isWidthSmall() { return false; }
|
|
19
|
+
getSubComponentsNames() {
|
|
20
|
+
return ["loader", "api", "psv", "grid", "popup", "urlHandler"];
|
|
21
|
+
}
|
|
22
|
+
onceAPIReady() {
|
|
23
|
+
return Promise.resolve();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
));
|
|
27
|
+
|
|
4
28
|
let comp;
|
|
5
29
|
global.console = { info: jest.fn(), error: jest.fn(), warn: jest.fn(), log: global.console.log };
|
|
6
30
|
|
|
7
31
|
beforeEach(() => comp = new Viewer());
|
|
8
32
|
afterEach(() => jest.clearAllMocks());
|
|
9
33
|
|
|
34
|
+
describe("_initWidgets", () => {
|
|
35
|
+
let initParamsMock;
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
comp.grid.appendChild = jest.fn();
|
|
39
|
+
|
|
40
|
+
// Mock the return value of getParentPostInit
|
|
41
|
+
initParamsMock = {
|
|
42
|
+
widgets: "true",
|
|
43
|
+
focus: "pic",
|
|
44
|
+
picture: "somePicture",
|
|
45
|
+
};
|
|
46
|
+
comp._createInitParamsHandler();
|
|
47
|
+
comp._initParams.getParentPostInit = jest.fn();
|
|
48
|
+
comp._initParams.getParentPostInit.mockReturnValue(initParamsMock);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should not add widgets if widgets is false", () => {
|
|
52
|
+
initParamsMock.widgets = "false";
|
|
53
|
+
comp._initWidgets();
|
|
54
|
+
expect(comp.grid.appendChild).not.toHaveBeenCalled();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("should handle widgets if width is not small", () => {
|
|
58
|
+
comp.isWidthSmall = () => false;
|
|
59
|
+
comp._initWidgets();
|
|
60
|
+
expect(comp.grid.appendChild).toMatchSnapshot();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should handle widgets if width is small", () => {
|
|
64
|
+
comp.isWidthSmall = () => true;
|
|
65
|
+
comp._initWidgets();
|
|
66
|
+
expect(comp.grid.appendChild).toMatchSnapshot();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
10
70
|
describe("getClassName", () => {
|
|
11
71
|
it("works", () => {
|
|
12
72
|
expect(comp.getClassName()).toBe("Viewer");
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`_initWidgets should handle widgets if width is not small 1`] = `
|
|
4
|
+
[MockFunction] {
|
|
5
|
+
"calls": Array [
|
|
6
|
+
Array [
|
|
7
|
+
<pnx-widget-zoom
|
|
8
|
+
class="pnx-print-hidden"
|
|
9
|
+
slot="bottom-right"
|
|
10
|
+
/>,
|
|
11
|
+
],
|
|
12
|
+
Array [
|
|
13
|
+
<pnx-widget-share
|
|
14
|
+
class="pnx-print-hidden"
|
|
15
|
+
slot="bottom-right"
|
|
16
|
+
/>,
|
|
17
|
+
],
|
|
18
|
+
Array [
|
|
19
|
+
<pnx-widget-legend
|
|
20
|
+
focus="pic"
|
|
21
|
+
picture="somePicture"
|
|
22
|
+
slot="top-left"
|
|
23
|
+
/>,
|
|
24
|
+
],
|
|
25
|
+
Array [
|
|
26
|
+
<pnx-widget-player
|
|
27
|
+
class="pnx-only-psv pnx-print-hidden"
|
|
28
|
+
slot="top"
|
|
29
|
+
/>,
|
|
30
|
+
],
|
|
31
|
+
],
|
|
32
|
+
"results": Array [
|
|
33
|
+
Object {
|
|
34
|
+
"type": "return",
|
|
35
|
+
"value": undefined,
|
|
36
|
+
},
|
|
37
|
+
Object {
|
|
38
|
+
"type": "return",
|
|
39
|
+
"value": undefined,
|
|
40
|
+
},
|
|
41
|
+
Object {
|
|
42
|
+
"type": "return",
|
|
43
|
+
"value": undefined,
|
|
44
|
+
},
|
|
45
|
+
Object {
|
|
46
|
+
"type": "return",
|
|
47
|
+
"value": undefined,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
exports[`_initWidgets should handle widgets if width is small 1`] = `
|
|
54
|
+
[MockFunction] {
|
|
55
|
+
"calls": Array [
|
|
56
|
+
Array [
|
|
57
|
+
<pnx-widget-share
|
|
58
|
+
class="pnx-print-hidden"
|
|
59
|
+
slot="bottom-right"
|
|
60
|
+
/>,
|
|
61
|
+
],
|
|
62
|
+
Array [
|
|
63
|
+
<pnx-widget-legend
|
|
64
|
+
focus="pic"
|
|
65
|
+
picture="somePicture"
|
|
66
|
+
slot="top"
|
|
67
|
+
/>,
|
|
68
|
+
],
|
|
69
|
+
Array [
|
|
70
|
+
<pnx-widget-player
|
|
71
|
+
class="pnx-only-psv pnx-print-hidden"
|
|
72
|
+
slot="top"
|
|
73
|
+
/>,
|
|
74
|
+
],
|
|
75
|
+
],
|
|
76
|
+
"results": Array [
|
|
77
|
+
Object {
|
|
78
|
+
"type": "return",
|
|
79
|
+
"value": undefined,
|
|
80
|
+
},
|
|
81
|
+
Object {
|
|
82
|
+
"type": "return",
|
|
83
|
+
"value": undefined,
|
|
84
|
+
},
|
|
85
|
+
Object {
|
|
86
|
+
"type": "return",
|
|
87
|
+
"value": undefined,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`_initWidgets should handle widgets if width is not small 1`] = `
|
|
4
|
+
[MockFunction] {
|
|
5
|
+
"calls": Array [
|
|
6
|
+
Array [
|
|
7
|
+
<pnx-widget-zoom
|
|
8
|
+
class="pnx-print-hidden"
|
|
9
|
+
slot="bottom-right"
|
|
10
|
+
/>,
|
|
11
|
+
],
|
|
12
|
+
Array [
|
|
13
|
+
<pnx-widget-share
|
|
14
|
+
class="pnx-print-hidden"
|
|
15
|
+
slot="bottom-right"
|
|
16
|
+
/>,
|
|
17
|
+
],
|
|
18
|
+
Array [
|
|
19
|
+
<pnx-widget-legend
|
|
20
|
+
focus="pic"
|
|
21
|
+
picture="somePicture"
|
|
22
|
+
slot="top-left"
|
|
23
|
+
/>,
|
|
24
|
+
],
|
|
25
|
+
Array [
|
|
26
|
+
<pnx-widget-player
|
|
27
|
+
class="pnx-only-psv pnx-print-hidden"
|
|
28
|
+
slot="top"
|
|
29
|
+
/>,
|
|
30
|
+
],
|
|
31
|
+
Array [
|
|
32
|
+
<pnx-widget-geosearch
|
|
33
|
+
class="pnx-only-map pnx-print-hidden"
|
|
34
|
+
slot="top-left"
|
|
35
|
+
/>,
|
|
36
|
+
],
|
|
37
|
+
Array [
|
|
38
|
+
<pnx-widget-mapfilters
|
|
39
|
+
class="pnx-only-map pnx-print-hidden"
|
|
40
|
+
slot="top-left"
|
|
41
|
+
user-search="true"
|
|
42
|
+
/>,
|
|
43
|
+
],
|
|
44
|
+
Array [
|
|
45
|
+
<pnx-widget-maplayers
|
|
46
|
+
class="pnx-only-map pnx-print-hidden"
|
|
47
|
+
slot="top-right"
|
|
48
|
+
/>,
|
|
49
|
+
],
|
|
50
|
+
],
|
|
51
|
+
"results": Array [
|
|
52
|
+
Object {
|
|
53
|
+
"type": "return",
|
|
54
|
+
"value": undefined,
|
|
55
|
+
},
|
|
56
|
+
Object {
|
|
57
|
+
"type": "return",
|
|
58
|
+
"value": undefined,
|
|
59
|
+
},
|
|
60
|
+
Object {
|
|
61
|
+
"type": "return",
|
|
62
|
+
"value": undefined,
|
|
63
|
+
},
|
|
64
|
+
Object {
|
|
65
|
+
"type": "return",
|
|
66
|
+
"value": undefined,
|
|
67
|
+
},
|
|
68
|
+
Object {
|
|
69
|
+
"type": "return",
|
|
70
|
+
"value": undefined,
|
|
71
|
+
},
|
|
72
|
+
Object {
|
|
73
|
+
"type": "return",
|
|
74
|
+
"value": undefined,
|
|
75
|
+
},
|
|
76
|
+
Object {
|
|
77
|
+
"type": "return",
|
|
78
|
+
"value": undefined,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
exports[`_initWidgets should handle widgets if width is small 1`] = `
|
|
85
|
+
[MockFunction] {
|
|
86
|
+
"calls": Array [
|
|
87
|
+
Array [
|
|
88
|
+
<pnx-widget-zoom
|
|
89
|
+
class="pnx-only-map pnx-print-hidden"
|
|
90
|
+
slot="top-left"
|
|
91
|
+
/>,
|
|
92
|
+
],
|
|
93
|
+
Array [
|
|
94
|
+
<pnx-widget-share
|
|
95
|
+
class="pnx-print-hidden"
|
|
96
|
+
slot="bottom-right"
|
|
97
|
+
/>,
|
|
98
|
+
],
|
|
99
|
+
Array [
|
|
100
|
+
<pnx-widget-legend
|
|
101
|
+
focus="pic"
|
|
102
|
+
picture="somePicture"
|
|
103
|
+
slot="top"
|
|
104
|
+
/>,
|
|
105
|
+
],
|
|
106
|
+
Array [
|
|
107
|
+
<pnx-widget-player
|
|
108
|
+
class="pnx-only-psv pnx-print-hidden"
|
|
109
|
+
slot="top"
|
|
110
|
+
/>,
|
|
111
|
+
],
|
|
112
|
+
Array [
|
|
113
|
+
<pnx-widget-geosearch
|
|
114
|
+
class="pnx-only-map pnx-print-hidden"
|
|
115
|
+
slot="top-right"
|
|
116
|
+
/>,
|
|
117
|
+
],
|
|
118
|
+
Array [
|
|
119
|
+
<pnx-widget-mapfilters
|
|
120
|
+
class="pnx-only-map pnx-print-hidden"
|
|
121
|
+
slot="top-right"
|
|
122
|
+
user-search="true"
|
|
123
|
+
/>,
|
|
124
|
+
],
|
|
125
|
+
Array [
|
|
126
|
+
<pnx-widget-maplayers
|
|
127
|
+
class="pnx-only-map pnx-print-hidden"
|
|
128
|
+
slot="top-right"
|
|
129
|
+
/>,
|
|
130
|
+
],
|
|
131
|
+
],
|
|
132
|
+
"results": Array [
|
|
133
|
+
Object {
|
|
134
|
+
"type": "return",
|
|
135
|
+
"value": undefined,
|
|
136
|
+
},
|
|
137
|
+
Object {
|
|
138
|
+
"type": "return",
|
|
139
|
+
"value": undefined,
|
|
140
|
+
},
|
|
141
|
+
Object {
|
|
142
|
+
"type": "return",
|
|
143
|
+
"value": undefined,
|
|
144
|
+
},
|
|
145
|
+
Object {
|
|
146
|
+
"type": "return",
|
|
147
|
+
"value": undefined,
|
|
148
|
+
},
|
|
149
|
+
Object {
|
|
150
|
+
"type": "return",
|
|
151
|
+
"value": undefined,
|
|
152
|
+
},
|
|
153
|
+
Object {
|
|
154
|
+
"type": "return",
|
|
155
|
+
"value": undefined,
|
|
156
|
+
},
|
|
157
|
+
Object {
|
|
158
|
+
"type": "return",
|
|
159
|
+
"value": undefined,
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
}
|
|
163
|
+
`;
|