27 lines
855 B
Python
27 lines
855 B
Python
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()
|