# -*- coding: utf-8 -*- """B06 횡단 카드 열 수 · 폭 · 높이(PLAN 138-3) — 열 수 1~6 · 기본 3 · 폭 = (칸 − 간격) ÷ n · 높이 = 폭 × 3열 비율. 규칙은 Node 헬퍼(`helper_138_cross_columns.cjs`)가 `B06_Section_UI_Section_Columns.ts` 를 그대로 돌림. """ import json import os import subprocess import pytest HERE = os.path.dirname(os.path.abspath(__file__)) @pytest.fixture(scope="module") def out(): proc = subprocess.run( ["node", os.path.join(HERE, "helper_138_cross_columns.cjs")], capture_output=True, text=True, encoding="utf-8", timeout=60, ) assert proc.returncode == 0, proc.stderr return json.loads(proc.stdout) def test_열_수_1_6_기본_3(out): # null = 저장값 없음(readStateRaw) → 기본 3(150-1) assert out["clamp"] == [3, 3, 3, 3, 1, 1, 3, 6, 6, 4] def test_카드_폭은_칸_폭_나누기_열_수(out): assert out["widths"] == [1232, 608, 400, (1232 - 80) / 6] assert out["baseWidth"] == 400 def test_3열은_자연_높이_줄_최댓값(out): assert out["rows3"] == [300, 300, 300, 400, 400] def test_다른_열_수는_3열_비율_그대로(out): # 2열 폭 608 = 3열 400 × 1.52 → 높이도 1.52 배 · 줄(2장) 최댓값 assert [round(h, 6) for h in out["rows2"]] == [456, 456, 425.6, 425.6, 608] # 1열 폭 1232 = 3.08 배 assert [round(h, 6) for h in out["rows1"]] == [770, 924, 862.4, 800.8, 1232]