Added unit tests for clearing the timer id of _.delay and _.defer and tests for array chaining methods.

This commit is contained in:
John-David Dalton
2013-11-24 15:11:45 -06:00
parent a150a8fd52
commit 97ea15300c

View File

@@ -1682,6 +1682,27 @@
QUnit.start();
}
});
asyncTest('should be cancelable', 1, function() {
if (!(isRhino && isModularize)) {
var pass = true;
var timerId = _.defer(function() {
pass = false;
});
clearTimeout(timerId);
setTimeout(function() {
ok(pass);
QUnit.start();
}, 128);
}
else {
skipTest();
QUnit.start();
}
});
}());
/*--------------------------------------------------------------------------*/
@@ -1727,6 +1748,27 @@
QUnit.start();
}
});
asyncTest('should be cancelable', 1, function() {
if (!(isRhino && isModularize)) {
var pass = true;
var timerId = _.delay(function() {
pass = false;
}, 32);
clearTimeout(timerId);
setTimeout(function() {
ok(pass);
QUnit.start();
}, 128);
}
else {
skipTest();
QUnit.start();
}
});
}());
/*--------------------------------------------------------------------------*/
@@ -7945,7 +7987,34 @@
/*--------------------------------------------------------------------------*/
QUnit.module('lodash(...) methods that return wrapped values');
QUnit.module('lodash(...) methods that return existing wrapped values');
(function() {
var array = [1, 2, 3],
wrapped = _(array);
var funcs = [
'push',
'reverse',
'sort',
'unshift'
];
_.forEach(funcs, function(methodName) {
test('`_(...).' + methodName + '` should return the existing wrapped value', 1, function() {
if (!isNpm) {
strictEqual(wrapped[methodName](), wrapped);
}
else {
skipTest();
}
});
});
}());
/*--------------------------------------------------------------------------*/
QUnit.module('lodash(...) methods that return new wrapped values');
(function() {
var array = [1, 2, 3],
@@ -7953,11 +8022,12 @@
var funcs = [
'concat',
'slice',
'splice'
];
_.forEach(funcs, function(methodName) {
test('`_.' + methodName + '` should return a wrapped value', 1, function() {
test('`_(...).' + methodName + '` should return a new wrapped value', 1, function() {
if (!isNpm) {
ok(wrapped[methodName]() instanceof _);
}