Normalize conversion factor formatting

This commit is contained in:
Codex Agent
2026-03-09 19:50:26 +00:00
parent c20f2ebc60
commit b44e9e5702
5 changed files with 88 additions and 23 deletions

View File

@@ -0,0 +1,26 @@
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
QUICK_CONVERSION_EXAMPLE = (
ROOT / "hdyc-svelte" / "src" / "lib" / "components" / "QuickConversionExample.svelte"
)
class QuickConversionExampleFormattingTests(unittest.TestCase):
def test_formula_uses_formatted_factor_and_offset(self) -> None:
text = QUICK_CONVERSION_EXAMPLE.read_text(encoding="utf-8")
normalized = " ".join(text.split())
snippet = (
"1 {config.labels.in1} = {formattedFactorValue}{hasOffset ? ` + ${formattedOffsetValue}` : ''} "
"{config.labels.in2}"
)
self.assertIn(
snippet,
normalized,
"The formula snippet should render formatted factor/offset values instead of raw floats",
)
if __name__ == "__main__":
unittest.main()