aboutsummaryrefslogtreecommitdiff
path: root/doc-tool/test
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-01-05 17:15:02 +0100
committerFelix Mulder <felix.mulder@gmail.com>2017-01-31 14:29:18 +0100
commit1dc446fc8973dce2da0bbb3c6eb97aa035d0d191 (patch)
tree8cb3c6bb35d5c2d82fdecc44c73d8fd77d47d817 /doc-tool/test
parent56cec80db7ab46c69cbbc8551ddf3c9857f8a804 (diff)
downloaddotty-1dc446fc8973dce2da0bbb3c6eb97aa035d0d191.tar.gz
dotty-1dc446fc8973dce2da0bbb3c6eb97aa035d0d191.tar.bz2
dotty-1dc446fc8973dce2da0bbb3c6eb97aa035d0d191.zip
Add initial page rendering using liquid and yaml front matter
Diffstat (limited to 'doc-tool/test')
-rw-r--r--doc-tool/test/YamlTest.scala69
1 files changed, 69 insertions, 0 deletions
diff --git a/doc-tool/test/YamlTest.scala b/doc-tool/test/YamlTest.scala
new file mode 100644
index 000000000..2d633d12c
--- /dev/null
+++ b/doc-tool/test/YamlTest.scala
@@ -0,0 +1,69 @@
+package dotty.tools
+package dottydoc
+
+import org.junit.Test
+import org.junit.Assert._
+
+import staticsite.MarkdownPage
+
+class YamlTest extends DottyDocTest {
+ import scala.collection.JavaConverters._
+
+ @Test def has1Key = {
+ val page = new MarkdownPage(
+ """|---
+ |key:
+ |---
+ |
+ |great""".stripMargin,
+ Map.empty
+ )
+
+ assert(
+ page.yaml == Map("key" -> ""),
+ s"""incorrect yaml, expected "key:" without key in: ${page.yaml}"""
+ )
+
+ assertEquals("<p>great</p>\n", page.html)
+ }
+
+ @Test def yamlPreservesLiquidTags = {
+ val page1 = new MarkdownPage(
+ """|---
+ |key:
+ |---
+ |
+ |{{ content }}""".stripMargin,
+ Map("content" -> "Hello, world!")
+ )
+
+ assert(
+ page1.yaml == Map("key" -> ""),
+ s"""incorrect yaml, expected "key:" without key in: ${page1.yaml}"""
+ )
+
+ assertEquals("<p>Hello, world!</p>\n", page1.html)
+
+ val page2 = new MarkdownPage(
+ """|{{ content }}""".stripMargin,
+ Map("content" -> "hello")
+ )
+ assert(
+ page2.yaml == Map(),
+ s"""incorrect yaml, expected "key:" without key in: ${page2.yaml}"""
+ )
+ assertEquals("<p>hello</p>\n", page2.html)
+
+ val page3 = new MarkdownPage(
+ """|{% if product.title == "Awesome Shoes" %}
+ |These shoes are awesome!
+ |{% endif %}""".stripMargin,
+ Map("product" -> Map("title" -> "Awesome Shoes").asJava)
+ )
+
+ assertEquals(
+ "<p>These shoes are awesome!</p>\n",
+ page3.html
+ )
+ }
+}