2006-10-14 19:50:07 -04:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
2006-09-29 14:52:04 -04:00
|
|
|
require 'test/unit'
|
2006-09-29 14:39:13 -04:00
|
|
|
require File.dirname(__FILE__) + '/../lib/haml/helpers'
|
2006-09-12 00:14:21 -04:00
|
|
|
|
2006-09-29 14:39:13 -04:00
|
|
|
class HelperTest < Test::Unit::TestCase
|
2006-09-12 00:14:21 -04:00
|
|
|
include Haml::Helpers
|
2006-08-08 09:42:19 -04:00
|
|
|
|
|
|
|
def test_find_and_flatten
|
|
|
|
assert_equal(find_and_flatten("<br/><textarea></textarea><br/>"),
|
|
|
|
"<br/><textarea></textarea><br/>")
|
2006-09-29 14:39:13 -04:00
|
|
|
|
2006-08-08 09:42:19 -04:00
|
|
|
assert_equal(find_and_flatten("<code lang='ruby'>TEST!</code>\t\t<p></p>"),
|
|
|
|
"<code lang='ruby'>TEST!</code>\t\t<p></p>")
|
2006-09-29 14:39:13 -04:00
|
|
|
|
2006-08-08 09:42:19 -04:00
|
|
|
assert_equal(find_and_flatten("<pre>Hello\nWorld!\nYOU ARE \rFLAT?\n\rOMGZ!</pre></br>"),
|
|
|
|
"<pre>Hello
World!
YOU ARE FLAT?
OMGZ!</pre></br>")
|
2006-09-29 14:39:13 -04:00
|
|
|
|
|
|
|
assert_equal(find_and_flatten("<div class='text_area_test_area'>\n <textarea>Two\n lines</textarea>\n</div>\n"),
|
|
|
|
"<div class='text_area_test_area'>\n <textarea>Two
 lines</textarea>\n</div>\n")
|
|
|
|
|
|
|
|
assert_equal(find_and_flatten("<code>Two\nlines</code><pre>a\nb\nc</pre>"),
|
|
|
|
"<code>Two
lines</code><pre>a
b
c</pre>")
|
|
|
|
|
|
|
|
assert_equal(find_and_flatten("<pre>Two\nlines</pre>\n<pre>a\nb\nc</pre>"),
|
|
|
|
"<pre>Two
lines</pre>\n<pre>a
b
c</pre>")
|
2006-08-08 17:38:50 -04:00
|
|
|
end
|
|
|
|
|
2006-09-29 14:39:13 -04:00
|
|
|
def test_list_of_should_render_correctly
|
2006-09-19 10:13:49 -04:00
|
|
|
assert_equal("<li>1</li>\n<li>2</li>", (list_of([1, 2]) { |i| i.to_s}))
|
|
|
|
assert_equal("<li>1</li>", (list_of([[1]]) { |i| i.first}))
|
|
|
|
end
|
2006-08-08 09:42:19 -04:00
|
|
|
end
|