diff --git a/.jshintrc b/.jshintrc index fad0529f..cad9eb97 100644 --- a/.jshintrc +++ b/.jshintrc @@ -6,7 +6,6 @@ "expr": true, "immed": false, "noarg": true, - "onevar": true, "smarttabs": true, "trailing": true, "unused": true, diff --git a/bower.json b/bower.json index 69da5b30..61e26ea9 100644 --- a/bower.json +++ b/bower.json @@ -20,7 +20,8 @@ ], "license": "MIT", "dependencies": { - "jquery": ">=1.9.0" + "jquery": ">=1.9.0", + "qunit": "~1.12.0" }, "ignore": [ "**/.*", diff --git a/src/linkified.js b/src/linkified.js index 4b550e5f..3ba667e5 100644 --- a/src/linkified.js +++ b/src/linkified.js @@ -49,7 +49,7 @@ Linkified.prototype = { if (this.element.nodeType === 1) { Linkified.linkifyNode.call(this, this.element); } else { - this.element = Linkified.linkify.apply( + this.element = Linkified.linkify.call( this, this.element.toString() ); diff --git a/tests/js/linkified.js b/tests/js/linkified.js new file mode 100644 index 00000000..ff76b46a --- /dev/null +++ b/tests/js/linkified.js @@ -0,0 +1,49 @@ +/* global test:true */ +/* global equal:true */ + + +test("linkify basics", function () { + + var linkifyTests = [{ + input: 'google.com', + output: 'google.com', + options: null + }, { + input: 'I like google.com the most', + output: 'I like google.com the most', + options: { + tagName: 'span' + } + }, { + input: 'I like Google.com the most', + output: 'I like Google.com the most', + options: null + }, { + input: 'there are two tests, brennan.com and nick.ca -- do they work?', + output: 'there are two tests, brennan.com and nick.ca -- do they work?', + options: { + linkClass: 'alink', + target: '_parent' + } + }, { + input: 'there are two tests!brennan.com. and nick.ca? -- do they work?', + output: 'there are two tests!brennan.com. and nick.ca? -- do they work?', + options: { + linkClasses: ['alink', 'blink'], + linkAttributes: { + 'data-link-test': 'awesome' + } + } + }]; + + for (var i = 0; i < linkifyTests.length; i++) { + equal( + (new Linkified( + linkifyTests[i].input, + linkifyTests[i].options + )).toString(), + linkifyTests[i].output + ); + } + +}); \ No newline at end of file diff --git a/tests/linkified.html b/tests/linkified.html new file mode 100644 index 00000000..495934f5 --- /dev/null +++ b/tests/linkified.html @@ -0,0 +1,18 @@ + + +
+ +