reflex/tests/components/typography/test_markdown.py
Masen Furer 26002a809b
[REF-3591] Remove chakra-related files from immutable vars PR (#3821)
* Add comments to html metadata component (#3731)

* fix: add verification for path /404 (#3723)

Co-authored-by: coolstorm <manas.gupta@fampay.in>

* Use the new state name when setting `is_hydrated` to false (#3738)

* Use `._is_mutable()` to account for parent state proxy (#3739)

When a parent state proxy is set, also allow child StateProxy._self_mutable to
override the parent's `_is_mutable()`.

* bump to 0.5.9 (#3746)

* add message when installing requirements.txt is needed for chosen template during init (#3750)

* #3752 bugfix add domain for XAxis (#3764)

* fix appharness app_source typing (#3777)

* fix import clash between connectionToaster and hooks.useState (#3749)

* use different registry when in china, fixes #3700 (#3702)

* do not reload compilation if using local app in AppHarness (#3790)

* do not reload if using local app

* Update reflex/testing.py

Co-authored-by: Masen Furer <m_github@0x26.net>

---------

Co-authored-by: Masen Furer <m_github@0x26.net>

* Bump memory on relevant actions (#3781)

Co-authored-by: Alek Petuskey <alekpetuskey@Aleks-MacBook-Pro.local>

* [REF-3334] Validate Toast Props (#3793)

* [REF-3536][REF-3537][REF-3541] Move chakra components into its repo(reflex-chakra) (#3798)

* fix get_uuid_string_var (#3795)

* minor State cleanup (#3768)

* Fix code wrap in markdown (#3755)

---------

Co-authored-by: Alek Petuskey <alek@pynecone.io>
Co-authored-by: Manas Gupta <53006261+Manas1820@users.noreply.github.com>
Co-authored-by: coolstorm <manas.gupta@fampay.in>
Co-authored-by: Thomas Brandého <thomas.brandeho@gmail.com>
Co-authored-by: Shubhankar Dimri <dimrishubhi@gmail.com>
Co-authored-by: benedikt-bartscher <31854409+benedikt-bartscher@users.noreply.github.com>
Co-authored-by: Khaleel Al-Adhami <khaleel.aladhami@gmail.com>
Co-authored-by: Alek Petuskey <alekpetuskey@Aleks-MacBook-Pro.local>
Co-authored-by: Elijah Ahianyo <elijahahianyo@gmail.com>
2024-08-22 16:15:12 -07:00

53 lines
1.4 KiB
Python

import pytest
import reflex_chakra as rc
import reflex as rx
from reflex.components.markdown import Markdown
@pytest.mark.parametrize(
"tag,expected",
[
("h1", "Heading"),
("h2", "Heading"),
("h3", "Heading"),
("h4", "Heading"),
("h5", "Heading"),
("h6", "Heading"),
("p", "Text"),
("ul", "ul"),
("ol", "ol"),
("li", "li"),
("a", "Link"),
("code", "Code"),
],
)
def test_get_component(tag, expected):
"""Test getting a component from the component map.
Args:
tag: The tag to get.
expected: The expected component.
"""
md = Markdown.create("# Hello")
assert tag in md.component_map # type: ignore
assert md.get_component(tag).tag == expected # type: ignore
def test_set_component_map():
"""Test setting the component map."""
component_map = {
"h1": lambda value: rx.box(
rc.heading(value, as_="h1", size="2xl"), padding="1em"
),
"p": lambda value: rx.box(rx.text(value), padding="1em"),
}
md = Markdown.create("# Hello", component_map=component_map)
# Check that the new tags have been added.
assert md.get_component("h1").tag == "Box" # type: ignore
assert md.get_component("p").tag == "Box" # type: ignore
# Make sure the old tags are still there.
assert md.get_component("h2").tag == "Heading" # type: ignore