6
6
from django .template import Context
7
7
from django .template import Template
8
8
from django .test import override_settings
9
-
10
9
from django_mermaid .templatetags import DEFAULT_THEME
11
10
12
11
@@ -16,7 +15,8 @@ def test_tag_use_in_template(version):
16
15
template = template .render (Context ({"content" : "graph LR; A-->B;" }))
17
16
assert template == (
18
17
"<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 )
20
20
)
21
21
22
22
@@ -26,7 +26,8 @@ def test_tag_use_settings_theme(version):
26
26
template = template .render (Context ({"content" : "graph LR; A-->B;" }))
27
27
assert template == (
28
28
"<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
30
31
)
31
32
32
33
@@ -35,7 +36,30 @@ def test_tag_use_custom_theme(version):
35
36
template = template .render (Context ({"content" : "graph LR; A-->B;" }))
36
37
assert template == (
37
38
"<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
39
63
)
40
64
41
65
0 commit comments