/scalate-wikitext/src/test/scala/org/fusesource/scalate/wikitext/HtmlMacroTest.scala

http://github.com/scalate/scalate · Scala · 71 lines · 46 code · 8 blank · 17 comment · 0 complexity · 7750e6ef06f01b58868ca9d5aff48058 MD5 · raw file

  1. /**
  2. * Copyright (C) 2009-2011 the original author or authors.
  3. * See the notice.md file distributed with this work for additional
  4. * information regarding copyright ownership.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.fusesource.scalate.wikitext
  19. class HtmlMacroTest extends AbstractConfluenceTest {
  20. test("html macro test") {
  21. assertFilter(
  22. """{html}<p>hello <b>world!</b></p>{html}""",
  23. """<p>hello <b>world!</b></p>""")
  24. }
  25. test("div macro test") {
  26. assertFilter(
  27. """{div}hello world{div}""",
  28. """<div><p>hello world</p></div>""")
  29. }
  30. test("div with attributes macro test") {
  31. assertFilter(
  32. """{div:style=margin-left:-20px; text-align:center; padding-right:20px;}hello world{div}""",
  33. """<div style="margin-left:-20px; text-align:center; padding-right:20px;"><p>hello world</p></div>""")
  34. }
  35. test("section and column") {
  36. assertFilter(
  37. """{section}{column}foo{column}{column}bar{column}{section}""",
  38. """<table class="sectionMacro" border="0" cellpadding="5px" cellspacing="0" width="100%"><tr><td class="confluenceTd" valign="top"><p>foo</p></td><td class="confluenceTd" valign="top"><p>bar</p></td></tr></table>""")
  39. }
  40. test("section and column with line breaks") {
  41. assertFilter(
  42. """
  43. {section}
  44. {column}
  45. foo{column}
  46. {column}
  47. bar
  48. {column}
  49. {section}
  50. """,
  51. """<table class="sectionMacro" border="0" cellpadding="5px" cellspacing="0" width="100%"><tr><td class="confluenceTd" valign="top"><p>foo</p></td><td class="confluenceTd" valign="top"><p>bar</p></td></tr></table>""")
  52. }
  53. test("link with image and width") {
  54. assertFilter(
  55. """[!karaf-box.png|width=256!|Download]""",
  56. """<p><a href="Download"><img width="256" border="0" src="karaf-box.png"/></a></p>""")
  57. }
  58. test("multiple links") {
  59. assertFilter(
  60. """[Foo|foo]/[Bar|bar]""",
  61. """<p><a href="foo">Foo</a>/<a href="bar">Bar</a></p>""")
  62. }
  63. }