lib/markdown2: introduce markdown base test services
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 30 May 2018 00:48:05 +0000 (20:48 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 20 Jun 2018 23:11:18 +0000 (19:11 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/markdown2/tests/test_markdown.nit [new file with mode: 0644]

diff --git a/lib/markdown2/tests/test_markdown.nit b/lib/markdown2/tests/test_markdown.nit
new file mode 100644 (file)
index 0000000..60f1f34
--- /dev/null
@@ -0,0 +1,42 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Test suites for module `markdown`
+module test_markdown
+
+import markdown_html_rendering
+
+# Abstract test class that instanciates the markdown parser
+abstract class TestMarkdown
+
+       # Markdown parser to use in tests
+       var md_parser = new MdParser
+
+       # Parse a `md` string as a MdNode
+       fun parse_md(md: String): MdNode do return md_parser.parse(md)
+end
+
+# Abstract test class that defines the test methods for HTML rendering
+abstract class TestMarkdownHtml
+       super TestMarkdown
+
+       # HTML renderer used in tests
+       var html_renderer = new HtmlRenderer
+
+       # Render the `md` string as HTML
+       fun md_to_html(md: String): String do
+               var node = parse_md(md)
+               return html_renderer.render(node)
+       end
+end