Skip to content

Commit 5f9904f

Browse files
committed
Add two more test cases
1 parent cee2398 commit 5f9904f

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

tests/conftest.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,13 @@
22

33

44
def pytest_configure():
5-
settings.configure(INSTALLED_APPS=["django_mermaid.apps.MermaidConfig"])
5+
settings.configure(
6+
INSTALLED_APPS=[
7+
"django_mermaid.apps.MermaidConfig"
8+
],
9+
TEMPLATES=[
10+
{
11+
"BACKEND": "django.template.backends.django.DjangoTemplates",
12+
},
13+
]
14+
)

tests/test_tag.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from django.template import Context
2+
from django.template import Template
3+
14
from django_mermaid.templatetags.mermaid import mermaid
25

36

@@ -6,3 +9,21 @@ def test_tag_renders():
69
"""<div class="mermaid">graph LR; A-->B;</div><script src="mermaid.js"></script>"""
710
"""<script>mermaid.initialize({"startOnLoad": true, theme: "default"});</script>"""
811
)
12+
13+
14+
def test_tag_use_in_template():
15+
template = Template("{% load mermaid %}{% mermaid content %}")
16+
template = template.render(Context({"content": "graph LR; A-->B;"}))
17+
assert template == (
18+
"""<div class="mermaid">graph LR; A-->B;</div><script src="mermaid.js"></script>"""
19+
"""<script>mermaid.initialize({"startOnLoad": true, theme: "default"});</script>"""
20+
)
21+
22+
23+
def test_tag_use_in_template_with_arguments():
24+
template = Template("{% load mermaid %}{% mermaid content \"forest\" %}")
25+
template = template.render(Context({"content": "graph LR; A-->B;"}))
26+
assert template == (
27+
"""<div class="mermaid">graph LR; A-->B;</div><script src="mermaid.js"></script>"""
28+
"""<script>mermaid.initialize({"startOnLoad": true, theme: "forest"});</script>"""
29+
)

0 commit comments

Comments
 (0)