test: add weather logic test suite
All checks were successful
CI / Lint, test, typecheck and build (push) Successful in 9m58s

This commit is contained in:
zv
2026-06-14 20:44:37 +02:00
parent ee55521803
commit bdba3c709c
11 changed files with 1357 additions and 10 deletions

View File

@@ -0,0 +1,29 @@
import { describe, expect, it } from "vitest";
import {
DEFAULT_WIND_SPEED_UNIT,
formatTemperature,
formatWindSpeed,
isTemperatureUnit,
isWindSpeedUnit,
} from "@/lib/weather-utils";
describe("weather utilities", () => {
it("formats wind speed in km/h by default", () => {
expect(DEFAULT_WIND_SPEED_UNIT).toBe("kmh");
expect(formatWindSpeed(5, "en")).toBe("18 km/h");
});
it("formats selected temperature and wind units", () => {
expect(formatTemperature(10, "en", "f")).toBe("50°F");
expect(formatWindSpeed(4, "en", "mph")).toBe("9 mph");
expect(formatWindSpeed(4, "en", "ms")).toBe("4.0 m/s");
});
it("validates supported presentation units", () => {
expect(isTemperatureUnit("c")).toBe(true);
expect(isTemperatureUnit("kelvin")).toBe(false);
expect(isWindSpeedUnit("kmh")).toBe(true);
expect(isWindSpeedUnit("knots")).toBe(false);
});
});