66from django .template import Context
77from django .template import Template
88from django .test import override_settings
9-
109from django_mermaid .templatetags import DEFAULT_THEME
1110
1211
@@ -16,7 +15,8 @@ def test_tag_use_in_template(version):
1615 template = template .render (Context ({"content" : "graph LR; A-->B;" }))
1716 assert template == (
1817 "<div class=\" mermaid\" >graph LR; A-->B;</div><script src=\" mermaid/%s/mermaid.js\" ></script>"
19- "<script>mermaid.initialize({\" startOnLoad\" : true, theme: \" %s\" });</script>" % (version , theme )
18+ "<script>mermaid.initialize({\" startOnLoad\" : true, \" theme\" : \" %s\" , \" themeVariables\" : {}"
19+ "});</script>" % (version , theme )
2020 )
2121
2222
@@ -26,7 +26,8 @@ def test_tag_use_settings_theme(version):
2626 template = template .render (Context ({"content" : "graph LR; A-->B;" }))
2727 assert template == (
2828 "<div class=\" mermaid\" >graph LR; A-->B;</div><script src=\" mermaid/%s/mermaid.js\" ></script>"
29- "<script>mermaid.initialize({\" startOnLoad\" : true, theme: \" forest\" });</script>" % version
29+ "<script>mermaid.initialize({\" startOnLoad\" : true, \" theme\" : \" forest\" , \" themeVariables\" "
30+ ": {}});</script>" % version
3031 )
3132
3233
@@ -35,7 +36,30 @@ def test_tag_use_custom_theme(version):
3536 template = template .render (Context ({"content" : "graph LR; A-->B;" }))
3637 assert template == (
3738 "<div class=\" mermaid\" >graph LR; A-->B;</div><script src=\" mermaid/%s/mermaid.js\" ></script>"
38- "<script>mermaid.initialize({\" startOnLoad\" : true, theme: \" dark\" });</script>" % version
39+ "<script>mermaid.initialize({\" startOnLoad\" : true, \" theme\" : \" dark\" , \" themeVariables\" : "
40+ "{}});</script>" % version
41+ )
42+
43+
44+ @override_settings (MERMAID_THEME_VARIABLES = {"primaryColor" : "red" })
45+ def test_tag_use_custom_theme_variables (version ):
46+ template = Template ("{% load mermaid %}{% mermaid content \" dark\" %}" )
47+ template = template .render (Context ({"content" : "graph LR; A-->B;" }))
48+ assert template == (
49+ "<div class=\" mermaid\" >graph LR; A-->B;</div><script src=\" mermaid/%s/mermaid.js\" ></script>"
50+ "<script>mermaid.initialize({\" startOnLoad\" : true, \" theme\" : \" dark\" , \" themeVariables\" : "
51+ "{}});</script>" % version
52+ )
53+
54+
55+ @override_settings (MERMAID_THEME = "base" , MERMAID_THEME_VARIABLES = {"primaryColor" : "#efefef" })
56+ def test_tag_use_custom_theme_variables_with_base_theme (version ):
57+ template = Template ("{% load mermaid %}{% mermaid content %}" )
58+ template = template .render (Context ({"content" : "graph LR; A-->B;" }))
59+ assert template == (
60+ "<div class=\" mermaid\" >graph LR; A-->B;</div><script src=\" mermaid/%s/mermaid.js\" ></script>"
61+ "<script>mermaid.initialize({\" startOnLoad\" : true, \" theme\" : \" base\" , \" themeVariables\" : "
62+ "{\" primaryColor\" : \" #efefef\" }});</script>" % version
3963 )
4064
4165
0 commit comments