reflex/tests/units/components/datadisplay/test_code.py
Thomas Brandého 3f538865b5
reorganize all tests in a single top folder (#3981)
* lift node version restraint to allow more recent version if already installed

* add node test for latest version

* change python version

* use purple for debug logs

* update workflow

* add playwright dev dependency

* update workflow

* change test

* oops

* improve test

* update test

* fix tests

* mv units tests to a subfolder

* reorganize tests

* fix install

* update test_state

* revert node changes and only keep new tests organization

* move integration tests in tests/integration

* fix integration workflow

* fix dockerfile workflow

* fix dockerfile workflow 2

* fix shared_state
2024-09-26 01:22:52 +02:00

33 lines
907 B
Python

import pytest
from reflex.components.datadisplay.code import CodeBlock, Theme
@pytest.mark.parametrize(
"theme, expected",
[(Theme.one_light, "oneLight"), (Theme.one_dark, "oneDark")],
)
def test_code_light_dark_theme(theme, expected):
code_block = CodeBlock.create(theme=theme)
assert code_block.theme._js_expr == expected # type: ignore
def generate_custom_code(language, expected_case):
return f"SyntaxHighlighter.registerLanguage('{language}', {expected_case})"
@pytest.mark.parametrize(
"language, expected_case",
[
("python", "python"),
("firestore-security-rules", "firestoreSecurityRules"),
("typescript", "typescript"),
],
)
def test_get_custom_code(language, expected_case):
code_block = CodeBlock.create(language=language)
assert code_block._get_custom_code() == generate_custom_code(
language, expected_case
)