Add tests for _.support.funcDecomp and WinRTError.

This commit is contained in:
John-David Dalton
2013-12-15 23:17:33 -08:00
parent 08047d4ab7
commit 38869d5035
2 changed files with 21 additions and 0 deletions

View File

@@ -44,6 +44,8 @@
Object._keys = Object.keys;
Object.keys = function() {};
window.WinRTError = Error;
window.clearTimeout = (function(fn) {
window._clearTimeout = fn;
return function(id) {
@@ -95,6 +97,8 @@
} else {
delete Object.keys;
}
window.WinRTError = undefined;
window.clearTimeout = _clearTimeout;
window._clearTimeout = undefined;

View File

@@ -227,6 +227,9 @@
'})'
].join('\n')));
// fake `WinRTError`
global.WinRTError = Error;
// fake dom
var window = global.window = {};
window.document = {};
@@ -279,6 +282,7 @@
global.setTimeout = _setTimeout;
delete global.window;
delete global.WinRTError;
delete Function.prototype._method;
} catch(e) { }
}
@@ -1412,6 +1416,7 @@
if (_.support.funcNames) {
_.support.funcNames = false;
_.createCallback(c, object);
ok('__bindData__' in c);
_.support.funcNames = true;
}
@@ -1423,6 +1428,18 @@
skipTest(3);
}
});
test('should not write `__bindData__` when `_.support.funcDecomp` is `false`', 1, function() {
function a() {};
if (defineProperty && lodashBizarro) {
lodashBizarro.createCallback(a, {});
equal('__bindData__' in a, false);
}
else {
skipTest();
}
});
}());
/*--------------------------------------------------------------------------*/