feat: refine widget interactions
This commit is contained in:
1 parent
a8a7545f40
commit
842e86012d
107 files changed
+3144
-1233
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { getPreferredUnit, getVisibleForecastDays } from "./component";
|
||||
import { getPreferredTime, getPreferredUnit, getPreferredWindSpeed, getVisibleForecastDays } from "./component";
|
||||
|
||||
describe("weather formatting", () => {
|
||||
it("preserves valid zero temperatures", () => {
|
||||
@@ -8,9 +8,15 @@ describe("weather formatting", () => {
|
||||
expect(getPreferredUnit(0, true, true)).toBe("32°F");
|
||||
});
|
||||
|
||||
it("keeps zero wind speeds and missing forecast values truthful", () => {
|
||||
expect(getPreferredWindSpeed(0)).toBe("0.0");
|
||||
expect(getPreferredWindSpeed(undefined)).toBe("?");
|
||||
expect(getPreferredTime(undefined)).toBe("?");
|
||||
expect(getPreferredTime("invalid")).toBe("?");
|
||||
});
|
||||
|
||||
it("limits compact forecasts by both axes", () => {
|
||||
expect(getVisibleForecastDays(7, 120, 100, false)).toBe(2);
|
||||
expect(getVisibleForecastDays(7, 600, 100, false)).toBe(3);
|
||||
expect(getVisibleForecastDays(7, 120, 100, true)).toBe(7);
|
||||
expect(getVisibleForecastDays(7, 120, 100)).toBe(2);
|
||||
expect(getVisibleForecastDays(7, 600, 100)).toBe(3);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user