Skip to content

Commit 2542d02

Browse files
author
nfrasser
committed
Updated test names, browser compatibility
The tests should now all pass on Chrome, Firefox, and the latest IE. Also includes full Saucelabs integration!
1 parent 7a1f033 commit 2542d02

19 files changed

+70
-33
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ env:
77
global:
88
- secure: LhH+mMqOktTe6cIt97PGKBfgUjZM8vRd0qddyg61FSxg7a3WrHQoHE8WdRioJ9+DDzpu/NSTsHEUFUpGN+kSRw1UY4tsNLH6HoBQnqrNN4tVOeefudJpdeteOKZrJ8r8TaA/eO7sAgXO2T+RLJ8+qTbhx8FVZtLaCAgkrS0w9Qk=
99
- secure: Okwm1aAR3oo09AhHDsjFSq1UGlIUtWYYvYeoolJScC/UVFGMiK9oC4fzRtUHv3kXcnshDlcVDrr/Q5JL9Qx6E+tosPJp+tioaqE8X4IDbVk7PPs/ToOOEmWnGvxkgmfCGSDuneG8RVhILkhls3fbm0z+rRWlvJkjefeA96T6zps=
10-
script: npm test
10+
script:
11+
- npm test
12+
- npm run test-ci
1113
after_script: npm run coverage

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
"version": "2.0.0-alpha.4",
44
"description": "Intelligent URL recognition, made easy",
55
"repository": {
6-
"type" : "git",
7-
"url" : "https://github.com/SoapBox/jQuery-linkify.git"
6+
"type": "git",
7+
"url": "https://github.com/SoapBox/jQuery-linkify.git"
88
},
99
"main": "index.js",
1010
"scripts": {
1111
"prepublish": "rm -rf lib/* && node_modules/.bin/gulp build",
1212
"test": "node_modules/.bin/gulp coverage",
13+
"test-ci": "node_modules/.bin/gulp test-ci",
1314
"coverage": "./node_modules/coveralls/bin/coveralls.js < coverage/lcov.info"
1415
},
1516
"author": "SoapBox Innovations (@SoapBoxHQ)",
@@ -28,7 +29,7 @@
2829
"gulp-concat": "^2.5.2",
2930
"gulp-istanbul": "^0.6.0",
3031
"gulp-jshint": "^1.9.2",
31-
"gulp-mocha": "^2.0.0",
32+
"gulp-mocha": "^2.1.0",
3233
"gulp-rename": "^1.2.0",
3334
"gulp-replace": "^0.5.3",
3435
"gulp-uglify": "^1.1.0",
@@ -38,10 +39,11 @@
3839
"karma": "^0.12.32",
3940
"karma-browserify": "^4.0.0",
4041
"karma-chrome-launcher": "^0.1.7",
42+
"karma-firefox-launcher": "^0.1.6",
4143
"karma-mocha": "^0.1.10",
4244
"karma-phantomjs-launcher": "^0.1.4",
4345
"karma-sauce-launcher": "^0.2.10",
44-
"lodash": "^3.5.0",
46+
"lodash": "^3.9.3",
4547
"merge-stream": "^0.1.7",
4648
"mocha": "^2.2.1"
4749
},

