Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
berendkleinhaneveld committed May 7, 2024
1 parent 995288b commit 835cf25
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
52 changes: 51 additions & 1 deletion tests/test_tag_template.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from observ import reactive

from collagraph import Collagraph, EventLoopType
from collagraph.renderers import DictRenderer


def test_basic_dict_renderer(parse_source):
def test_tag_template(parse_source):
App, _ = parse_source(
"""
<template>
Expand Down Expand Up @@ -32,3 +34,51 @@ class App(cg.Component):
_ = None
container = None
gui = None


def test_component_template_tag(parse_source):
Template, _ = parse_source(
"""
<template>
<content>
<template>
<child name="a" />
<child name="b" />
</template>
<!-- FIXME: v-if="more" creates NameError -->
<template v-if="props['more']">
<child name="c" />
<child name="d" />
</template>
</content>
</template>
<script lang="python">
import collagraph as cg
class Template(cg.Component):
pass
</script>
"""
)

gui = Collagraph(DictRenderer(), event_loop_type=EventLoopType.SYNC)
container = {"type": "root"}
state = reactive({"more": False})

gui.render(Template, container, state=state)

content = container["children"][0]
assert content["type"] == "content"

assert len(content["children"]) == 2
for child, name in zip(content["children"], ["a", "b"]):
assert child["type"] == "child"
assert child["attrs"]["name"] == name

state["more"] = True

assert len(content["children"]) == 4
for child, name in zip(content["children"], ["a", "b", "c", "d"]):
assert child["type"] == "child"
assert child["attrs"]["name"] == name
21 changes: 0 additions & 21 deletions tests_legacy/data/template.cgx

This file was deleted.

29 changes: 0 additions & 29 deletions tests_legacy/test_template_tags.py

This file was deleted.

0 comments on commit 835cf25

Please sign in to comment.