mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 08:37:49 +00:00
Added unit tests for clearing the timer id of _.delay and _.defer and tests for array chaining methods.
This commit is contained in:
74
test/test.js
74
test/test.js
@@ -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 _);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user