refactor(mood): drop the orientation helper until something needs it

The inverse flag is read by the trend legend and by the assistant block;
the function that flips a value through it had no caller. It comes back
with the surface that needs a combined view, not before.
This commit is contained in:
Marc-André Bombeck committed 2026-08-08 02:07:21 +02:00
1 parent 0c017ba335
commit 5d98a98c21
2 files changed
-41

No files matched your search

-25
View File
@@ -5,7 +5,6 @@ import {
MOOD_DIMENSION_MAX,
MOOD_DIMENSION_MIN,
getMoodDimension,
orientForComparison,
} from "@/lib/mood/dimensions";
describe("MOOD_DIMENSIONS", () => {
@@ -61,27 +60,3 @@ describe("MOOD_DIMENSIONS", () => {
expect(getMoodDimension("")).toBeUndefined();
});
});
describe("orientForComparison", () => {
const a1 = MOOD_DIMENSIONS[0];
const a2 = MOOD_DIMENSIONS[1];
it("leaves an upright dimension alone", () => {
expect(orientForComparison(a1, 0)).toBe(0);
expect(orientForComparison(a1, 7)).toBe(7);
expect(orientForComparison(a1, 10)).toBe(10);
});
it("flips the inverse dimension around the scale", () => {
expect(orientForComparison(a2, 0)).toBe(10);
expect(orientForComparison(a2, 3)).toBe(7);
expect(orientForComparison(a2, 10)).toBe(0);
});
it("answers null for an absent value rather than a neutral one", () => {
expect(orientForComparison(a1, null)).toBeNull();
expect(orientForComparison(a1, undefined)).toBeNull();
expect(orientForComparison(a2, null)).toBeNull();
expect(orientForComparison(a2, Number.NaN)).toBeNull();
});
});
-16
View File
@@ -120,19 +120,3 @@ const BY_KEY = new Map<string, MoodDimension>(
export function getMoodDimension(key: string): MoodDimension | undefined {
return BY_KEY.get(key);
}
/**
* Turn a stored value into one where "up" reads as "better".
*
* The only legal way to normalise an inverse dimension. Returns `null` for an
* absent value, because an unanswered dimension is not a neutral one — the
* whole point of leaving A2..A5 nullable is that absence stays readable as
* absence.
*/
export function orientForComparison(
dimension: MoodDimension,
value: number | null | undefined,
): number | null {
if (typeof value !== "number" || !Number.isFinite(value)) return null;
return dimension.inverse ? dimension.max - value : value;
}