PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/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 */
18package org.fusesource.scalate.wikitext
19
20class HtmlMacroTest extends AbstractConfluenceTest {
21  test("html macro test") {
22    assertFilter(
23      """{html}<p>hello <b>world!</b></p>{html}""",
24      """<p>hello <b>world!</b></p>""")
25  }
26
27  test("div macro test") {
28    assertFilter(
29      """{div}hello world{div}""",
30      """<div><p>hello world</p></div>""")
31  }
32
33  test("div with attributes macro test") {
34    assertFilter(
35      """{div:style=margin-left:-20px; text-align:center; padding-right:20px;}hello world{div}""",
36      """<div style="margin-left:-20px; text-align:center; padding-right:20px;"><p>hello world</p></div>""")
37  }
38
39  test("section and column") {
40    assertFilter(
41      """{section}{column}foo{column}{column}bar{column}{section}""",
42      """<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>""")
43  }
44
45  test("section and column with line breaks") {
46    assertFilter(
47      """
48{section}
49{column}
50foo{column}
51{column}
52bar
53{column}
54{section}
55""",
56      """<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>""")
57  }
58
59  test("link with image and width") {
60    assertFilter(
61      """[!karaf-box.png|width=256!|Download]""",
62      """<p><a href="Download"><img width="256" border="0" src="karaf-box.png"/></a></p>""")
63  }
64
65  test("multiple links") {
66    assertFilter(
67      """[Foo|foo]/[Bar|bar]""",
68      """<p><a href="foo">Foo</a>/<a href="bar">Bar</a></p>""")
69  }
70
71}