Files
Aislo/resources/tester/spreadsheet/spreadsheet_toolbar_unit_entry.ts
T
eomsangdon 7c966a1cca Merge remote-tracking branch 'origin/main_laptop_1' into main_desktop_1
# Conflicts:
#	A00_Common/spreadsheet/spreadsheet_link_set.ts
#	A00_Common/spreadsheet/spreadsheet_links.css
#	A00_Common/spreadsheet/spreadsheet_links.ts
#	A00_Common/spreadsheet/spreadsheet_menu.ts
#	A00_Common/spreadsheet/spreadsheet_menu_items.ts
#	A00_Common/spreadsheet/spreadsheet_toolbar.ts
#	resources/tester/test_spreadsheet_set_link.py
#	ui_template/ui_template_context_menu.css
#	ui_template/ui_template_context_menu.ts
2026-10-08 13:29:31 +09:00

40 lines
1.9 KiB
TypeScript

/* 단위 Φ(81-5) 순수 길 시험 진입 — vite --ssr 로 번들해 Node 로 돌림(메인 판 attachUnitToFormat ·
* UNIT_PREFIX · UNIT_GROUPS 에 맞춤 — 81-3·81-4·81-5 겹침 정리).
* 결과 = JSON {pass, fail, failures} 한 줄(`test_spreadsheet_toolbar_unit.py` 가 읽음) */
import {
attachUnitToFormat,
UNIT_GROUPS,
UNIT_PREFIX,
} from "../../../A00_Common/spreadsheet/spreadsheet_toolbar";
let pass = 0;
const failures: string[] = [];
const eq = (name: string, got: unknown, want: unknown): void => {
if (JSON.stringify(got) === JSON.stringify(want)) pass += 1;
else failures.push(`${name}: ${JSON.stringify(got)} ≠ ${JSON.stringify(want)}`);
};
const PHI = "Φ";
// Φ 는 길이 묶음(UnitGroup_area) 끝 — 다른 묶음엔 안 들어감 · 앞 단위 목록에 있음
const lengthGroup = UNIT_GROUPS.find(([label]) => label === "UnitGroup_area")!;
eq("Φ = 길이 묶음 끝", lengthGroup[1][lengthGroup[1].length - 1], PHI);
eq(
"Φ 는 다른 묶음에 없음",
UNIT_GROUPS.filter(([label]) => label !== "UnitGroup_area").some((g) => g[1].includes(PHI)),
false,
);
eq("Φ 는 앞 단위 목록에 있음", UNIT_PREFIX.includes(PHI), true);
// 보통 단위(뒤에 붙음) — 지금처럼
eq("보통 단위 서식 — 뒤", attachUnitToFormat("0", "㎡"), '0"㎡"');
eq("보통 단위 서식 — 옛 단위 바꿈", attachUnitToFormat('0"㎡"', "㎝"), '0"㎝"');
// Φ(지름) — 숫자 앞(메인 판 attachUnitToFormat 이 앞/뒤를 한 함수에서 갈라 처리)
eq("Φ 서식 — 앞", attachUnitToFormat("0", PHI), '"Φ"0');
eq("Φ 서식 — 빈 코드도 0 기준", attachUnitToFormat("", PHI), '"Φ"0');
eq("Φ 서식 — 옛 Φ 바꿈(겹쳐 안 붙음)", attachUnitToFormat('"Φ"0', PHI), '"Φ"0');
eq("Φ 서식 — 뒤 단위와 공존", attachUnitToFormat('0"㎡"', PHI), '"Φ"0"㎡"');
console.log(JSON.stringify({ pass, fail: failures.length, failures }));