src/linkify-jquery.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,20 @@ function apply($, doc=null) {
4242

4343
$(doc).ready(function () {
4444
$('[data-linkify]').each(function () {
45+
4546
let
4647
$this = $(this),
4748
data = $this.data(),
4849
target = data.linkify,
50+
nl2br = data.linkifyNlbr,
4951
options = {
5052
linkAttributes: data.linkifyAttributes,
5153
defaultProtocol: data.linkifyDefaultProtocol,
5254
events: data.linkifyEvents,
5355
format: data.linkifyFormat,
5456
formatHref: data.linkifyFormatHref,
5557
newLine: data.linkifyNewline, // deprecated
56-
nl2br: !!data.linkifyNlbr,
58+
nl2br: !!nl2br && nl2br !== 0 && nl2br !== 'false',
5759
tagName: data.linkifyTagname,
5860
target: data.linkifyTarget,
5961
linkClass: data.linkifyLinkclass,
@@ -65,7 +67,7 @@ function apply($, doc=null) {
6567
}
6668

6769
// Apply it right away if possible
68-
if (typeof __karma__ === 'undefined' && typeof jQuery !== 'undefined' && doc) {
70+
if (typeof jQuery !== 'undefined' && doc) {
6971
apply(jQuery, doc);
7072
}
7173

test/ci.conf.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,18 @@ module.exports = function (config) {
1818
browserName: 'firefox',
1919
version: '30'
2020
},
21-
sl_ios_safari: {
22-
base: 'SauceLabs',
23-
browserName: 'iphone',
24-
platform: 'OS X 10.9',
25-
version: '7.1'
26-
},
2721
sl_ie_11: {
2822
base: 'SauceLabs',
2923
browserName: 'internet explorer',
3024
platform: 'Windows 8.1',
3125
version: '11'
32-
},
26+
}/*,
3327
sl_ie_8: {
3428
base: 'SauceLabs',
3529
browserName: 'internet explorer',
3630
platform: 'Windows 7',
3731
version: '8'
38-
}
32+
}*/
3933
};
4034

4135
config.set(extend(base, {

test/firefox.conf.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Karma Chrome configuration
2+
// Just opens Google Chrome for testing
3+
4+
var
5+
base = require('./conf'),
6+
extend = require('lodash').extend;
7+
8+
module.exports = function (config) {
9+
10+
config.set(extend(base, {
11+
12+
// level of logging
13+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
14+
logLevel: config.LOG_INFO,
15+
browsers: ['Firefox']
16+
}));
17+
};

test/spec/html/extra.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<div data-linkify="header" data-linkify-default-protocol="https" data-linkify-nlbr=true><header>Have a link to:
1+
<div data-linkify="header" data-linkify-default-protocol="https" data-linkify-nlbr="true"><header>Have a link to:
22
github.com!</header></div><div id="linkify-test-div" data-linkify="this" data-linkify-tagname="i" data-linkify-target="_parent" data-linkify-linkclass="test-class" data-linkify-default-protocol="https" data-linkify-nl2br="1">Another [email protected] email as well as a http://t.co link.</div>

test/spec/html/linkified-alt.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
Hello here are some links to <a href="ftp://awesome.com/?where=this" class="linkified" target="_blank" rel="nofollow">ftp://awesome.com/?where=this</a> and <a href="http://localhost:8080" class="linkified" target="_blank" rel="nofollow">localhost:8080</a>, pretty neat right? <p>Here's a nested <a href="http://github.com/SoapBox/linkifyjs" class="linkified" target="_blank" rel="nofollow">github.com/SoapBox/linkifyjs</a> paragraph</p>
2+
Hello here are some links to <a rel="nofollow" target="_blank" class="linkified" href="ftp://awesome.com/?where=this">ftp://awesome.com/?where=this</a> and <a rel="nofollow" target="_blank" class="linkified" href="http://localhost:8080">localhost:8080</a>, pretty neat right? <p>Here's a nested <a rel="nofollow" target="_blank" class="linkified" href="http://github.com/SoapBox/linkifyjs">github.com/SoapBox/linkifyjs</a> paragraph</p>
3+
Hello here are some links to <a class="linkified" href="ftp://awesome.com/?where=this" target="_blank" rel="nofollow">ftp://awesome.com/?where=this</a> and <a class="linkified" href="http://localhost:8080" target="_blank" rel="nofollow">localhost:8080</a>, pretty neat right? <p>Here's a nested <a class="linkified" href="http://github.com/SoapBox/linkifyjs" target="_blank" rel="nofollow">github.com/SoapBox/linkifyjs</a> paragraph</p>

test/spec/html/linkified.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
Hello here are some links to <a href="ftp://awesome.com/?where=this" class="linkified" target="_blank">ftp://awesome.com/?where=this</a> and <a href="http://localhost:8080" class="linkified" target="_blank">localhost:8080</a>, pretty neat right? <p>Here's a nested <a href="http://github.com/SoapBox/linkifyjs" class="linkified" target="_blank">github.com/SoapBox/linkifyjs</a> paragraph</p>
2+
Hello here are some links to <a target="_blank" class="linkified" href="ftp://awesome.com/?where=this">ftp://awesome.com/?where=this</a> and <a target="_blank" class="linkified" href="http://localhost:8080">localhost:8080</a>, pretty neat right? <p>Here's a nested <a target="_blank" class="linkified" href="http://github.com/SoapBox/linkifyjs">github.com/SoapBox/linkifyjs</a> paragraph</p>
3+
Hello here are some links to <a class="linkified" href="ftp://awesome.com/?where=this" target="_blank">ftp://awesome.com/?where=this</a> and <a class="linkified" href="http://localhost:8080" target="_blank">localhost:8080</a>, pretty neat right? <p>Here's a nested <a class="linkified" href="http://github.com/SoapBox/linkifyjs" target="_blank">github.com/SoapBox/linkifyjs</a> paragraph</p>
4+

test/spec/html/options.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@ var fs = require('fs');
33

44
module.exports = {
55
original: fs.readFileSync(__dirname + '/original.html', 'utf8').trim(),
6-
linkified: fs.readFileSync(__dirname + '/linkified.html', 'utf8').trim(),
7-
linkifiedAlt: fs.readFileSync(__dirname + '/linkified-alt.html', 'utf8').trim(),
6+
7+
// These are split into arrays by line, where each line represents a
8+
// different attribute ordering (based on the rendering engine)
9+
// Each line is semantically identical.
10+
linkified: fs.readFileSync(__dirname + '/linkified.html', 'utf8')
11+
.split('\n')
12+
.map(function (line) { return line.trim(); }),
13+
linkifiedAlt: fs.readFileSync(__dirname + '/linkified-alt.html', 'utf8')
14+
.split('\n')
15+
.map(function (line) { return line.trim(); }),
16+
817
extra: fs.readFileSync(__dirname + '/extra.html', 'utf8').trim(), // for jQuery plugin tests
918
altOptions: {
1019
linkAttributes: {

test/spec/linkify-element-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ describe('linkify-element', function () {
5858
(testContainer).should.be.okay;
5959
testContainer.should.be.a('object');
6060
var result = linkifyElement(testContainer, null, doc);
61-
result.should.eql(testContainer); // should return the same element
62-
testContainer.innerHTML.should.eql(htmlOptions.linkified);
61+
result.should.equal(testContainer); // should return the same element
62+
htmlOptions.linkified.should.include(testContainer.innerHTML);
6363
});
6464

6565
it('Works with overriden options', function () {
6666
(testContainer).should.be.okay;
6767
testContainer.should.be.a('object');
6868
var result = linkifyElement(testContainer, htmlOptions.altOptions, doc);
69-
result.should.eql(testContainer); // should return the same element
70-
testContainer.innerHTML.should.eql(htmlOptions.linkifiedAlt);
69+
result.should.equal(testContainer); // should return the same element
70+
htmlOptions.linkifiedAlt.should.include(testContainer.innerHTML);
7171

7272
/*
7373
// These don't work across all test suites :(

0 commit comments

Comments
 (0)