81 lines
2.2 KiB
TypeScript
81 lines
2.2 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { buildCityDecisionState } from "@/components/dashboard/scan-terminal/city-decision-state";
|
|
import type { MarketDecisionView } from "@/components/dashboard/scan-terminal/city-card-decision-utils";
|
|
|
|
function market(status: MarketDecisionView["status"]): MarketDecisionView {
|
|
return {
|
|
bucketLabel: "--",
|
|
confidence: "--",
|
|
edgeText: "--",
|
|
impliedText: "--",
|
|
modelText: "--",
|
|
priceText: "--",
|
|
reason: "",
|
|
status,
|
|
title: "",
|
|
tone: "watch",
|
|
};
|
|
}
|
|
|
|
export function runTests() {
|
|
const breakout = buildCityDecisionState({
|
|
isEn: false,
|
|
isHkoObservation: false,
|
|
modelHighlyConsistent: true,
|
|
needsNextBulletin: false,
|
|
observationStale: false,
|
|
observedHighBreak: true,
|
|
observedLowBreak: false,
|
|
observedLowLag: false,
|
|
peakHasPassed: false,
|
|
});
|
|
|
|
assert.equal(breakout.urgency, "now");
|
|
assert.equal(breakout.recommendation, "watch");
|
|
assert.match(breakout.primaryReason, /实测已突破模型上沿/);
|
|
assert.match(breakout.primaryReason, /建议关注偏高温/);
|
|
assert.ok(breakout.badges.some((badge) => badge.label === "实测突破"));
|
|
|
|
const marketUnavailable = buildCityDecisionState({
|
|
isEn: false,
|
|
isHkoObservation: false,
|
|
modelHighlyConsistent: false,
|
|
needsNextBulletin: false,
|
|
observationStale: false,
|
|
observedHighBreak: false,
|
|
observedLowBreak: false,
|
|
observedLowLag: false,
|
|
peakHasPassed: false,
|
|
});
|
|
|
|
|
|
const fallback = buildCityDecisionState({
|
|
isEn: false,
|
|
isHkoObservation: false,
|
|
modelHighlyConsistent: false,
|
|
needsNextBulletin: false,
|
|
observationStale: false,
|
|
observedHighBreak: false,
|
|
observedLowBreak: false,
|
|
observedLowLag: false,
|
|
peakHasPassed: false,
|
|
});
|
|
|
|
assert.equal(fallback.recommendation, "watch");
|
|
|
|
const partialStream = buildCityDecisionState({
|
|
isEn: false,
|
|
isHkoObservation: false,
|
|
modelHighlyConsistent: false,
|
|
needsNextBulletin: true,
|
|
observationStale: false,
|
|
observedHighBreak: false,
|
|
observedLowBreak: false,
|
|
observedLowLag: true,
|
|
peakHasPassed: false,
|
|
});
|
|
|
|
assert.equal(partialStream.urgency, "soon");
|
|
assert.equal(partialStream.recommendation, "wait");
|
|
}
|