Files
kapteins-daagbok/client/src/utils/openWeatherMap.test.ts
T
elpatron 3d02f841a0 Add live journal OWM weather and manual GPS fix dialog.
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>
2026-06-01 09:03:37 +02:00

30 lines
934 B
TypeScript

import { describe, expect, it } from 'vitest'
import {
formatWindStrengthBeaufort,
mpsToBeaufort,
parseOwmCurrentWeather
} from './openWeatherMap.js'
describe('openWeatherMap', () => {
it('maps m/s to Beaufort', () => {
expect(mpsToBeaufort(0)).toBe(0)
expect(mpsToBeaufort(5)).toBe(3)
expect(mpsToBeaufort(15)).toBe(7)
expect(formatWindStrengthBeaufort(5)).toBe('3 Bft (5.0 m/s)')
})
it('parses OWM current weather payload', () => {
const parsed = parseOwmCurrentWeather({
wind: { speed: 8.5, deg: 225 },
main: { pressure: 1018, temp: 17.4 },
weather: [{ icon: '04d', description: 'Bedeckt' }]
})
expect(parsed.windDirection).toBe('SW')
expect(parsed.windStrength).toBe('5 Bft (8.5 m/s)')
expect(parsed.windPressure).toBe('1018')
expect(parsed.tempC).toBe('17.4')
expect(parsed.precipText).toBe('Bedeckt')
expect(parsed.weatherIcon).toBe('04d')
})
})