The owner approved removing the first group of lines from the BUG-2071 sweep: the line under each annual range card, the onboarding note about filling in one's own data later, the ayanamsa scope sentence, and the notes above the Bhava and transit tables. Their constants and CSS go with them; the lines the owner did not approve stay. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
59 lines
3.3 KiB
TypeScript
59 lines
3.3 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
AYANAMSA_VALUES,
|
|
DEFAULT_AYANAMSA,
|
|
isAyanamsaName,
|
|
resolveAyanamsa,
|
|
} from "../src/lib/ayanamsa.ts";
|
|
|
|
const read = (path: string) => readFileSync(new URL(path, import.meta.url), "utf8");
|
|
|
|
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);
|
|
// 原值:岁差设置下面有一句 AYANAMSA_SWITCH_HINT「之后的咨询、报告、星盘库、每日星语和生时纠正会按新岁差算。」
|
|
// 新值:这句和常量都没有了 原因:负责人 2026-11-20 定,表单下面的说明句去掉(BUG-2078)
|
|
assert.doesNotMatch(read("../src/lib/ayanamsa.ts"), /AYANAMSA_SWITCH_HINT|会按新岁差算/);
|
|
assert.doesNotMatch(read("../src/components/ayanamsa-preference-field.tsx"), /ayanamsa-preference-hint|AYANAMSA_SWITCH_HINT/);
|
|
});
|
|
|
|
// 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);
|
|
});
|