From 55ac6e4973478b4e1f1f24a6e5f23a70eff46c21 Mon Sep 17 00:00:00 2001 From: Xiaojing Chen Date: Wed, 1 Mar 2023 03:29:06 +0800 Subject: [PATCH] Add unit test for style (#615) --- tests/test_style.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/test_style.py diff --git a/tests/test_style.py b/tests/test_style.py new file mode 100644 index 000000000..c5c60305a --- /dev/null +++ b/tests/test_style.py @@ -0,0 +1,39 @@ +import pytest + +from pynecone import style +from pynecone.var import Var + +test_style = [ + ({"a": 1}, {"a": 1}), + ({"a": Var.create("abc")}, {"a": "abc"}), + ({"test_case": 1}, {"testCase": 1}), + ({"test_case": {"a": 1}}, {"testCase": {"a": 1}}), +] + + +@pytest.mark.parametrize( + "style_dict,expected", + test_style, +) +def test_convert(style_dict, expected): + """Test Format a style dictionary. + + Args: + style_dict: The style to check. + expected: The expected formatted style. + """ + assert style.convert(style_dict) == expected + + +@pytest.mark.parametrize( + "style_dict,expected", + test_style, +) +def test_create_style(style_dict, expected): + """Test style dictionary. + + Args: + style_dict: The style to check. + expected: The expected formatted style. + """ + assert style.Style(style_dict) == expected