feat: add weather unit preferences
Some checks failed
CI / Lint, test, typecheck and build (push) Has been cancelled
Some checks failed
CI / Lint, test, typecheck and build (push) Has been cancelled
This commit is contained in:
@@ -54,10 +54,16 @@ function warning(overrides: Partial<WeatherWarning> = {}): WeatherWarning {
|
||||
}
|
||||
|
||||
describe("weather briefs", () => {
|
||||
it("uses selected temperature and wind units in the morning brief", () => {
|
||||
it("uses selected temperature, wind and precipitation units in the morning brief", () => {
|
||||
const brief = buildWeatherBrief({
|
||||
forecast: forecast([
|
||||
hour({ time: "2026-06-14T08:00", temperature: 10, windSpeed: 4, precipitationProbability: 80 }),
|
||||
hour({
|
||||
time: "2026-06-14T08:00",
|
||||
temperature: 10,
|
||||
windSpeed: 4,
|
||||
precipitationProbability: 80,
|
||||
precipitation: 25.4,
|
||||
}),
|
||||
hour({ time: "2026-06-14T09:00", temperature: 12, windSpeed: 5, precipitationProbability: 30 }),
|
||||
]),
|
||||
warnings: [],
|
||||
@@ -67,6 +73,7 @@ describe("weather briefs", () => {
|
||||
language: "en",
|
||||
temperatureUnit: "f",
|
||||
windSpeedUnit: "mph",
|
||||
precipitationUnit: "in",
|
||||
now: new Date("2026-06-14T06:00:00.000Z"),
|
||||
});
|
||||
|
||||
@@ -74,25 +81,34 @@ describe("weather briefs", () => {
|
||||
expect(brief?.pushBody).toContain("50°F-54°F");
|
||||
expect(brief?.pushBody).toContain("wind 11 mph");
|
||||
expect(brief?.pushBody).not.toContain("km/h");
|
||||
expect(brief?.body.join(" ")).toContain("1.00 in");
|
||||
});
|
||||
|
||||
it("warns about tomorrow storms from model weather codes without IMGW warning", () => {
|
||||
const brief = buildTomorrowWeatherBrief({
|
||||
forecast: forecast([
|
||||
hour({ time: "2026-06-15T08:00", temperature: 14, weatherCode: 3, precipitationProbability: 20 }),
|
||||
hour({ time: "2026-06-15T15:00", temperature: 21, weatherCode: 95, precipitationProbability: 30 }),
|
||||
hour({
|
||||
time: "2026-06-15T15:00",
|
||||
temperature: 21,
|
||||
weatherCode: 95,
|
||||
precipitationProbability: 30,
|
||||
precipitation: 25.4,
|
||||
}),
|
||||
]),
|
||||
warnings: [],
|
||||
province: "mazowieckie",
|
||||
countyTeryt: "1465",
|
||||
locationName: "Warsaw",
|
||||
language: "en",
|
||||
precipitationUnit: "in",
|
||||
now: new Date("2026-06-14T16:00:00.000Z"),
|
||||
});
|
||||
|
||||
expect(brief?.severity).toBe("warning");
|
||||
expect(brief?.headline).toBe("Thunderstorms are possible tomorrow");
|
||||
expect(brief?.pushBody).toContain("thunderstorms");
|
||||
expect(brief?.pushBody).toContain("1.00 in");
|
||||
expect(brief?.pushBody).not.toContain("IMGW");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user