3d02f841a0
Fetch OpenWeatherMap in live log when a GPS fix is under six hours old, open a fix modal with manual coordinates when geolocation fails, and only show the undo bar after a successful save. Co-authored-by: Cursor <cursoragent@cursor.com>
21 lines
620 B
TypeScript
21 lines
620 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { normalizeGpsCoordinates, parseGpsCoordinate } from './geolocation.js'
|
|
|
|
describe('geolocation helpers', () => {
|
|
it('parses coordinates with comma decimals', () => {
|
|
expect(parseGpsCoordinate('54,123')).toBeCloseTo(54.123)
|
|
})
|
|
|
|
it('normalizes valid lat/lng', () => {
|
|
expect(normalizeGpsCoordinates('54.1', '10.2')).toEqual({
|
|
lat: '54.100000',
|
|
lng: '10.200000'
|
|
})
|
|
})
|
|
|
|
it('rejects out-of-range values', () => {
|
|
expect(normalizeGpsCoordinates('91', '0')).toBeNull()
|
|
expect(normalizeGpsCoordinates('0', '181')).toBeNull()
|
|
})
|
|
})
|