Skip to content

Commit ad06a12

Browse files
committed
add capability to test via zuul
Provides test coverage for all major browsers
1 parent e6e4695 commit ad06a12

4 files changed

Lines changed: 64 additions & 32 deletions

File tree

.zuul.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ui: mocha-qunit
2+
browsers:
3+
- name: chrome
4+
version: oldest..latest
5+
- name: firefox
6+
version: oldest..latest
7+
- name: opera
8+
version: latest
9+
- name: safari
10+
version: oldest..latest
11+
- name: ie
12+
version: oldest..latest

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ function ieOnEnd (script, cb) {
4040
script.onreadystatechange = function () {
4141
if (this.readyState != 'complete' && this.readyState != 'loaded') return
4242
this.onreadystatechange = null
43-
cb() // there is no way to catch loading errors in IE8
43+
cb(null, true) // there is no way to catch loading errors in IE8
4444
}
4545
}

test/index.html

Lines changed: 0 additions & 31 deletions
This file was deleted.

test/index.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
var assert = require('assert');
2+
var load = require('../')
3+
4+
var last_msg = undefined;
5+
log = function(msg) {
6+
last_msg = msg;
7+
}
8+
9+
test('success', function(done) {
10+
load('test/hello.js', function (err) {
11+
assert.ifError(err);
12+
assert.equal(last_msg, 'Hello world');
13+
last_msg = undefined;
14+
done();
15+
})
16+
});
17+
18+
test('no exist', function(done) {
19+
load('unexistent.js', function (err, legacy) {
20+
if (!legacy) {
21+
assert.ok(err);
22+
}
23+
24+
var tid = setTimeout(function() {
25+
done();
26+
}, 200);
27+
28+
// some browsers will also throw as well as report erro
29+
var old = window.onerror;
30+
window.onerror = function(msg, file, line) {
31+
if (msg !== 'Error loading script') {
32+
assert(false);
33+
}
34+
window.onerror = old;
35+
clearTimeout(tid);
36+
done();
37+
};
38+
})
39+
});
40+
41+
test('throw', function(done) {
42+
var old = window.onerror;
43+
// silence the script error
44+
window.onerror = function() {};
45+
load('test/throw.js', function (err) {
46+
assert.ifError(err);
47+
window.onerror = old;
48+
done();
49+
})
50+
});
51+

0 commit comments

Comments
 (0)