mirror of
https://github.com/django-components/django-components.git
synced 2025-09-26 15:39:08 +00:00
bug: Test showing bug with components in inclusion_tag
This commit is contained in:
parent
8a6215b9cd
commit
1671b625a3
2 changed files with 77 additions and 0 deletions
|
@ -631,3 +631,69 @@ class TestDependencyRendering:
|
|||
<div data-djc-id-ca1bc44>Another</div>
|
||||
""",
|
||||
)
|
||||
|
||||
def test_dependencies_with_component_in_inclusion_tag(self):
|
||||
registry.register(name="test_component", component=OtherComponent)
|
||||
|
||||
template_str: types.django_html = """
|
||||
{% load component_tags %}
|
||||
{% component_js_dependencies %}
|
||||
{% component_css_dependencies %}
|
||||
{% inclusion_tag %}
|
||||
"""
|
||||
template = Template(template_str)
|
||||
rendered: str = template.render(Context({}))
|
||||
|
||||
# Dependency manager script
|
||||
assertInHTML('<script src="django_components/django_components.min.js"></script>', rendered, count=1)
|
||||
assertInHTML(
|
||||
"""
|
||||
<script src="xyz1.js"></script>
|
||||
""",
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
assertInHTML(
|
||||
"""
|
||||
<link href="xyz1.css" media="all" rel="stylesheet">
|
||||
""",
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
|
||||
assert rendered.count("<script") == 4 # manager + loader + 2 OtherComponent
|
||||
assert rendered.count("<link") == 1 # 1 OtherComponent
|
||||
assert rendered.count("<style") == 1 # 1 Style
|
||||
|
||||
def test_dependencies_with_component_in_inclusion_tag_working(self):
|
||||
registry.register(name="test_component", component=OtherComponent)
|
||||
|
||||
template_str: types.django_html = """
|
||||
{% load component_tags %}
|
||||
{% component_js_dependencies %}
|
||||
{% component_css_dependencies %}
|
||||
{% inclusion_tag_working %}
|
||||
"""
|
||||
template = Template(template_str)
|
||||
rendered: str = template.render(Context({}))
|
||||
|
||||
# Dependency manager script
|
||||
assertInHTML('<script src="django_components/django_components.min.js"></script>', rendered, count=1)
|
||||
assertInHTML(
|
||||
"""
|
||||
<script src="xyz1.js"></script>
|
||||
""",
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
assertInHTML(
|
||||
"""
|
||||
<link href="xyz1.css" media="all" rel="stylesheet">
|
||||
""",
|
||||
rendered,
|
||||
count=1,
|
||||
)
|
||||
|
||||
assert rendered.count("<script") == 4 # manager + loader + 2 OtherComponent
|
||||
assert rendered.count("<link") == 1 # 1 OtherComponent
|
||||
assert rendered.count("<style") == 1 # 1 Style
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue