@flighthq/geolocation 0.2.0 → 0.2.1-next.410.a23f189
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/package.json +2 -2
- package/src/geolocation.test.ts +9 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/geolocation",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-next.410.a23f189",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/flighthq/flight.git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@flighthq/types": "0.2.
|
|
35
|
+
"@flighthq/types": "0.2.1-next.410.a23f189"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"typescript": "^5.3.0"
|
package/src/geolocation.test.ts
CHANGED
|
@@ -119,7 +119,10 @@ describe('createWebGeolocationBackend', () => {
|
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
it('reads a host-provided floorLevel from coords', async () => {
|
|
122
|
-
const
|
|
122
|
+
const hadOwn = Object.prototype.hasOwnProperty.call(navigator, 'geolocation');
|
|
123
|
+
const original =
|
|
124
|
+
Object.getOwnPropertyDescriptor(navigator, 'geolocation') ??
|
|
125
|
+
Object.getOwnPropertyDescriptor(Object.getPrototypeOf(navigator), 'geolocation');
|
|
123
126
|
Object.defineProperty(navigator, 'geolocation', {
|
|
124
127
|
configurable: true,
|
|
125
128
|
value: {
|
|
@@ -145,8 +148,11 @@ describe('createWebGeolocationBackend', () => {
|
|
|
145
148
|
const position = await backend.getCurrentPosition({});
|
|
146
149
|
expect(position?.floorLevel).toBe(3);
|
|
147
150
|
} finally {
|
|
148
|
-
if (original !== undefined)
|
|
149
|
-
|
|
151
|
+
if (hadOwn && original !== undefined) {
|
|
152
|
+
Object.defineProperty(navigator, 'geolocation', original);
|
|
153
|
+
} else {
|
|
154
|
+
delete (navigator as { geolocation?: unknown }).geolocation;
|
|
155
|
+
}
|
|
150
156
|
}
|
|
151
157
|
});
|
|
152
158
|
});
|