Gause to orsted
This commit is contained in:
@@ -669,9 +669,27 @@ a:focus-visible {
|
||||
|
||||
.calc-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
grid-template-columns: repeat(1, minmax(0, 1fr));
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
.calc-list {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 960px) {
|
||||
.calc-list {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
.calc-list {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
.calc-list-item {
|
||||
display: block;
|
||||
position: relative;
|
||||
|
||||
@@ -379,7 +379,7 @@ export const calculators: CalculatorDef[] = [
|
||||
{"slug": "webers-per-square-centimeter-to-gauss", "name": "Webers per square centimeter to Gauss", "category": "magnetism", "type": "standard", "teaser": "Scale the small-area flux into Gauss.", "labels": {"in1": "Webers per square centimeter", "in2": "Gauss"}, "factor": 100000000.0},
|
||||
{"slug": "gauss-to-webers-per-square-centimeter", "name": "Gauss to Webers per square centimeter", "category": "magnetism", "type": "standard", "teaser": "Convert Gauss back into Weber per square centimeter.", "labels": {"in1": "Gauss", "in2": "Webers per square centimeter"}, "factor": 1e-08, "hidden": true},
|
||||
{"slug": "oersted-to-gauss", "name": "Oersted to Gauss", "category": "magnetism", "type": "standard", "teaser": "In vacuum, the numeric values for Oersted and Gauss match.", "labels": {"in1": "Oersted", "in2": "Gauss"}, "hidden": true},
|
||||
{"slug": "gauss-to-oersted", "name": "Gauss to Oersted", "category": "magnetism", "type": "standard", "teaser": "Translate the flux density version back into the magnetizing force scale.", "labels": {"in1": "Gauss", "in2": "Oersted"}},
|
||||
{"slug": "gauss-to-oersted", "name": "Gauss to Oersted", "category": "magnetism", "type": "standard", "teaser": "Translate the flux density version back into the magnetizing force scale.", "labels": {"in1": "Gauss", "in2": "Oersted"}, "factor": 1.0},
|
||||
{"slug": "kilogauss-to-microtesla", "name": "Kilogauss to Microtesla", "category": "magnetism", "type": "standard", "teaser": "A kilogauss field equals 100,000 microtesla.", "labels": {"in1": "Kilogauss", "in2": "Microtesla"}, "factor": 100000.0},
|
||||
{"slug": "microtesla-to-kilogauss", "name": "Microtesla to Kilogauss", "category": "magnetism", "type": "standard", "teaser": "Convert microtesla readings into kilogauss.", "labels": {"in1": "Microtesla", "in2": "Kilogauss"}, "factor": 1e-05, "hidden": true},
|
||||
{"slug": "kilogauss-to-nanotesla", "name": "Kilogauss to Nanotesla", "category": "magnetism", "type": "standard", "teaser": "Express kilogauss values in nanotesla for sensitive instrumentation.", "labels": {"in1": "Kilogauss", "in2": "Nanotesla"}, "factor": 100000000.0},
|
||||
|
||||
43
tests/test_gauss_to_oersted_conversion_rate.py
Normal file
43
tests/test_gauss_to_oersted_conversion_rate.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import re
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
CALCULATORS_TS = ROOT / "hdyc-svelte" / "src" / "lib" / "data" / "calculators.ts"
|
||||
CONVERSION_RATE_UTIL = ROOT / "hdyc-svelte" / "src" / "lib" / "utils" / "conversionRate.ts"
|
||||
CATEGORY_PAGE = ROOT / "hdyc-svelte" / "src" / "routes" / "category" / "[category]" / "+page.svelte"
|
||||
CALCULATOR_COMPONENT = ROOT / "hdyc-svelte" / "src" / "lib" / "components" / "Calculator.svelte"
|
||||
TARGET_SLUG = "gauss-to-oersted"
|
||||
|
||||
|
||||
def _extract_calculator_block(slug: str) -> str:
|
||||
for line in CALCULATORS_TS.read_text(encoding="utf-8").splitlines():
|
||||
if f'"slug": "{slug}"' in line:
|
||||
return line
|
||||
raise AssertionError(f"Could not find calculator definition for '{slug}'")
|
||||
|
||||
|
||||
class GaussToOerstedConversionRateRegressionTests(unittest.TestCase):
|
||||
def test_gauss_to_oersted_includes_factor_for_conversion_rate_and_tooltip(self) -> None:
|
||||
block = _extract_calculator_block(TARGET_SLUG)
|
||||
self.assertRegex(
|
||||
block,
|
||||
r'"factor":\s*[0-9.eE+-]+',
|
||||
"Missing factor on gauss-to-oersted prevents conversion rate text from rendering in both calculator footer and category tooltip.",
|
||||
)
|
||||
|
||||
def test_conversion_rate_is_wired_to_both_surfaces(self) -> None:
|
||||
util_text = CONVERSION_RATE_UTIL.read_text(encoding="utf-8")
|
||||
category_page_text = CATEGORY_PAGE.read_text(encoding="utf-8")
|
||||
calculator_component_text = CALCULATOR_COMPONENT.read_text(encoding="utf-8")
|
||||
|
||||
self.assertIn("getConversionRateText", util_text)
|
||||
self.assertIn("conversionRateText = getConversionRateText(calc)", category_page_text)
|
||||
self.assertIn('role="tooltip"', category_page_text)
|
||||
self.assertIn("conversionRateText = getConversionRateText(config)", calculator_component_text)
|
||||
self.assertIn('<span class="formula-hint">', calculator_component_text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user