initial 2
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-06-26 09:26:50 +01:00
parent 194330fb47
commit 3b37368e7d
213 changed files with 14688 additions and 1 deletions

View File

@@ -0,0 +1,74 @@
import { describe, it, expect } from "vitest";
import {
hasMeaningfulReflectionContent,
shouldAwardReflectionXp,
} from "../reflection-utils";
describe("hasMeaningfulReflectionContent", () => {
it("returns false for all empty fields", () => {
expect(
hasMeaningfulReflectionContent({
wentWell: "",
learned: "",
improveTomorrow: "",
})
).toBe(false);
});
it("returns false for whitespace-only fields", () => {
expect(
hasMeaningfulReflectionContent({
wentWell: " ",
learned: "\t",
improveTomorrow: " \n ",
})
).toBe(false);
});
it("returns true when any field has content", () => {
expect(
hasMeaningfulReflectionContent({
wentWell: "",
learned: "Read for 20 minutes",
improveTomorrow: "",
})
).toBe(true);
});
});
describe("shouldAwardReflectionXp", () => {
const empty = { wentWell: "", learned: "", improveTomorrow: "" };
const filled = {
wentWell: "Good day",
learned: "Something new",
improveTomorrow: "Sleep earlier",
};
it("does not award for empty content", () => {
expect(shouldAwardReflectionXp(null, empty)).toBe(false);
});
it("does not award for whitespace-only content", () => {
expect(
shouldAwardReflectionXp(null, {
wentWell: " ",
learned: "",
improveTomorrow: "",
})
).toBe(false);
});
it("awards on first meaningful save", () => {
expect(shouldAwardReflectionXp(null, filled)).toBe(true);
});
it("does not award when updating already meaningful reflection", () => {
expect(shouldAwardReflectionXp(filled, { ...filled, learned: "More" })).toBe(
false
);
});
it("awards when empty row exists and user adds meaningful content", () => {
expect(shouldAwardReflectionXp(empty, filled)).toBe(true);
});
});