30
spec/core/baseSpec.js
Normal file
30
spec/core/baseSpec.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
describe('base helpers', function() {
|
||||||
|
describe('isError_', function() {
|
||||||
|
fit("correctly handles WebSocket events", function(done) {
|
||||||
|
if (typeof jasmine.getGlobal().WebSocket === 'undefined') {
|
||||||
|
done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var obj = (function() {
|
||||||
|
var sock = new WebSocket('ws://localhost');
|
||||||
|
var event;
|
||||||
|
sock.onerror = function(e) {
|
||||||
|
event = e
|
||||||
|
};
|
||||||
|
return function() { return event };
|
||||||
|
})();
|
||||||
|
var left = 20;
|
||||||
|
|
||||||
|
var int = setInterval(function() {
|
||||||
|
if (obj() || left === 0) {
|
||||||
|
var result = jasmineUnderTest.isError_(obj());
|
||||||
|
expect(result).toBe(false);
|
||||||
|
done();
|
||||||
|
} else {
|
||||||
|
left--;
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -89,9 +89,15 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
|
|||||||
if (value instanceof Error) {
|
if (value instanceof Error) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (value && value.constructor && value.constructor.constructor &&
|
if (value && value.constructor && value.constructor.constructor) {
|
||||||
(value instanceof (value.constructor.constructor('return this')()).Error)) {
|
var valueGlobal = value.constructor.constructor('return this');
|
||||||
return true;
|
if (j$.isFunction_(valueGlobal)) {
|
||||||
|
valueGlobal = valueGlobal();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valueGlobal.Error && value instanceof valueGlobal.Error) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user