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

/wheels/tests/view/urls/autoLink.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 56 lines | 47 code | 9 blank | 0 comment | 0 complexity | cf3b16bd6904fcf151b448120ab02d33 MD5 | raw file
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="setup">
 4		<cfset loc.controller = controller(name="dummy")>
 5	</cffunction>
 6
 7	<cffunction name="test_link_urls">
 8		<cfset loc.str = 'blah blah <a href="http://cfwheels.org/download">http://cfwheels.org/download</a> Download Wheels from http://cfwheels.org/download blah blah'>
 9		<cfset loc.r = loc.controller.autoLink(loc.str, "URLs")>
10		<cfset loc.e = 'blah blah <a href="http://cfwheels.org/download">http://cfwheels.org/download</a> Download Wheels from <a href="http://cfwheels.org/download">http://cfwheels.org/download</a> blah blah'>
11		<cfset assert('loc.e eq loc.r')>
12	</cffunction>
13
14	<cffunction name="test_link_email">
15		<cfset loc.str = 'blah blah <a href="mailto:tpetruzzi@gmail.com">tpetruzzi@gmail.com</a> Download Wheels from tpetruzzi@gmail.com blah blah'>
16		<cfset loc.r = loc.controller.autoLink(loc.str, "emailAddresses")>
17		<cfset loc.e = 'blah blah <a href="mailto:tpetruzzi@gmail.com">tpetruzzi@gmail.com</a> Download Wheels from <a href="mailto:tpetruzzi@gmail.com">tpetruzzi@gmail.com</a> blah blah'>
18		<cfset assert('loc.e eq loc.r')>
19	</cffunction>
20
21	<cffunction name="test_do_not_include_punctuation">
22		<cfset loc.str = 'The best http://cfwheels.org, Framework around. Download Wheels from http://cfwheels.org/download.?!'>
23		<cfset loc.r = loc.controller.autoLink(loc.str, "URLs")>
24		<cfset loc.e = 'The best <a href="http://cfwheels.org">http://cfwheels.org</a>, Framework around. Download Wheels from <a href="http://cfwheels.org/download">http://cfwheels.org/download</a>.?!'>
25		<cfset assert('loc.e eq loc.r')>
26	</cffunction>
27
28	<cffunction name="test_overloaded_argument_become_link_attributes">
29		<cfset loc.str = 'Download Wheels from http://cfwheels.org/download'>
30		<cfset loc.r = loc.controller.autoLink(text=loc.str, link="URLs", target="_blank", class="wheels-href")>
31		<cfset loc.e = 'Download Wheels from <a class="wheels-href" href="http://cfwheels.org/download" target="_blank">http://cfwheels.org/download</a>'>
32		<cfset assert('loc.e eq loc.r')>
33	</cffunction>
34
35	<cffunction name="test_issue_560">
36		<cfset loc.str = 'http://www.foo.uk'>
37		<cfset loc.r = loc.controller.autoLink(loc.str)>
38		<cfset loc.e = '<a href="http://www.foo.uk">http://www.foo.uk</a>'>
39		<cfset assert('loc.e eq loc.r')>
40	</cffunction>
41
42	<cffunction name="test_issue_656_relative_paths_escaped">
43		<cfset loc.str = 'Download Wheels from <a href="/">http://x.com/x</a> blah blah'>
44		<cfset loc.r = loc.controller.autoLink(loc.str)>
45		<cfset loc.e = 'Download Wheels from <a href="/">http://x.com/x</a> blah blah'>
46		<cfset assert('loc.e eq loc.r')>
47	</cffunction>
48
49	<cffunction name="test_issue_656_relative_paths_link">
50		<cfset loc.str ='Download Wheels from /cfwheels.org/download blah blah'>
51		<cfset loc.r = loc.controller.autoLink(loc.str)>
52		<cfset loc.e = 'Download Wheels from <a href="/cfwheels.org/download">/cfwheels.org/download</a> blah blah'>
53		<cfset assert('loc.e eq loc.r')>
54	</cffunction>
55
56</cfcomponent>