mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 05:21:15 +00:00
fix(native): location at the accuracy asked for, and a Play payment that clears later is redeemed
- The location shim runs at high accuracy only while a watcher wants it and drops back once that watcher is gone, instead of keeping the 2 s GPS rate for the rest of the session. - The purchase client can hand over a Play subscription that was paid but never delivered (a pending payment that cleared later), and the plans screen redeems it at once, as a restore would, before Google Play refunds it after three days.
This commit is contained in:
@@ -55,6 +55,22 @@ describe('native geolocation', () => {
|
||||
expect(TrekShell.stopLocation).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('runs at high accuracy only while a watcher asks for it, and drops back after', () => {
|
||||
installNativeGeolocation();
|
||||
const passive = navigator.geolocation.watchPosition(vi.fn());
|
||||
expect(TrekShell.startLocation).toHaveBeenLastCalledWith({ highAccuracy: false });
|
||||
const tracking = navigator.geolocation.watchPosition(vi.fn(), undefined, { enableHighAccuracy: true });
|
||||
expect(TrekShell.startLocation).toHaveBeenLastCalledWith({ highAccuracy: true });
|
||||
navigator.geolocation.clearWatch(tracking);
|
||||
expect(TrekShell.startLocation).toHaveBeenLastCalledWith({ highAccuracy: false });
|
||||
expect(TrekShell.startLocation).toHaveBeenCalledTimes(3);
|
||||
// A later passive watch does not inherit the high accuracy.
|
||||
navigator.geolocation.watchPosition(vi.fn());
|
||||
expect(TrekShell.startLocation).toHaveBeenCalledTimes(3);
|
||||
navigator.geolocation.clearWatch(passive);
|
||||
expect(TrekShell.stopLocation).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('settles a one-off request with the first fix, and passes a denial on as the Geolocation error', async () => {
|
||||
installNativeGeolocation();
|
||||
const once = vi.fn();
|
||||
|
||||
Reference in New Issue
Block a user