Add regression test for #239 (broke extends tags) + minor tweaks (#247)

This commit is contained in:
adriaan 2023-03-23 21:38:08 +01:00 committed by GitHub
parent 6fcddccd6c
commit 7544bd10e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 1 deletions

6
.gitignore vendored
View file

@ -65,3 +65,9 @@ target/
# as project supports variety of Django versions
poetry.lock
pyproject.toml
# PyCharm
.idea/
# Python environment
.venv/

View file

@ -0,0 +1,12 @@
{% load component_tags %}
<!DOCTYPE html>
<html lang="en">
<body>
<main role="main">
<div class='container main-container'>
{% block body %}
{% endblock %}
</div>
</main>
</body>
</html>

View file

@ -1,2 +1,3 @@
{% load component_tags %}<p class="incrementer">value={{ value }};calls={{ calls }}</p>
{% load component_tags %}
<p class="incrementer">value={{ value }};calls={{ calls }}</p>
{% slot 'content' %}{% endslot %}

View file

@ -1055,3 +1055,50 @@ class ConditionalIfFilledSlotsTests(SimpleTestCase):
"""
rendered = Template(template).render(Context({}))
self.assertHTMLEqual(rendered, expected)
class RegressionTests(SimpleTestCase):
"""Ensure we don't break the same thing AGAIN."""
def setUp(self):
component.registry.clear()
super().setUp()
@classmethod
def tearDownClass(cls):
super().tearDownClass()
component.registry.clear()
def test_extends_tag_works(self):
component.registry.register("slotted_component", SlottedComponent)
template = """
{% extends "extendable_template_with_blocks.html" %}
{% load component_tags %}
{% block body %}
{% component_block "slotted_component" %}
{% fill "header" %}{% endfill %}
{% fill "main" %}
TEST
{% endfill %}
{% fill "footer" %}{% endfill %}
{% endcomponent_block %}
{% endblock %}
"""
rendered = Template(template).render(Context())
expected = """
<!DOCTYPE html>
<html lang="en">
<body>
<main role="main">
<div class='container main-container'>
<custom-template>
<header></header>
<main>TEST</main>
<footer></footer>
</custom-template>
</div>
</main>
</body>
</html>
"""
self.assertHTMLEqual(rendered, expected)