react-spatial 1.2.2 → 1.2.3-beta.3
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/LayerService.js +128 -184
- package/LayerService.js.map +7 -1
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +163 -221
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -1
- package/components/BaseLayerSwitcher/index.js +1 -3
- package/components/BaseLayerSwitcher/index.js.map +7 -1
- package/components/BasicMap/BasicMap.js +147 -285
- package/components/BasicMap/BasicMap.js.map +7 -1
- package/components/BasicMap/index.js +1 -3
- package/components/BasicMap/index.js.map +7 -1
- package/components/CanvasSaveButton/CanvasSaveButton.js +165 -419
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -1
- package/components/CanvasSaveButton/index.js +1 -3
- package/components/CanvasSaveButton/index.js.map +7 -1
- package/components/Copyright/Copyright.js +29 -70
- package/components/Copyright/Copyright.js.map +7 -1
- package/components/Copyright/index.js +1 -3
- package/components/Copyright/index.js.map +7 -1
- package/components/FeatureExportButton/FeatureExportButton.js +40 -106
- package/components/FeatureExportButton/FeatureExportButton.js.map +7 -1
- package/components/FeatureExportButton/index.js +1 -3
- package/components/FeatureExportButton/index.js.map +7 -1
- package/components/FilterButton/FilterButton.js +41 -106
- package/components/FilterButton/FilterButton.js.map +7 -1
- package/components/FilterButton/index.js +1 -3
- package/components/FilterButton/index.js.map +7 -1
- package/components/FitExtent/FitExtent.js +17 -50
- package/components/FitExtent/FitExtent.js.map +7 -1
- package/components/FitExtent/index.js +1 -3
- package/components/FitExtent/index.js.map +7 -1
- package/components/FollowButton/FollowButton.js +41 -111
- package/components/FollowButton/FollowButton.js.map +7 -1
- package/components/FollowButton/index.js +1 -3
- package/components/FollowButton/index.js.map +7 -1
- package/components/Geolocation/Geolocation.js +104 -213
- package/components/Geolocation/Geolocation.js.map +7 -1
- package/components/Geolocation/index.js +1 -3
- package/components/Geolocation/index.js.map +7 -1
- package/components/LayerTree/LayerTree.js +204 -410
- package/components/LayerTree/LayerTree.js.map +7 -1
- package/components/LayerTree/index.js +1 -3
- package/components/LayerTree/index.js.map +7 -1
- package/components/MousePosition/MousePosition.js +61 -130
- package/components/MousePosition/MousePosition.js.map +7 -1
- package/components/MousePosition/index.js +1 -3
- package/components/MousePosition/index.js.map +7 -1
- package/components/NorthArrow/NorthArrow.js +22 -62
- package/components/NorthArrow/NorthArrow.js.map +7 -1
- package/components/NorthArrow/index.js +1 -3
- package/components/NorthArrow/index.js.map +7 -1
- package/components/Overlay/Overlay.js +83 -130
- package/components/Overlay/Overlay.js.map +7 -1
- package/components/Overlay/index.js +1 -3
- package/components/Overlay/index.js.map +7 -1
- package/components/Permalink/Permalink.js +150 -244
- package/components/Permalink/Permalink.js.map +7 -1
- package/components/Permalink/index.js +1 -3
- package/components/Permalink/index.js.map +7 -1
- package/components/Popup/Popup.js +106 -233
- package/components/Popup/Popup.js.map +7 -1
- package/components/Popup/index.js +1 -3
- package/components/Popup/index.js.map +7 -1
- package/components/ResizeHandler/ResizeHandler.js +58 -113
- package/components/ResizeHandler/ResizeHandler.js.map +7 -1
- package/components/ResizeHandler/index.js +1 -3
- package/components/ResizeHandler/index.js.map +7 -1
- package/components/RouteSchedule/RouteSchedule.js +150 -283
- package/components/RouteSchedule/RouteSchedule.js.map +7 -1
- package/components/RouteSchedule/index.js +1 -3
- package/components/RouteSchedule/index.js.map +7 -1
- package/components/ScaleLine/ScaleLine.js +21 -45
- package/components/ScaleLine/ScaleLine.js.map +7 -1
- package/components/ScaleLine/index.js +1 -3
- package/components/ScaleLine/index.js.map +7 -1
- package/components/Search/Search.js +122 -186
- package/components/Search/Search.js.map +7 -1
- package/components/Search/SearchService.js +45 -69
- package/components/Search/SearchService.js.map +7 -1
- package/components/Search/engines/Engine.js +18 -25
- package/components/Search/engines/Engine.js.map +7 -1
- package/components/Search/engines/StopFinder.js +21 -38
- package/components/Search/engines/StopFinder.js.map +7 -1
- package/components/Search/index.js +3 -6
- package/components/Search/index.js.map +7 -1
- package/components/StopsFinder/StopsFinder.js +123 -174
- package/components/StopsFinder/StopsFinder.js.map +7 -1
- package/components/StopsFinder/StopsFinderOption.js +37 -54
- package/components/StopsFinder/StopsFinderOption.js.map +7 -1
- package/components/StopsFinder/index.js +1 -3
- package/components/StopsFinder/index.js.map +7 -1
- package/components/TrackerControl/TrackerControl.js +73 -128
- package/components/TrackerControl/TrackerControl.js.map +7 -1
- package/components/TrackerControl/index.js +1 -3
- package/components/TrackerControl/index.js.map +7 -1
- package/components/Zoom/Zoom.js +69 -112
- package/components/Zoom/Zoom.js.map +7 -1
- package/components/Zoom/index.js +1 -3
- package/components/Zoom/index.js.map +7 -1
- package/package.json +10 -5
- package/propTypes.js +17 -23
- package/propTypes.js.map +7 -1
- package/setupTests.js +2 -4
- package/setupTests.js.map +7 -1
- package/themes/README.md +26 -0
- package/themes/default/components.scss +0 -1
- package/themes/default/examples.scss +0 -1
- package/utils/GlobalsForOle.js +63 -64
- package/utils/GlobalsForOle.js.map +7 -1
- package/utils/KML.js +178 -364
- package/utils/KML.js.map +7 -1
- package/utils/KMLFormat.js +37 -73
- package/utils/KMLFormat.js.map +7 -1
- package/utils/Styles.js +24 -32
- package/utils/Styles.js.map +7 -1
- package/utils/getPolygonPattern.js +11 -44
- package/utils/getPolygonPattern.js.map +7 -1
- package/utils/timeUtils.js +16 -35
- package/utils/timeUtils.js.map +7 -1
- package/LayerService.test.js +0 -160
- package/LayerService.test.js.map +0 -1
- package/Projections.js +0 -16
- package/Projections.js.map +0 -1
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -88
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js.map +0 -1
- package/components/BaseLayerToggler/BaseLayerToggler.js +0 -490
- package/components/BaseLayerToggler/BaseLayerToggler.js.map +0 -1
- package/components/BaseLayerToggler/BaseLayerToggler.md.scss +0 -9
- package/components/BaseLayerToggler/BaseLayerToggler.scss +0 -49
- package/components/BaseLayerToggler/BaseLayerToggler.test.js +0 -127
- package/components/BaseLayerToggler/BaseLayerToggler.test.js.map +0 -1
- package/components/BaseLayerToggler/index.js +0 -3
- package/components/BaseLayerToggler/index.js.map +0 -1
- package/components/BasicMap/BasicMap.test.js +0 -288
- package/components/BasicMap/BasicMap.test.js.map +0 -1
- package/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -173
- package/components/CanvasSaveButton/CanvasSaveButton.test.js.map +0 -1
- package/components/Copyright/Copyright.test.js +0 -133
- package/components/Copyright/Copyright.test.js.map +0 -1
- package/components/FeatureExportButton/FeatureExportButton.test.js +0 -407
- package/components/FeatureExportButton/FeatureExportButton.test.js.map +0 -1
- package/components/FilterButton/FilterButton.test.js +0 -48
- package/components/FilterButton/FilterButton.test.js.map +0 -1
- package/components/FitExtent/FitExtent.test.js +0 -44
- package/components/FitExtent/FitExtent.test.js.map +0 -1
- package/components/FollowButton/FollowButton.test.js +0 -57
- package/components/FollowButton/FollowButton.test.js.map +0 -1
- package/components/Geolocation/Geolocation.test.js +0 -263
- package/components/Geolocation/Geolocation.test.js.map +0 -1
- package/components/LayerTree/LayerTree.test.js +0 -323
- package/components/LayerTree/LayerTree.test.js.map +0 -1
- package/components/MousePosition/MousePosition.test.js +0 -125
- package/components/MousePosition/MousePosition.test.js.map +0 -1
- package/components/NorthArrow/NorthArrow.test.js +0 -106
- package/components/NorthArrow/NorthArrow.test.js.map +0 -1
- package/components/Overlay/Overlay.test.js +0 -145
- package/components/Overlay/Overlay.test.js.map +0 -1
- package/components/Permalink/Permalink.test.js +0 -267
- package/components/Permalink/Permalink.test.js.map +0 -1
- package/components/Popup/Popup.test.js +0 -291
- package/components/Popup/Popup.test.js.map +0 -1
- package/components/ResizeHandler/ResizeHandler.test.js +0 -410
- package/components/ResizeHandler/ResizeHandler.test.js.map +0 -1
- package/components/RouteSchedule/RouteSchedule.test.js +0 -102
- package/components/RouteSchedule/RouteSchedule.test.js.map +0 -1
- package/components/ScaleLine/ScaleLine.test.js +0 -32
- package/components/ScaleLine/ScaleLine.test.js.map +0 -1
- package/components/Search/Search.test.js +0 -15
- package/components/Search/Search.test.js.map +0 -1
- package/components/StopsFinder/StopsFinder.test.js +0 -19
- package/components/StopsFinder/StopsFinder.test.js.map +0 -1
- package/components/TrackerControl/TrackerControl.test.js +0 -17
- package/components/TrackerControl/TrackerControl.test.js.map +0 -1
- package/components/Zoom/Zoom.test.js +0 -150
- package/components/Zoom/Zoom.test.js.map +0 -1
- package/styleguidist/ComponentsList.js +0 -52
- package/styleguidist/ComponentsList.js.map +0 -1
- package/styleguidist/StyleGuide.js +0 -253
- package/styleguidist/StyleGuide.js.map +0 -1
- package/utils/KML.test.js +0 -163
- package/utils/KML.test.js.map +0 -1
- package/utils/KMLFormat.test.js +0 -22
- package/utils/KMLFormat.test.js.map +0 -1
- package/utils/getPolygonPattern.test.js +0 -66
- package/utils/getPolygonPattern.test.js.map +0 -1
- package/utils/timeUtils.test.js +0 -32
- package/utils/timeUtils.test.js.map +0 -1
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
|
-
/* eslint-disable react/no-multi-comp,react/prefer-stateless-function,react/prop-types */
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { configure, mount, shallow } from 'enzyme';
|
|
5
|
-
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
|
6
|
-
import ResizeObserver from 'resize-observer-polyfill';
|
|
7
|
-
import ResizeHandler from './ResizeHandler';
|
|
8
|
-
|
|
9
|
-
jest.mock('resize-observer-polyfill');
|
|
10
|
-
|
|
11
|
-
configure({ adapter: new Adapter() });
|
|
12
|
-
|
|
13
|
-
var Div = /*@__PURE__*/(function (superclass) {
|
|
14
|
-
function Div () {
|
|
15
|
-
superclass.apply(this, arguments);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if ( superclass ) Div.__proto__ = superclass;
|
|
19
|
-
Div.prototype = Object.create( superclass && superclass.prototype );
|
|
20
|
-
Div.prototype.constructor = Div;
|
|
21
|
-
|
|
22
|
-
Div.prototype.render = function render () {
|
|
23
|
-
return React.createElement( 'div', null );
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return Div;
|
|
27
|
-
}(React.Component));
|
|
28
|
-
|
|
29
|
-
var BasicComponent = /*@__PURE__*/(function (superclass) {
|
|
30
|
-
function BasicComponent () {
|
|
31
|
-
superclass.apply(this, arguments);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if ( superclass ) BasicComponent.__proto__ = superclass;
|
|
35
|
-
BasicComponent.prototype = Object.create( superclass && superclass.prototype );
|
|
36
|
-
BasicComponent.prototype.constructor = BasicComponent;
|
|
37
|
-
|
|
38
|
-
BasicComponent.prototype.render = function render () {
|
|
39
|
-
var ref = this.props;
|
|
40
|
-
var onResize = ref.onResize;
|
|
41
|
-
var stylePropHeight = ref.stylePropHeight;
|
|
42
|
-
return (
|
|
43
|
-
React.createElement( 'div', { id: "basic" },
|
|
44
|
-
React.createElement( ResizeHandler, {
|
|
45
|
-
observe: this, onResize: onResize, stylePropHeight: stylePropHeight })
|
|
46
|
-
)
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return BasicComponent;
|
|
51
|
-
}(React.Component));
|
|
52
|
-
|
|
53
|
-
var BasicComponent3 = /*@__PURE__*/(function (superclass) {
|
|
54
|
-
function BasicComponent3 () {
|
|
55
|
-
superclass.apply(this, arguments);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if ( superclass ) BasicComponent3.__proto__ = superclass;
|
|
59
|
-
BasicComponent3.prototype = Object.create( superclass && superclass.prototype );
|
|
60
|
-
BasicComponent3.prototype.constructor = BasicComponent3;
|
|
61
|
-
|
|
62
|
-
BasicComponent3.prototype.render = function render () {
|
|
63
|
-
return (
|
|
64
|
-
React.createElement( 'div', { id: "basic" },
|
|
65
|
-
React.createElement( ResizeHandler, {
|
|
66
|
-
observe: this, maxHeightBrkpts: {
|
|
67
|
-
niedrig: 150,
|
|
68
|
-
hoch: Infinity,
|
|
69
|
-
}, maxWidthBrkpts: {
|
|
70
|
-
schmal: 150,
|
|
71
|
-
breit: Infinity,
|
|
72
|
-
} })
|
|
73
|
-
)
|
|
74
|
-
);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
return BasicComponent3;
|
|
78
|
-
}(React.Component));
|
|
79
|
-
|
|
80
|
-
var StrComponent = /*@__PURE__*/(function (superclass) {
|
|
81
|
-
function StrComponent () {
|
|
82
|
-
superclass.apply(this, arguments);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if ( superclass ) StrComponent.__proto__ = superclass;
|
|
86
|
-
StrComponent.prototype = Object.create( superclass && superclass.prototype );
|
|
87
|
-
StrComponent.prototype.constructor = StrComponent;
|
|
88
|
-
|
|
89
|
-
StrComponent.prototype.render = function render () {
|
|
90
|
-
return (
|
|
91
|
-
React.createElement( 'span', { id: "basic" },
|
|
92
|
-
React.createElement( ResizeHandler, { observe: "#basic" })
|
|
93
|
-
)
|
|
94
|
-
);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
return StrComponent;
|
|
98
|
-
}(React.Component));
|
|
99
|
-
|
|
100
|
-
var ThisComponent = /*@__PURE__*/(function (superclass) {
|
|
101
|
-
function ThisComponent () {
|
|
102
|
-
superclass.apply(this, arguments);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if ( superclass ) ThisComponent.__proto__ = superclass;
|
|
106
|
-
ThisComponent.prototype = Object.create( superclass && superclass.prototype );
|
|
107
|
-
ThisComponent.prototype.constructor = ThisComponent;
|
|
108
|
-
|
|
109
|
-
ThisComponent.prototype.render = function render () {
|
|
110
|
-
return (
|
|
111
|
-
React.createElement( 'div', null,
|
|
112
|
-
React.createElement( ResizeHandler, { observe: this })
|
|
113
|
-
)
|
|
114
|
-
);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
return ThisComponent;
|
|
118
|
-
}(React.Component));
|
|
119
|
-
|
|
120
|
-
var RefComponent = /*@__PURE__*/(function (superclass) {
|
|
121
|
-
function RefComponent(props) {
|
|
122
|
-
superclass.call(this, props);
|
|
123
|
-
this.ref = React.createRef();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if ( superclass ) RefComponent.__proto__ = superclass;
|
|
127
|
-
RefComponent.prototype = Object.create( superclass && superclass.prototype );
|
|
128
|
-
RefComponent.prototype.constructor = RefComponent;
|
|
129
|
-
|
|
130
|
-
RefComponent.prototype.render = function render () {
|
|
131
|
-
return (
|
|
132
|
-
React.createElement( React.Fragment, null,
|
|
133
|
-
React.createElement( Div, { ref: this.ref }),
|
|
134
|
-
React.createElement( ResizeHandler, { observe: this.ref })
|
|
135
|
-
)
|
|
136
|
-
);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
return RefComponent;
|
|
140
|
-
}(React.Component));
|
|
141
|
-
|
|
142
|
-
var CallbackComponent = /*@__PURE__*/(function (superclass) {
|
|
143
|
-
function CallbackComponent(props) {
|
|
144
|
-
superclass.call(this, props);
|
|
145
|
-
this.state = {
|
|
146
|
-
ref: null,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if ( superclass ) CallbackComponent.__proto__ = superclass;
|
|
151
|
-
CallbackComponent.prototype = Object.create( superclass && superclass.prototype );
|
|
152
|
-
CallbackComponent.prototype.constructor = CallbackComponent;
|
|
153
|
-
|
|
154
|
-
CallbackComponent.prototype.render = function render () {
|
|
155
|
-
var this$1 = this;
|
|
156
|
-
|
|
157
|
-
var ref$1 = this.state;
|
|
158
|
-
var ref = ref$1.ref;
|
|
159
|
-
return (
|
|
160
|
-
React.createElement( React.Fragment, null,
|
|
161
|
-
React.createElement( 'div', {
|
|
162
|
-
ref: function (node) {
|
|
163
|
-
if (node && !ref) {
|
|
164
|
-
this$1.setState({
|
|
165
|
-
ref: node,
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
} }),
|
|
169
|
-
React.createElement( ResizeHandler, { observe: ref })
|
|
170
|
-
)
|
|
171
|
-
);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
return CallbackComponent;
|
|
175
|
-
}(React.Component));
|
|
176
|
-
|
|
177
|
-
var RefNodeComponent = /*@__PURE__*/(function (superclass) {
|
|
178
|
-
function RefNodeComponent(props) {
|
|
179
|
-
superclass.call(this, props);
|
|
180
|
-
this.ref = React.createRef();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if ( superclass ) RefNodeComponent.__proto__ = superclass;
|
|
184
|
-
RefNodeComponent.prototype = Object.create( superclass && superclass.prototype );
|
|
185
|
-
RefNodeComponent.prototype.constructor = RefNodeComponent;
|
|
186
|
-
|
|
187
|
-
RefNodeComponent.prototype.render = function render () {
|
|
188
|
-
return (
|
|
189
|
-
React.createElement( React.Fragment, null,
|
|
190
|
-
React.createElement( 'div', { ref: this.ref }),
|
|
191
|
-
React.createElement( ResizeHandler, { observe: this.ref })
|
|
192
|
-
)
|
|
193
|
-
);
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
return RefNodeComponent;
|
|
197
|
-
}(React.Component));
|
|
198
|
-
|
|
199
|
-
// eslint-disable-next-line react/prefer-stateless-function
|
|
200
|
-
var CallbackNodeComponent = /*@__PURE__*/(function (superclass) {
|
|
201
|
-
function CallbackNodeComponent(props) {
|
|
202
|
-
superclass.call(this, props);
|
|
203
|
-
this.state = {
|
|
204
|
-
ref: null,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if ( superclass ) CallbackNodeComponent.__proto__ = superclass;
|
|
209
|
-
CallbackNodeComponent.prototype = Object.create( superclass && superclass.prototype );
|
|
210
|
-
CallbackNodeComponent.prototype.constructor = CallbackNodeComponent;
|
|
211
|
-
|
|
212
|
-
CallbackNodeComponent.prototype.render = function render () {
|
|
213
|
-
var this$1 = this;
|
|
214
|
-
|
|
215
|
-
var ref$1 = this.state;
|
|
216
|
-
var ref = ref$1.ref;
|
|
217
|
-
return (
|
|
218
|
-
React.createElement( React.Fragment, null,
|
|
219
|
-
React.createElement( 'div', {
|
|
220
|
-
ref: function (node) {
|
|
221
|
-
if (node && !ref) {
|
|
222
|
-
this$1.setState({
|
|
223
|
-
ref: node,
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
} }),
|
|
227
|
-
React.createElement( ResizeHandler, { observe: ref })
|
|
228
|
-
)
|
|
229
|
-
);
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
return CallbackNodeComponent;
|
|
233
|
-
}(React.Component));
|
|
234
|
-
|
|
235
|
-
var comps = [
|
|
236
|
-
ThisComponent,
|
|
237
|
-
RefComponent,
|
|
238
|
-
RefNodeComponent,
|
|
239
|
-
CallbackComponent,
|
|
240
|
-
CallbackNodeComponent ];
|
|
241
|
-
|
|
242
|
-
describe('ResizeHandler', function () {
|
|
243
|
-
describe('when observe property is not set', function () {
|
|
244
|
-
test("doesn't observe", function () {
|
|
245
|
-
var spy = jest.spyOn(ResizeObserver.prototype, 'observe');
|
|
246
|
-
shallow(React.createElement( ResizeHandler, null ));
|
|
247
|
-
expect(spy).not.toHaveBeenCalled();
|
|
248
|
-
spy.mockRestore();
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
test('disconnect on unmount', function () {
|
|
252
|
-
var wrapper = shallow(React.createElement( ResizeHandler, null ));
|
|
253
|
-
var spy = jest.spyOn(wrapper.instance().observer, 'disconnect');
|
|
254
|
-
wrapper.unmount();
|
|
255
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
describe('when observe property is set', function () {
|
|
260
|
-
test('try t get an html node from a string on (un)mount', function () {
|
|
261
|
-
var div = document.createElement('div');
|
|
262
|
-
document.querySelectorAll = jest.fn().mockImplementation(function () {
|
|
263
|
-
return [div];
|
|
264
|
-
});
|
|
265
|
-
var spy = jest.spyOn(ResizeObserver.prototype, 'observe');
|
|
266
|
-
var spy2 = jest.spyOn(ResizeObserver.prototype, 'disconnect');
|
|
267
|
-
mount(React.createElement( StrComponent, null ));
|
|
268
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
269
|
-
expect(spy.mock.calls[0][0]).toBe(div);
|
|
270
|
-
expect(spy2.mock.calls.length >= 1).toBe(true);
|
|
271
|
-
spy.mockRestore();
|
|
272
|
-
spy2.mockRestore();
|
|
273
|
-
document.querySelectorAll.mockRestore();
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
comps.forEach(function (Comp) {
|
|
277
|
-
test(("(un)observes an html node from " + (Comp.name) + " on (un)mount"), function () {
|
|
278
|
-
var spy = jest.spyOn(ResizeObserver.prototype, 'observe');
|
|
279
|
-
var spy2 = jest.spyOn(ResizeObserver.prototype, 'disconnect');
|
|
280
|
-
var wrapper = mount(React.createElement( Comp, null ));
|
|
281
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
282
|
-
expect(spy.mock.calls[0][0]).toBeInstanceOf(Element);
|
|
283
|
-
expect(spy2.mock.calls.length >= 1).toBe(true);
|
|
284
|
-
ResizeObserver.prototype.observe.mockRestore();
|
|
285
|
-
spy.mockRestore();
|
|
286
|
-
spy2.mockRestore();
|
|
287
|
-
wrapper.unmount();
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
test('set the default css class on resize ', function () {
|
|
292
|
-
var wrapper = mount(React.createElement( BasicComponent, null ));
|
|
293
|
-
var basic = wrapper.getDOMNode();
|
|
294
|
-
|
|
295
|
-
// The mock class set the onResize property, we just have to run it to
|
|
296
|
-
// simulate a resize
|
|
297
|
-
ResizeObserver.onResize([
|
|
298
|
-
{
|
|
299
|
-
target: basic,
|
|
300
|
-
contentRect: {
|
|
301
|
-
width: 200,
|
|
302
|
-
height: 200,
|
|
303
|
-
},
|
|
304
|
-
} ]);
|
|
305
|
-
expect(basic.className).toBe('rs-w-xs rs-h-xs');
|
|
306
|
-
|
|
307
|
-
ResizeObserver.onResize([
|
|
308
|
-
{
|
|
309
|
-
target: basic,
|
|
310
|
-
contentRect: {
|
|
311
|
-
width: 577,
|
|
312
|
-
height: 577,
|
|
313
|
-
},
|
|
314
|
-
} ]);
|
|
315
|
-
expect(basic.className).toBe('rs-w-s rs-h-s');
|
|
316
|
-
ResizeObserver.onResize([
|
|
317
|
-
{
|
|
318
|
-
target: basic,
|
|
319
|
-
contentRect: {
|
|
320
|
-
width: 769,
|
|
321
|
-
height: 769,
|
|
322
|
-
},
|
|
323
|
-
} ]);
|
|
324
|
-
expect(basic.className).toBe('rs-w-m rs-h-m');
|
|
325
|
-
ResizeObserver.onResize([
|
|
326
|
-
{
|
|
327
|
-
target: basic,
|
|
328
|
-
contentRect: {
|
|
329
|
-
width: 993,
|
|
330
|
-
height: 993,
|
|
331
|
-
},
|
|
332
|
-
} ]);
|
|
333
|
-
expect(basic.className).toBe('rs-w-l rs-h-l');
|
|
334
|
-
ResizeObserver.onResize([
|
|
335
|
-
{
|
|
336
|
-
target: basic,
|
|
337
|
-
contentRect: {
|
|
338
|
-
width: 1201,
|
|
339
|
-
height: 1201,
|
|
340
|
-
},
|
|
341
|
-
} ]);
|
|
342
|
-
expect(basic.className).toBe('rs-w-xl rs-h-xl');
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
test('uses user defined breakpoints', function () {
|
|
346
|
-
var wrapper = mount(React.createElement( BasicComponent3, null ));
|
|
347
|
-
var basic = wrapper.getDOMNode();
|
|
348
|
-
|
|
349
|
-
// The mock class set the onResize property, we just have to run it to
|
|
350
|
-
// simulate a resize
|
|
351
|
-
ResizeObserver.onResize([
|
|
352
|
-
{
|
|
353
|
-
target: basic,
|
|
354
|
-
contentRect: {
|
|
355
|
-
width: 100,
|
|
356
|
-
height: 100,
|
|
357
|
-
},
|
|
358
|
-
} ]);
|
|
359
|
-
expect(basic.className).toBe('rs-w-schmal rs-h-niedrig');
|
|
360
|
-
|
|
361
|
-
ResizeObserver.onResize([
|
|
362
|
-
{
|
|
363
|
-
target: basic,
|
|
364
|
-
contentRect: {
|
|
365
|
-
width: 1000,
|
|
366
|
-
height: 1000,
|
|
367
|
-
},
|
|
368
|
-
} ]);
|
|
369
|
-
expect(basic.className).toBe('rs-w-breit rs-h-hoch');
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
test('calls onResize property', function () {
|
|
373
|
-
var fn = jest.fn();
|
|
374
|
-
var wrapper = mount(React.createElement( BasicComponent, { onResize: fn }));
|
|
375
|
-
var basic = wrapper.getDOMNode();
|
|
376
|
-
|
|
377
|
-
// The mock class set the onResize property, we just have to run it to
|
|
378
|
-
// simulate a resize
|
|
379
|
-
ResizeObserver.onResize([
|
|
380
|
-
{
|
|
381
|
-
target: basic,
|
|
382
|
-
contentRect: {
|
|
383
|
-
width: 100,
|
|
384
|
-
height: 100,
|
|
385
|
-
},
|
|
386
|
-
} ]);
|
|
387
|
-
expect(fn).toHaveBeenCalledTimes(1);
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
test('set a style property on resize', function () {
|
|
391
|
-
var spy = jest.spyOn(document.documentElement.style, 'setProperty');
|
|
392
|
-
var wrapper = mount(React.createElement( BasicComponent, { stylePropHeight: "foo" }));
|
|
393
|
-
var basic = wrapper.getDOMNode();
|
|
394
|
-
|
|
395
|
-
// The mock class set the onResize property, we just have to run it to
|
|
396
|
-
// simulate a resize
|
|
397
|
-
ResizeObserver.onResize([
|
|
398
|
-
{
|
|
399
|
-
target: basic,
|
|
400
|
-
contentRect: {
|
|
401
|
-
width: 100,
|
|
402
|
-
height: 100,
|
|
403
|
-
},
|
|
404
|
-
} ]);
|
|
405
|
-
expect(spy).toHaveBeenCalledWith('foo', '7.68px');
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
});
|
|
409
|
-
|
|
410
|
-
//# sourceMappingURL=ResizeHandler.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResizeHandler.test.js","sources":["../../../src/components/ResizeHandler/ResizeHandler.test.js"],"sourcesContent":["/* eslint-disable max-classes-per-file */\n/* eslint-disable react/no-multi-comp,react/prefer-stateless-function,react/prop-types */\nimport React from 'react';\nimport { configure, mount, shallow } from 'enzyme';\nimport Adapter from '@wojtekmaj/enzyme-adapter-react-17';\nimport ResizeObserver from 'resize-observer-polyfill';\nimport ResizeHandler from './ResizeHandler';\n\njest.mock('resize-observer-polyfill');\n\nconfigure({ adapter: new Adapter() });\n\nclass Div extends React.Component {\n render() {\n return <div />;\n }\n}\n\nclass BasicComponent extends React.Component {\n render() {\n const { onResize, stylePropHeight } = this.props;\n return (\n <div id=\"basic\">\n <ResizeHandler\n observe={this}\n onResize={onResize}\n stylePropHeight={stylePropHeight}\n />\n </div>\n );\n }\n}\n\nclass BasicComponent3 extends React.Component {\n render() {\n return (\n <div id=\"basic\">\n <ResizeHandler\n observe={this}\n maxHeightBrkpts={{\n niedrig: 150,\n hoch: Infinity,\n }}\n maxWidthBrkpts={{\n schmal: 150,\n breit: Infinity,\n }}\n />\n </div>\n );\n }\n}\n\nclass StrComponent extends React.Component {\n render() {\n return (\n <span id=\"basic\">\n <ResizeHandler observe=\"#basic\" />\n </span>\n );\n }\n}\n\nclass ThisComponent extends React.Component {\n render() {\n return (\n <div>\n <ResizeHandler observe={this} />\n </div>\n );\n }\n}\n\nclass RefComponent extends React.Component {\n constructor(props) {\n super(props);\n this.ref = React.createRef();\n }\n\n render() {\n return (\n <>\n <Div ref={this.ref} />\n <ResizeHandler observe={this.ref} />\n </>\n );\n }\n}\n\nclass CallbackComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n ref: null,\n };\n }\n\n render() {\n const { ref } = this.state;\n return (\n <>\n <div\n ref={(node) => {\n if (node && !ref) {\n this.setState({\n ref: node,\n });\n }\n }}\n />\n <ResizeHandler observe={ref} />\n </>\n );\n }\n}\n\nclass RefNodeComponent extends React.Component {\n constructor(props) {\n super(props);\n this.ref = React.createRef();\n }\n\n render() {\n return (\n <>\n <div ref={this.ref} />\n <ResizeHandler observe={this.ref} />\n </>\n );\n }\n}\n\n// eslint-disable-next-line react/prefer-stateless-function\nclass CallbackNodeComponent extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n ref: null,\n };\n }\n\n render() {\n const { ref } = this.state;\n return (\n <>\n <div\n ref={(node) => {\n if (node && !ref) {\n this.setState({\n ref: node,\n });\n }\n }}\n />\n <ResizeHandler observe={ref} />\n </>\n );\n }\n}\n\nconst comps = [\n ThisComponent,\n RefComponent,\n RefNodeComponent,\n CallbackComponent,\n CallbackNodeComponent,\n];\n\ndescribe('ResizeHandler', () => {\n describe('when observe property is not set', () => {\n test(\"doesn't observe\", () => {\n const spy = jest.spyOn(ResizeObserver.prototype, 'observe');\n shallow(<ResizeHandler />);\n expect(spy).not.toHaveBeenCalled();\n spy.mockRestore();\n });\n\n test('disconnect on unmount', () => {\n const wrapper = shallow(<ResizeHandler />);\n const spy = jest.spyOn(wrapper.instance().observer, 'disconnect');\n wrapper.unmount();\n expect(spy).toHaveBeenCalledTimes(1);\n });\n });\n\n describe('when observe property is set', () => {\n test('try t get an html node from a string on (un)mount', () => {\n const div = document.createElement('div');\n document.querySelectorAll = jest.fn().mockImplementation(() => {\n return [div];\n });\n const spy = jest.spyOn(ResizeObserver.prototype, 'observe');\n const spy2 = jest.spyOn(ResizeObserver.prototype, 'disconnect');\n mount(<StrComponent />);\n expect(spy).toHaveBeenCalledTimes(1);\n expect(spy.mock.calls[0][0]).toBe(div);\n expect(spy2.mock.calls.length >= 1).toBe(true);\n spy.mockRestore();\n spy2.mockRestore();\n document.querySelectorAll.mockRestore();\n });\n\n comps.forEach((Comp) => {\n test(`(un)observes an html node from ${Comp.name} on (un)mount`, () => {\n const spy = jest.spyOn(ResizeObserver.prototype, 'observe');\n const spy2 = jest.spyOn(ResizeObserver.prototype, 'disconnect');\n const wrapper = mount(<Comp />);\n expect(spy).toHaveBeenCalledTimes(1);\n expect(spy.mock.calls[0][0]).toBeInstanceOf(Element);\n expect(spy2.mock.calls.length >= 1).toBe(true);\n ResizeObserver.prototype.observe.mockRestore();\n spy.mockRestore();\n spy2.mockRestore();\n wrapper.unmount();\n });\n });\n\n test('set the default css class on resize ', () => {\n const wrapper = mount(<BasicComponent />);\n const basic = wrapper.getDOMNode();\n\n // The mock class set the onResize property, we just have to run it to\n // simulate a resize\n ResizeObserver.onResize([\n {\n target: basic,\n contentRect: {\n width: 200,\n height: 200,\n },\n },\n ]);\n expect(basic.className).toBe('rs-w-xs rs-h-xs');\n\n ResizeObserver.onResize([\n {\n target: basic,\n contentRect: {\n width: 577,\n height: 577,\n },\n },\n ]);\n expect(basic.className).toBe('rs-w-s rs-h-s');\n ResizeObserver.onResize([\n {\n target: basic,\n contentRect: {\n width: 769,\n height: 769,\n },\n },\n ]);\n expect(basic.className).toBe('rs-w-m rs-h-m');\n ResizeObserver.onResize([\n {\n target: basic,\n contentRect: {\n width: 993,\n height: 993,\n },\n },\n ]);\n expect(basic.className).toBe('rs-w-l rs-h-l');\n ResizeObserver.onResize([\n {\n target: basic,\n contentRect: {\n width: 1201,\n height: 1201,\n },\n },\n ]);\n expect(basic.className).toBe('rs-w-xl rs-h-xl');\n });\n\n test('uses user defined breakpoints', () => {\n const wrapper = mount(<BasicComponent3 />);\n const basic = wrapper.getDOMNode();\n\n // The mock class set the onResize property, we just have to run it to\n // simulate a resize\n ResizeObserver.onResize([\n {\n target: basic,\n contentRect: {\n width: 100,\n height: 100,\n },\n },\n ]);\n expect(basic.className).toBe('rs-w-schmal rs-h-niedrig');\n\n ResizeObserver.onResize([\n {\n target: basic,\n contentRect: {\n width: 1000,\n height: 1000,\n },\n },\n ]);\n expect(basic.className).toBe('rs-w-breit rs-h-hoch');\n });\n\n test('calls onResize property', () => {\n const fn = jest.fn();\n const wrapper = mount(<BasicComponent onResize={fn} />);\n const basic = wrapper.getDOMNode();\n\n // The mock class set the onResize property, we just have to run it to\n // simulate a resize\n ResizeObserver.onResize([\n {\n target: basic,\n contentRect: {\n width: 100,\n height: 100,\n },\n },\n ]);\n expect(fn).toHaveBeenCalledTimes(1);\n });\n\n test('set a style property on resize', () => {\n const spy = jest.spyOn(document.documentElement.style, 'setProperty');\n const wrapper = mount(<BasicComponent stylePropHeight=\"foo\" />);\n const basic = wrapper.getDOMNode();\n\n // The mock class set the onResize property, we just have to run it to\n // simulate a resize\n ResizeObserver.onResize([\n {\n target: basic,\n contentRect: {\n width: 100,\n height: 100,\n },\n },\n ]);\n expect(spy).toHaveBeenCalledWith('foo', '7.68px');\n });\n });\n});\n"],"names":["const","super","this"],"mappings":"AAAA;AACA;AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,SAAS,SAAS,EAAE,KAAK,EAAE,OAAO,QAAQ,QAAQ,CAAC;AACnD,OAAO,OAAO,MAAM,oCAAoC,CAAC;AACzD,OAAO,cAAc,MAAM,0BAA0B,CAAC;AACtD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C;AACA,IAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;AACtC;AACA,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC;AACtC;AACA,IAAM,GAAG,GAAwB;;;;;;;;;gBAC/B,yBAAM,GAAG;AACX,IAAI,OAAO,sBAAC,UAAG,EAAG,CAAC;AACnB;;;EAHkB,KAAK,CAAC,YAIvB;AACD;AACA,IAAM,cAAc,GAAwB;;;;;;;;;2BAC1C,yBAAM,GAAG;AACX,WAAuC,GAAG,IAAI,CAAC;IAAnC;IAAU,0CAA+B;AACrD,IAAI,OAAO;AACX,MAAM,sBAAC,OAAG,CAAC,IAAG,UAAQ;AACtB,QAAQ,qBAAC,gBAAa;AACtB,UAAU,SAAS,IAAK,EACd,UAAU,QAAS,EACnB,iBAAiB,iBAAgB,CACjC;AACV,MAAM,CAAM;AACZ,KAAK,CAAC;AACN;;;EAZ6B,KAAK,CAAC,YAalC;AACD;AACA,IAAM,eAAe,GAAwB;;;;;;;;;4BAC3C,yBAAM,GAAG;AACX,IA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AW;AACX,SAAS,CACH,CAAC,CAAC,CAAC;AACT,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACxD,KAAK,CAAC,CAAC;AACP,GAAG,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import renderer from 'react-test-renderer';
|
|
3
|
-
import 'jest-date-mock';
|
|
4
|
-
import { TrajservLayer } from 'mobility-toolbox-js/ol';
|
|
5
|
-
import RouteSchedule from '.';
|
|
6
|
-
|
|
7
|
-
var RealDate = Date;
|
|
8
|
-
|
|
9
|
-
var lineInfos = {
|
|
10
|
-
backgroundColor: 'ff8a00',
|
|
11
|
-
destination: 'Station name',
|
|
12
|
-
id: 9959310,
|
|
13
|
-
routeIdentifier: '03634.003849.004:9',
|
|
14
|
-
longName: 'T 3',
|
|
15
|
-
shortName: '3',
|
|
16
|
-
operator: 'foo',
|
|
17
|
-
operatorUrl: 'foo.ch',
|
|
18
|
-
publisher: 'bar',
|
|
19
|
-
publisherUrl: 'bar.ch',
|
|
20
|
-
stations: [
|
|
21
|
-
{
|
|
22
|
-
stationId: '1',
|
|
23
|
-
stationName: 'first stop',
|
|
24
|
-
coordinates: [8.51772, 47.3586],
|
|
25
|
-
arrivalDelay: 60000, // +1m
|
|
26
|
-
arrivalTime: 1571729580000,
|
|
27
|
-
departureDelay: 60000,
|
|
28
|
-
departureTime: 1571729580000,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
stationId: '2',
|
|
32
|
-
stationName: 'second stop',
|
|
33
|
-
coordinates: [8.54119, 47.36646],
|
|
34
|
-
arrivalDelay: 0, // +0
|
|
35
|
-
arrivalTime: 1571729903000,
|
|
36
|
-
departureDelay: 120000, // +2m
|
|
37
|
-
departureTime: 1571729903000,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
stationId: '4',
|
|
41
|
-
stationName: 'no stop',
|
|
42
|
-
coordinates: [8.54119, 47.36646],
|
|
43
|
-
arrivalDelay: null, // +0
|
|
44
|
-
arrivalTime: 0,
|
|
45
|
-
departureDelay: null, // +2m
|
|
46
|
-
departureTime: 0,
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
stationId: '3',
|
|
50
|
-
stationName: 'third stop',
|
|
51
|
-
coordinates: [8.54119, 50],
|
|
52
|
-
arrivalDelay: 240000, // +4m
|
|
53
|
-
arrivalTime: 1571730323000,
|
|
54
|
-
departureDelay: 0, // +0
|
|
55
|
-
departureTime: 0,
|
|
56
|
-
} ],
|
|
57
|
-
vehicleType: 0,
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
describe('RouteSchedule', function () {
|
|
61
|
-
beforeEach(function () {
|
|
62
|
-
global.Date = jest.fn(function () {
|
|
63
|
-
return {
|
|
64
|
-
getHours: function () {
|
|
65
|
-
return 9;
|
|
66
|
-
},
|
|
67
|
-
getMinutes: function () {
|
|
68
|
-
return 1;
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
Object.assign(Date, RealDate);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
afterEach(function () {
|
|
76
|
-
global.Date = RealDate;
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('matches snapshots.', function () {
|
|
80
|
-
var trackerLayer = new TrajservLayer();
|
|
81
|
-
var component = renderer.create(
|
|
82
|
-
React.createElement( RouteSchedule, {
|
|
83
|
-
lineInfos: lineInfos, trackerLayer: trackerLayer, setCenter: function () {}, renderHeaderButtons: function () {
|
|
84
|
-
return React.createElement( 'div', null, "Button" );
|
|
85
|
-
} })
|
|
86
|
-
);
|
|
87
|
-
var tree = component.toJSON();
|
|
88
|
-
expect(tree).toMatchSnapshot();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// to test: on station click
|
|
92
|
-
// to test: time formating
|
|
93
|
-
// to test: delay formating
|
|
94
|
-
// to test: delay color
|
|
95
|
-
// to test: no arrival delay on first station
|
|
96
|
-
// to test: no arrival date on first station
|
|
97
|
-
// to test: no departure delay on last station
|
|
98
|
-
// to test: no departure date on last station
|
|
99
|
-
// to test: font bold on first and last station
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
//# sourceMappingURL=RouteSchedule.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RouteSchedule.test.js","sources":["../../../src/components/RouteSchedule/RouteSchedule.test.js"],"sourcesContent":["import React from 'react';\nimport renderer from 'react-test-renderer';\nimport 'jest-date-mock';\nimport { TrajservLayer } from 'mobility-toolbox-js/ol';\nimport RouteSchedule from '.';\n\nconst RealDate = Date;\n\nconst lineInfos = {\n backgroundColor: 'ff8a00',\n destination: 'Station name',\n id: 9959310,\n routeIdentifier: '03634.003849.004:9',\n longName: 'T 3',\n shortName: '3',\n operator: 'foo',\n operatorUrl: 'foo.ch',\n publisher: 'bar',\n publisherUrl: 'bar.ch',\n stations: [\n {\n stationId: '1',\n stationName: 'first stop',\n coordinates: [8.51772, 47.3586],\n arrivalDelay: 60000, // +1m\n arrivalTime: 1571729580000,\n departureDelay: 60000,\n departureTime: 1571729580000,\n },\n {\n stationId: '2',\n stationName: 'second stop',\n coordinates: [8.54119, 47.36646],\n arrivalDelay: 0, // +0\n arrivalTime: 1571729903000,\n departureDelay: 120000, // +2m\n departureTime: 1571729903000,\n },\n {\n stationId: '4',\n stationName: 'no stop',\n coordinates: [8.54119, 47.36646],\n arrivalDelay: null, // +0\n arrivalTime: 0,\n departureDelay: null, // +2m\n departureTime: 0,\n },\n {\n stationId: '3',\n stationName: 'third stop',\n coordinates: [8.54119, 50],\n arrivalDelay: 240000, // +4m\n arrivalTime: 1571730323000,\n departureDelay: 0, // +0\n departureTime: 0,\n },\n ],\n vehicleType: 0,\n};\n\ndescribe('RouteSchedule', () => {\n beforeEach(() => {\n global.Date = jest.fn(() => {\n return {\n getHours: () => {\n return 9;\n },\n getMinutes: () => {\n return 1;\n },\n };\n });\n Object.assign(Date, RealDate);\n });\n\n afterEach(() => {\n global.Date = RealDate;\n });\n\n test('matches snapshots.', () => {\n const trackerLayer = new TrajservLayer();\n const component = renderer.create(\n <RouteSchedule\n lineInfos={lineInfos}\n trackerLayer={trackerLayer}\n setCenter={() => {}}\n renderHeaderButtons={() => {\n return <div>Button</div>;\n }}\n />,\n );\n const tree = component.toJSON();\n expect(tree).toMatchSnapshot();\n });\n\n // to test: on station click\n // to test: time formating\n // to test: delay formating\n // to test: delay color\n // to test: no arrival delay on first station\n // to test: no arrival date on first station\n // to test: no departure delay on last station\n // to test: no departure date on last station\n // to test: font bold on first and last station\n});\n"],"names":["const"],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAC3C,OAAO,gBAAgB,CAAC;AACxB,SAAS,aAAa,QAAQ,wBAAwB,CAAC;AACvD,OAAO,aAAa,MAAM,GAAG,CAAC;AAC9B;AACAA,GAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;AACtB;AACAA,GAAK,CAAC,SAAS,GAAG;AAClB,EAAE,eAAe,EAAE,QAAQ;AAC3B,EAAE,WAAW,EAAE,cAAc;AAC7B,EAAE,EAAE,EAAE,OAAO;AACb,EAAE,eAAe,EAAE,oBAAoB;AACvC,EAAE,QAAQ,EAAE,KAAK;AACjB,EAAE,SAAS,EAAE,GAAG;AAChB,EAAE,QAAQ,EAAE,KAAK;AACjB,EAAE,WAAW,EAAE,QAAQ;AACvB,EAAE,SAAS,EAAE,KAAK;AAClB,EAAE,YAAY,EAAE,QAAQ;AACxB,EAAE,QAAQ,EAAE;AACZ,IAAI;AACJ,MAAM,SAAS,EAAE,GAAG;AACpB,MAAM,WAAW,EAAE,YAAY;AAC/B,MAAM,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;AACrC,MAAM,YAAY,EAAE,KAAK;AACzB,MAAM,WAAW,EAAE,aAAa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AACR,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAClC,GAAG,CAAC,CAAC;AACL;AACA,EAAE,SAAS,UAAC,GAAM;AAClB,IAAI,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;AAC3B,GAAG,CAAC,CAAC;AACL;AACA,EAAE,IAAI,CAAC,oBAAoB,WAAE,GAAM;AACnC,IAAIA,GAAK,CAAC,YAAY,GAAG,IAAI,aAAa,EAAE,CAAC;AAC7C,IAAIA,GAAK,CAAC,SAAS,GAAG,QAAQ,CAAC,MAAM;AACrC,MAAM,qBAAC,gBAAa;AACpB,QAAQ,WAAW,SAAU,EACrB,cAAc,YAAa,EAC3B,oBAAW,GAAM,EAAG,EACpB,8BAAqB,GAAM;AACnC,UAAU,OAAO,sBAAC,YAAI,QAAM,EAAM,CAAC;AACnC,WAAU,CACD;AACT,KAAK,CAAC;AACN,IAAIA,GAAK,CAAC,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;AACpC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACnC,GAAG,CAAC,CAAC;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC,CAAC,CAAC;"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import 'jest-canvas-mock';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { configure, mount } from 'enzyme';
|
|
4
|
-
import OLMap from 'ol/Map';
|
|
5
|
-
import OLView from 'ol/View';
|
|
6
|
-
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
|
7
|
-
import renderer from 'react-test-renderer';
|
|
8
|
-
import ScaleLine from './ScaleLine';
|
|
9
|
-
|
|
10
|
-
configure({ adapter: new Adapter() });
|
|
11
|
-
|
|
12
|
-
describe('ScaleLine', function () {
|
|
13
|
-
test('matches snapshot', function () {
|
|
14
|
-
var map = new OLMap({ view: new OLView({ zoom: 7, center: [0, 0] }) });
|
|
15
|
-
var component = renderer.create(React.createElement( ScaleLine, { map: map }));
|
|
16
|
-
var tree = component.toJSON();
|
|
17
|
-
expect(tree).toMatchSnapshot();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('remove control on unmount.', function () {
|
|
21
|
-
var map = new OLMap({});
|
|
22
|
-
var spy = jest.spyOn(map, 'removeControl');
|
|
23
|
-
var spy2 = jest.spyOn(map, 'addControl');
|
|
24
|
-
var wrapper = mount(React.createElement( ScaleLine, { map: map }));
|
|
25
|
-
expect(spy).toHaveBeenCalledTimes(0);
|
|
26
|
-
wrapper.unmount();
|
|
27
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
28
|
-
expect(spy.mock.calls[0][0]).toBe(spy2.mock.calls[0][0]);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
//# sourceMappingURL=ScaleLine.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ScaleLine.test.js","sources":["../../../src/components/ScaleLine/ScaleLine.test.js"],"sourcesContent":["import 'jest-canvas-mock';\nimport React from 'react';\nimport { configure, mount } from 'enzyme';\nimport OLMap from 'ol/Map';\nimport OLView from 'ol/View';\nimport Adapter from '@wojtekmaj/enzyme-adapter-react-17';\nimport renderer from 'react-test-renderer';\nimport ScaleLine from './ScaleLine';\n\nconfigure({ adapter: new Adapter() });\n\ndescribe('ScaleLine', () => {\n test('matches snapshot', () => {\n const map = new OLMap({ view: new OLView({ zoom: 7, center: [0, 0] }) });\n const component = renderer.create(<ScaleLine map={map} />);\n const tree = component.toJSON();\n expect(tree).toMatchSnapshot();\n });\n\n test('remove control on unmount.', () => {\n const map = new OLMap({});\n const spy = jest.spyOn(map, 'removeControl');\n const spy2 = jest.spyOn(map, 'addControl');\n const wrapper = mount(<ScaleLine map={map} />);\n expect(spy).toHaveBeenCalledTimes(0);\n wrapper.unmount();\n expect(spy).toHaveBeenCalledTim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IAAIA,GAAK,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;AAC/C,IAAIA,GAAK,CAAC,OAAO,GAAG,KAAK,CAAC,qBAAC,YAAS,CAAC,KAAK,KAAI,CAAG,CAAC,CAAC;AACnD,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;AACzC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;AACtB,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;AACzC,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,GAAG,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import renderer from 'react-test-renderer';
|
|
3
|
-
import Search from '.';
|
|
4
|
-
|
|
5
|
-
describe('Search', function () {
|
|
6
|
-
test('matches snapshots.', function () {
|
|
7
|
-
var component = renderer.create(React.createElement( Search, null ));
|
|
8
|
-
expect(component.toJSON()).toMatchSnapshot();
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
// to test: custom props
|
|
13
|
-
// to test: searching
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=Search.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Search.test.js","sources":["../../../src/components/Search/Search.test.js"],"sourcesContent":["import React from 'react';\nimport renderer from 'react-test-renderer';\nimport Search from '.';\n\ndescribe('Search', () => {\n test('matches snapshots.', () => {\n const component = renderer.create(<Search />);\n expect(component.toJSON()).toMatchSnapshot();\n });\n});\n\n// to test: custom props\n// to test: searching\n"],"names":["const"],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAC3C,OAAO,MAAM,MAAM,GAAG,CAAC;AACvB;AACA,QAAQ,CAAC,QAAQ,WAAE,GAAM;AACzB,EAAE,IAAI,CAAC,oBAAoB,WAAE,GAAM;AACnC,IAAIA,GAAK,CAAC,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,qBAAC,YAAM,EAAG,CAAC,CAAC;AAClD,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC;AACjD,GAAG,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AACH;AACA;AACA;"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import renderer from 'react-test-renderer';
|
|
3
|
-
import { Map } from 'ol';
|
|
4
|
-
import StopsFinder from '.';
|
|
5
|
-
|
|
6
|
-
describe('StopsFinder', function () {
|
|
7
|
-
var map;
|
|
8
|
-
|
|
9
|
-
beforeEach(function () {
|
|
10
|
-
map = new Map({});
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('matches snapshots.', function () {
|
|
14
|
-
var component = renderer.create(React.createElement( StopsFinder, { map: map }));
|
|
15
|
-
expect(component.toJSON()).toMatchSnapshot();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=StopsFinder.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StopsFinder.test.js","sources":["../../../src/components/StopsFinder/StopsFinder.test.js"],"sourcesContent":["import React from 'react';\nimport renderer from 'react-test-renderer';\nimport { Map } from 'ol';\nimport StopsFinder from '.';\n\ndescribe('StopsFinder', () => {\n let map;\n\n beforeEach(() => {\n map = new Map({});\n });\n\n test('matches snapshots.', () => {\n const component = renderer.create(<StopsFinder map={map} />);\n expect(component.toJSON()).toMatchSnapshot();\n });\n});\n"],"names":["let","const"],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAC3C,SAAS,GAAG,QAAQ,IAAI,CAAC;AACzB,OAAO,WAAW,MAAM,GAAG,CAAC;AAC5B;AACA,QAAQ,CAAC,aAAa,WAAE,GAAM;AAC9B,EAAEA,GAAG,CAAC,GAAG,CAAC;AACV;AACA,EAAE,UAAU,UAAC,GAAM;AACnB,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC;AACtB,GAAG,CAAC,CAAC;AACL;AACA,EAAE,IAAI,CAAC,oBAAoB,WAAE,GAAM;AACnC,IAAIC,GAAK,CAAC,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,qBAAC,cAAW,CAAC,KAAK,KAAI,CAAG,CAAC,CAAC;AACjE,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC;AACjD,GAAG,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import renderer from 'react-test-renderer';
|
|
3
|
-
import { TrajservLayer } from 'mobility-toolbox-js/ol';
|
|
4
|
-
import TrackerControl from '.';
|
|
5
|
-
|
|
6
|
-
describe('TrackerControl', function () {
|
|
7
|
-
test('matches snapshots.', function () {
|
|
8
|
-
var trackerLayer = new TrajservLayer();
|
|
9
|
-
var component = renderer.create(
|
|
10
|
-
React.createElement( TrackerControl, { trackerLayer: trackerLayer })
|
|
11
|
-
);
|
|
12
|
-
var tree = component.toJSON();
|
|
13
|
-
expect(tree).toMatchSnapshot();
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=TrackerControl.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TrackerControl.test.js","sources":["../../../src/components/TrackerControl/TrackerControl.test.js"],"sourcesContent":["import React from 'react';\nimport renderer from 'react-test-renderer';\nimport { TrajservLayer } from 'mobility-toolbox-js/ol';\nimport TrackerControl from '.';\n\ndescribe('TrackerControl', () => {\n test('matches snapshots.', () => {\n const trackerLayer = new TrajservLayer();\n const component = renderer.create(\n <TrackerControl trackerLayer={trackerLayer} />,\n );\n const tree = component.toJSON();\n expect(tree).toMatchSnapshot();\n });\n});\n"],"names":["const"],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAC3C,SAAS,aAAa,QAAQ,wBAAwB,CAAC;AACvD,OAAO,cAAc,MAAM,GAAG,CAAC;AAC/B;AACA,QAAQ,CAAC,gBAAgB,WAAE,GAAM;AACjC,EAAE,IAAI,CAAC,oBAAoB,WAAE,GAAM;AACnC,IAAIA,GAAK,CAAC,YAAY,GAAG,IAAI,aAAa,EAAE,CAAC;AAC7C,IAAIA,GAAK,CAAC,SAAS,GAAG,QAAQ,CAAC,MAAM;AACrC,MAAM,qBAAC,iBAAc,CAAC,cAAc,cAAa,CAAI;AACrD,KAAK,CAAC;AACN,IAAIA,GAAK,CAAC,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;AACpC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;AACnC,GAAG,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;"}
|