Update planner, check-in records, location service and tests
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { getCurrentGcj02Location, isLocationPermissionDenied } from '../src/services/location'
|
||||
import {
|
||||
getCurrentGcj02Location,
|
||||
isLocationPermissionDenied,
|
||||
isLocationSnapshotFresh,
|
||||
} from '../src/services/location'
|
||||
|
||||
describe('current location adapter', () => {
|
||||
beforeEach(() => {
|
||||
@@ -73,4 +77,16 @@ describe('current location adapter', () => {
|
||||
expect(isLocationPermissionDenied({ errMsg: 'getLocation:fail privacy permission is not authorized' })).toBe(false)
|
||||
expect(isLocationPermissionDenied({ errMsg: 'getLocation:fail system error' })).toBe(false)
|
||||
})
|
||||
|
||||
it('evaluates location freshness at exact boundaries and rejects invalid clocks', () => {
|
||||
const capturedAt = '2026-07-31T02:00:00.000Z'
|
||||
const capturedTimestamp = Date.parse(capturedAt)
|
||||
const maxAgeMs = 5 * 60 * 1000
|
||||
|
||||
expect(isLocationSnapshotFresh(capturedAt, capturedTimestamp, maxAgeMs)).toBe(true)
|
||||
expect(isLocationSnapshotFresh(capturedAt, capturedTimestamp + maxAgeMs, maxAgeMs)).toBe(true)
|
||||
expect(isLocationSnapshotFresh(capturedAt, capturedTimestamp + maxAgeMs + 1, maxAgeMs)).toBe(false)
|
||||
expect(isLocationSnapshotFresh(capturedAt, capturedTimestamp - 1, maxAgeMs)).toBe(false)
|
||||
expect(isLocationSnapshotFresh('invalid', capturedTimestamp, maxAgeMs)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user