describe "autolink", -> it "can be called on a string", -> expect("hi there".autoLink()).toBeDefined() it "does not alter a string with no URL present", -> expect("hi again".autoLink()).toEqual("hi again") it "returns the string with the URLs hyperlinked", -> expect("Check out this search engine http://google.com".autoLink()). toEqual( "Check out this search engine " + "http://google.com" ) it "does not hyperlink additional non-URL text", -> expect("LMSTFY: http://google.com and RTFM".autoLink()). toEqual( "LMSTFY: http://google.com and RTFM" ) it "correctly hyperlinks text with multiple URLs", -> expect( "Google is http://google.com and Twitter is http://twitter.com".autoLink() ).toEqual( "Google is http://google.com and " + "Twitter is http://twitter.com" ) it "correctly hyperlinks URLs, regardless of TLD", -> expect("Click here http://bit.ly/1337 now".autoLink()). toEqual( "Click here http://bit.ly/1337 now" ) it "correctly hyperlinks URLs, regardless of subdomain", -> expect("Check it: http://some.sub.domain".autoLink()). toEqual( "Check it: http://some.sub.domain" ) it "correctly handles punctuation", -> expect("Go here now http://google.com!".autoLink()). toEqual( "Go here now http://google.com!" ) it "correctly handles hash character(#)", -> expect("Go here now http://google.com/#query=index".autoLink()). toEqual( "Go here now http://google.com/#query=index" ) it "correctly handles escaped fragment character(#!)", -> expect("Go here now http://twitter.com/#!/PostDeskUK".autoLink()). toEqual( "Go here now http://twitter.com/#!/PostDeskUK" ) it "correctly handles parentheses ()", -> expect("My favorite Wikipedia Article http://en.wikipedia.org/wiki/Culture_of_honor_(Southern_United_States)".autoLink()). toEqual( "My favorite Wikipedia Article http://en.wikipedia.org/wiki/Culture_of_honor_(Southern_United_States)" ) it "allows single right quotes", -> expect("Safety for Syria’s Women http://www.rescue.org/press-releases/syria’s-women-and-girls-continue-face-chaos-and-danger-fearing-their-safety-18565".autoLink()). toEqual( "Safety for Syria’s Women http://www.rescue.org/press-releases/syria’s-women-and-girls-continue-face-chaos-and-danger-fearing-their-safety-18565" ) it "correctly handles FTP links", -> expect("Click here ftp://ftp.google.com".autoLink()). toEqual( "Click here ftp://ftp.google.com" ) it "sets link attributes based on the options provided", -> expect("Google it: http://google.com".autoLink(target: "_blank")). toEqual( "Google it: " + "http://google.com" ) it "sets multiple link attributes if more than one is given", -> expect( "Google it: http://google.com".autoLink(target: "_blank", rel: "nofollow") ).toEqual( "Google it: http://google.com" ) xit "correctly handles surrounding HTML tags", -> expect("
http://nba.com
".autoLink()). toEqual("") it "can begin with a hyperlink", -> expect("http://google.com That is a link to Google".autoLink()). toEqual( "http://google.com " + "That is a link to Google" ) it "can have a hyperlink as first part of a new line", -> expect("I think I can help you.\nhttp://google.com That is a link to Google".autoLink()). toEqual( "I think I can help you.\n" + "http://google.com " + "That is a link to Google" ) it "can have a hyperlink as first part of a new HTML line", -> expect("I think I can help you.http://google.com
" + "http://google.com" + "
".autoLink())
.toEqual("Image
")
it "will not affect anchors", ->
expect("Anchor http://example.com".autoLink())
.toEqual("Anchor http://example.com")
it "will still work", ->
expect("Anchor http://example.com to http://example.com".autoLink())
.toEqual("Anchor http://example.com to http://example.com")