package dotty.tools package dottydoc package staticsite import org.junit.Test import org.junit.Assert._ class PageTests extends DottyDocTest { import scala.collection.JavaConverters._ @Test def mdHas1Key = { val page = new MarkdownPage( """|--- |key: |--- | |great""".stripMargin, Map.empty, Map.empty ) assert( page.yaml == Map("key" -> ""), s"""incorrect yaml, expected "key:" without key in: ${page.yaml}""" ) assertEquals("
great
\n", page.html) } @Test def yamlPreservesLiquidTags = { val page1 = new MarkdownPage( """|--- |key: |--- | |{{ content }}""".stripMargin, Map("content" -> "Hello, world!"), Map.empty ) assert( page1.yaml == Map("key" -> ""), s"""incorrect yaml, expected "key:" without key in: ${page1.yaml}""" ) assertEquals("Hello, world!
\n", page1.html) val page2 = new MarkdownPage( """|{{ content }}""".stripMargin, Map("content" -> "hello"), Map.empty ) assert( page2.yaml == Map(), s"""incorrect yaml, expected "key:" without key in: ${page2.yaml}""" ) assertEquals("hello
\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), Map.empty ) assertEquals( "These shoes are awesome!
\n", page3.html ) } @Test def simpleHtmlPage = { val p1 = new HtmlPage("""