display_helper_test.rb
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require File.dirname(__FILE__) + '/../test_helper'
class DisplayHelperTest < Test::Unit::TestCase
include DisplayHelper
include ActionView::Helpers::TagHelper
#### product_path related tests ####
# TODO: product_path has no tests!
#### txt2html related tests ####
should 'show txt line-breaks' do
html = txt2html "Bli\n123"
assert_equal "Bli\n<br/>\n123", html
html = txt2html "Bli\n123 456\nabc"
assert_equal "Bli\n<br/>\n123 456\n<br/>\nabc", html
end
should 'replace empty lines as paragraphs separators' do
html = txt2html "Bli\n\n123"
assert_equal "Bli\n<p/>\n123", html
html = txt2html "Bli \n \n 123"
assert_equal "Bli\n<p/>\n123", html
end
should 'trim txt before convert to html' do
html = txt2html "\nBli\n123\n"
assert_equal "Bli\n<br/>\n123", html
html = txt2html " Bli\n123 "
assert_equal "Bli\n<br/>\n123", html
html = txt2html " \nBli\n123\n "
assert_equal "Bli\n<br/>\n123", html
end
should 'linkify "http://" prepended words on txt2html' do
html = txt2html "go to http://noosfero.org"
assert_equal 'go to <a href="http://noosfero.org" onclick="return confirm(\'Are you sure you want to visit this web site?\')" rel="nofolow" target="_blank">noos​fero​.org</a>', html
end
should 'linkify "www." prepended words on txt2html' do
html = txt2html "go to www.noosfero.org yeah!"
assert_equal 'go to <a href="http://www.noosfero.org" onclick="return confirm(\'Are you sure you want to visit this web site?\')" rel="nofolow" target="_blank">www.​noos​fero​.org</a> yeah!', html
end
end