1 module("wysihtml5.dom.autoLink", {
2 equal: function(actual, expected, message) {
3 return QUnit.assert.htmlEqual(actual, expected, message);
6 autoLink: function(html) {
7 var container = wysihtml5.dom.getAsDom(html);
8 return wysihtml5.dom.autoLink(container).innerHTML;
13 test("Basic test", function() {
14 ok(wysihtml5.dom.autoLink.URL_REG_EXP, "URL reg exp is revealed to be access globally");
17 this.autoLink("hey check out this search engine http://www.google.com"),
18 "hey check out this search engine <a href=\"http://www.google.com\">http://www.google.com</a>",
19 "Urls starting with http:// are correctly linked"
23 this.autoLink("hey check out this search engine https://www.google.com"),
24 "hey check out this search engine <a href=\"https://www.google.com\">https://www.google.com</a>",
25 "Urls starting with https:// are correctly linked"
29 this.autoLink("hey check out this search engine www.google.com"),
30 "hey check out this search engine <a href=\"http://www.google.com\">www.google.com</a>",
31 "Urls starting with www. are correctly linked"
35 this.autoLink("hey check out this mail christopher.blum@xing.com"),
36 "hey check out this mail christopher.blum@xing.com",
37 "E-Mails are not linked"
41 this.autoLink("http://google.de"),
42 "<a href=\"http://google.de\">http://google.de</a>",
43 "Single url without www. but with http:// is auto linked"
47 this.autoLink("hey check out this search engine <a href=\"http://www.google.com\">www.google.com</a>"),
48 "hey check out this search engine <a href=\"http://www.google.com\">www.google.com</a>",
49 "Already auto-linked stuff isn't causing a relinking"
53 this.autoLink("hey check out this search engine <code><span>http://www.google.com</span></code>"),
54 "hey check out this search engine <code><span>http://www.google.com</span></code>",
55 "Urls inside 'code' elements are not auto linked"
59 this.autoLink("hey check out this search engine <pre>http://www.google.com</pre>"),
60 "hey check out this search engine <pre>http://www.google.com</pre>",
61 "Urls inside 'pre' elements are not auto linked"
65 this.autoLink("hey check out this search engine (http://www.google.com)"),
66 "hey check out this search engine (<a href=\"http://www.google.com\">http://www.google.com</a>)",
67 "Parenthesis around url are not part of url #1"
71 this.autoLink("hey check out this search engine (http://www.google.com?q=hello(spencer))"),
72 "hey check out this search engine (<a href=\"http://www.google.com?q=hello(spencer)\">http://www.google.com?q=hello(spencer)</a>)",
73 "Parenthesis around url are not part of url #2"
77 this.autoLink("hey check out this search engine <span>http://www.google.com?q=hello(spencer)</span>"),
78 "hey check out this search engine <span><a href=\"http://www.google.com?q=hello(spencer)\">http://www.google.com?q=hello(spencer)</a></span>",
79 "Urls in tags are correctly auto linked"
83 this.autoLink("http://google.de and http://yahoo.com as well as <span>http://de.finance.yahoo.com</span> <a href=\"http://google.com\" class=\"more\">http://google.com</a>"),
84 "<a href=\"http://google.de\">http://google.de</a> and <a href=\"http://yahoo.com\">http://yahoo.com</a> as well as <span><a href=\"http://de.finance.yahoo.com\">http://de.finance.yahoo.com</a></span> <a href=\"http://google.com\" class=\"more\">http://google.com</a>",
85 "Multiple urls are correctly auto linked"
89 this.autoLink("<script>http://google.de</script>"),
90 "<script>http://google.de</script>",
91 "Urls in SCRIPT elements are not touched"
95 this.autoLink("<script>http://google.de</script>"),
96 "<script>http://google.de</script>",
97 "Urls in SCRIPT elements are not touched"
101 this.autoLink(" http://www.google.de"),
102 " <a href=\"http://www.google.de\">http://www.google.de</a>",
103 "Check if white space in front of url is preserved"
107 this.autoLink("<b>foo</b> http://www.google.de"),
108 "<b>foo</b> <a href=\"http://www.google.de\">http://www.google.de</a>",
109 "Check if plain HTML markup isn't evaluated"