Skip to content

Commit

Permalink
GH-5: Update the mocks to fix CI fail
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtyomVancyan committed Mar 13, 2023
1 parent d1cda2a commit 00963a4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/test_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@
from os.path import exists
from os.path import join

from django.conf import settings
from django.template import Context
from django.template import Template

from django_mermaid.templatetags import MERMAID_VERSION
from django_mermaid.templatetags.mermaid import mermaid


def test_tag_renders():
assert mermaid("graph LR; A-->B;") == (
"""<div class="mermaid">graph LR; A-->B;</div><script src="mermaid.js"></script>"""
"""<script>mermaid.initialize({"startOnLoad": true, theme: "default"});</script>"""
"<div class=\"mermaid\">graph LR; A-->B;</div><script src=\"mermaid/%s/mermaid.js\"></script>"
"<script>mermaid.initialize({\"startOnLoad\": true, theme: \"default\"});</script>" % MERMAID_VERSION
)


def test_tag_use_in_template():
template = Template("{% load mermaid %}{% mermaid content %}")
template = template.render(Context({"content": "graph LR; A-->B;"}))
assert template == (
"""<div class="mermaid">graph LR; A-->B;</div><script src="mermaid.js"></script>"""
"""<script>mermaid.initialize({"startOnLoad": true, theme: "default"});</script>"""
"<div class=\"mermaid\">graph LR; A-->B;</div><script src=\"mermaid/%s/mermaid.js\"></script>"
"<script>mermaid.initialize({\"startOnLoad\": true, theme: \"default\"});</script>" % MERMAID_VERSION
)


def test_tag_use_in_template_with_arguments():
template = Template("{% load mermaid %}{% mermaid content \"forest\" %}")
template = template.render(Context({"content": "graph LR; A-->B;"}))
assert template == (
"""<div class="mermaid">graph LR; A-->B;</div><script src="mermaid.js"></script>"""
"""<script>mermaid.initialize({"startOnLoad": true, theme: "forest"});</script>"""
"<div class=\"mermaid\">graph LR; A-->B;</div><script src=\"mermaid/%s/mermaid.js\"></script>"
"<script>mermaid.initialize({\"startOnLoad\": true, theme: \"forest\"});</script>" % MERMAID_VERSION
)


def test_tag_use_custom_version():
static_dir = join(dirname(__file__), "..", "src", "django_mermaid", "static")
assert exists(join(static_dir, "mermaid", settings.MERMAID_VERSION, "mermaid.js"))
assert exists(join(static_dir, "mermaid", MERMAID_VERSION, "mermaid.js"))

0 comments on commit 00963a4

Please sign in to comment.