T6: offer True Citra and Fagan-Bradley beside Raman/Lahiri/KP/True Pushya,
engine-supported values only; widen profiles_ayanamsa_check by an additive
migration; ephemeris note names; path tests so no new value falls back to
Raman.
T7: the unlayered `button { color: inherit; }` beats Tailwind's
text-primary-foreground, so solid report buttons showed page ink (light
(light 4.85:1, dark 5.77:1), grey disabled without fade, neutral selected
preset. button.tsx and theme tokens unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017eEAG8HD3mm8gsKXgk8uU8
55 lines
2.9 KiB
TypeScript
55 lines
2.9 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
AYANAMSA_SWITCH_HINT,
|
|
AYANAMSA_VALUES,
|
|
DEFAULT_AYANAMSA,
|
|
isAyanamsaName,
|
|
resolveAyanamsa,
|
|
} from "../src/lib/ayanamsa.ts";
|
|
|
|
test("resolveAyanamsa defaults to Raman and accepts the six product values", () => {
|
|
assert.equal(DEFAULT_AYANAMSA, "raman");
|
|
assert.deepEqual([...AYANAMSA_VALUES], ["raman", "lahiri", "kp", "true_citra", "true_pushya", "fagan_bradley"]);
|
|
assert.equal(resolveAyanamsa(), "raman");
|
|
assert.equal(resolveAyanamsa(null), "raman");
|
|
assert.equal(resolveAyanamsa({}), "raman");
|
|
assert.equal(resolveAyanamsa({ ayanamsa: "lahiri" }), "lahiri");
|
|
assert.equal(resolveAyanamsa({ ayanamsa: "KP" }), "kp");
|
|
assert.equal(resolveAyanamsa({ ayanamsa: "krishnamurti" }), "kp");
|
|
assert.equal(resolveAyanamsa({ ayanamsa: "true-pushya" }), "true_pushya");
|
|
assert.equal(resolveAyanamsa({ ayanamsa: "fagan" }), "raman");
|
|
assert.equal(resolveAyanamsa({ ayanamsa: "djwhal_khul" }), "raman");
|
|
assert.equal(isAyanamsaName("raman"), true);
|
|
assert.equal(isAyanamsaName("sidereal"), false);
|
|
assert.match(AYANAMSA_SWITCH_HINT, /咨询、报告、星盘库和每日星语/);
|
|
assert.match(AYANAMSA_SWITCH_HINT, /生时校正目前仍固定按 Raman/);
|
|
});
|
|
|
|
// TASK-chart-types-and-report-buttons-20260928 T6: every offered value must
|
|
// come back unchanged — `resolveAyanamsa` silently falls back to Raman for an
|
|
// unknown value, so a value missing from AYANAMSA_VALUES would quietly turn a
|
|
// user's True Citra chart into a Raman one on every path.
|
|
test("each of the six ayanamsa values resolves to itself, never to the Raman fallback", () => {
|
|
for (const value of ["raman", "lahiri", "kp", "true_citra", "true_pushya", "fagan_bradley"]) {
|
|
assert.equal(resolveAyanamsa({ ayanamsa: value }), value);
|
|
assert.equal(resolveAyanamsa({ ayanamsa: value.toUpperCase().replace(/_/g, "-") }), value);
|
|
}
|
|
// Same alias the engine accepts (`scripts/ayanamsa_utils.py`).
|
|
assert.equal(resolveAyanamsa({ ayanamsa: "true_chitra" }), "true_citra");
|
|
assert.equal(resolveAyanamsa({ ayanamsa: "True-Chitra" }), "true_citra");
|
|
});
|
|
|
|
test("the settings list is exactly the six values in product order, only engine-supported ones", async () => {
|
|
const { AYANAMSA_OPTIONS } = await import("../src/lib/ayanamsa.ts");
|
|
assert.deepEqual(AYANAMSA_OPTIONS.map((option) => option.value), [...AYANAMSA_VALUES]);
|
|
assert.deepEqual(AYANAMSA_OPTIONS.map((option) => option.label), [
|
|
"Raman(默认)", "Lahiri", "KP", "True Citra", "True Pushya", "Fagan-Bradley",
|
|
]);
|
|
const { readFileSync } = await import("node:fs");
|
|
const engine = readFileSync(new URL("../../scripts/ayanamsa_utils.py", import.meta.url), "utf8");
|
|
for (const value of AYANAMSA_VALUES) assert.match(engine, new RegExp(`'${value}': getattr\\(swe`));
|
|
for (const option of AYANAMSA_OPTIONS) assert.ok(option.description.length > 0);
|
|
});
|