test: add weather logic test suite
All checks were successful
CI / Lint, test, typecheck and build (push) Successful in 9m58s
All checks were successful
CI / Lint, test, typecheck and build (push) Successful in 9m58s
This commit is contained in:
29
tests/weather-utils.test.ts
Normal file
29
tests/weather-utils.test.ts
Normal 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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user