Use more pre-QUnit 2.0 APIs.

This commit is contained in:
John-David Dalton
2015-09-09 18:05:48 -07:00
parent d77c5123c1
commit 20695548f1

View File

@@ -577,9 +577,11 @@
} }
}); });
QUnit.asyncTest('should support loading ' + basename + ' in a web worker', function(assert) { QUnit.test('should support loading ' + basename + ' in a web worker', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (Worker) { if (Worker) {
var limit = 30000 / QUnit.config.asyncRetries, var limit = 30000 / QUnit.config.asyncRetries,
start = +new Date; start = +new Date;
@@ -591,14 +593,14 @@
return; return;
} }
assert.strictEqual(actual, _.VERSION); assert.strictEqual(actual, _.VERSION);
QUnit.start(); done();
}; };
attempt(); attempt();
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
@@ -2983,9 +2985,11 @@
QUnit.module('lodash.debounce'); QUnit.module('lodash.debounce');
(function() { (function() {
QUnit.asyncTest('should debounce a function', function(assert) { QUnit.test('should debounce a function', function(assert) {
assert.expect(2); assert.expect(2);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var callCount = 0, var callCount = 0,
debounced = _.debounce(function() { callCount++; }, 32); debounced = _.debounce(function() { callCount++; }, 32);
@@ -2998,18 +3002,20 @@
setTimeout(function() { setTimeout(function() {
assert.strictEqual(callCount, 1); assert.strictEqual(callCount, 1);
QUnit.start(); done();
}, 96); }, 96);
} }
else { else {
skipTest(assert, 2); skipTest(assert, 2);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('subsequent debounced calls return the last `func` result', function(assert) { QUnit.test('subsequent debounced calls return the last `func` result', function(assert) {
assert.expect(2); assert.expect(2);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var debounced = _.debounce(_.identity, 32); var debounced = _.debounce(_.identity, 32);
debounced('x'); debounced('x');
@@ -3020,18 +3026,20 @@
setTimeout(function() { setTimeout(function() {
assert.notEqual(debounced('z'), 'z'); assert.notEqual(debounced('z'), 'z');
QUnit.start(); done();
}, 128); }, 128);
} }
else { else {
skipTest(assert, 2); skipTest(assert, 2);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('subsequent "immediate" debounced calls return the last `func` result', function(assert) { QUnit.test('subsequent "immediate" debounced calls return the last `func` result', function(assert) {
assert.expect(2); assert.expect(2);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var debounced = _.debounce(_.identity, 32, { 'leading': true, 'trailing': false }), var debounced = _.debounce(_.identity, 32, { 'leading': true, 'trailing': false }),
result = [debounced('x'), debounced('y')]; result = [debounced('x'), debounced('y')];
@@ -3041,18 +3049,20 @@
setTimeout(function() { setTimeout(function() {
var result = [debounced('a'), debounced('b')]; var result = [debounced('a'), debounced('b')];
assert.deepEqual(result, ['a', 'a']); assert.deepEqual(result, ['a', 'a']);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert, 2); skipTest(assert, 2);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('should apply default options', function(assert) { QUnit.test('should apply default options', function(assert) {
assert.expect(2); assert.expect(2);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
@@ -3065,18 +3075,20 @@
setTimeout(function() { setTimeout(function() {
assert.strictEqual(callCount, 1); assert.strictEqual(callCount, 1);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert, 2); skipTest(assert, 2);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('should support a `leading` option', function(assert) { QUnit.test('should support a `leading` option', function(assert) {
assert.expect(5); assert.expect(5);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var callCounts = [0, 0]; var callCounts = [0, 0];
@@ -3105,18 +3117,20 @@
withLeading('x'); withLeading('x');
assert.strictEqual(callCounts[0], 2); assert.strictEqual(callCounts[0], 2);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert, 5); skipTest(assert, 5);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('should support a `trailing` option', function(assert) { QUnit.test('should support a `trailing` option', function(assert) {
assert.expect(4); assert.expect(4);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var withCount = 0, var withCount = 0,
withoutCount = 0; withoutCount = 0;
@@ -3137,18 +3151,20 @@
setTimeout(function() { setTimeout(function() {
assert.strictEqual(withCount, 1); assert.strictEqual(withCount, 1);
assert.strictEqual(withoutCount, 0); assert.strictEqual(withoutCount, 0);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert, 4); skipTest(assert, 4);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('should support a `maxWait` option', function(assert) { QUnit.test('should support a `maxWait` option', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var limit = (argv || isPhantom) ? 1000 : 320, var limit = (argv || isPhantom) ? 1000 : 320,
withCount = 0, withCount = 0,
@@ -3171,18 +3187,20 @@
setTimeout(function() { setTimeout(function() {
assert.deepEqual(actual, [true, false]); assert.deepEqual(actual, [true, false]);
QUnit.start(); done();
}, 1); }, 1);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('should cancel `maxDelayed` when `delayed` is invoked', function(assert) { QUnit.test('should cancel `maxDelayed` when `delayed` is invoked', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
@@ -3194,18 +3212,20 @@
setTimeout(function() { setTimeout(function() {
assert.strictEqual(callCount, 1); assert.strictEqual(callCount, 1);
QUnit.start(); done();
}, 128); }, 128);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('should invoke the `trailing` call with the correct arguments and `this` binding', function(assert) { QUnit.test('should invoke the `trailing` call with the correct arguments and `this` binding', function(assert) {
assert.expect(2); assert.expect(2);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var actual, var actual,
callCount = 0, callCount = 0,
@@ -3225,12 +3245,12 @@
setTimeout(function() { setTimeout(function() {
assert.strictEqual(callCount, 2); assert.strictEqual(callCount, 2);
assert.deepEqual(actual, [object, 'a']); assert.deepEqual(actual, [object, 'a']);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert, 2); skipTest(assert, 2);
QUnit.start(); done();
} }
}); });
}()); }());
@@ -3379,27 +3399,31 @@
QUnit.module('lodash.defer'); QUnit.module('lodash.defer');
(function() { (function() {
QUnit.asyncTest('should defer `func` execution', function(assert) { QUnit.test('should defer `func` execution', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var pass = false; var pass = false;
_.defer(function() { pass = true; }); _.defer(function() { pass = true; });
setTimeout(function() { setTimeout(function() {
assert.ok(pass); assert.ok(pass);
QUnit.start(); done();
}, 32); }, 32);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('should provide additional arguments to `func`', function(assert) { QUnit.test('should provide additional arguments to `func`', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var args; var args;
@@ -3409,18 +3433,20 @@
setTimeout(function() { setTimeout(function() {
assert.deepEqual(args, [1, 2]); assert.deepEqual(args, [1, 2]);
QUnit.start(); done();
}, 32); }, 32);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('should be cancelable', function(assert) { QUnit.test('should be cancelable', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var pass = true; var pass = true;
@@ -3432,12 +3458,12 @@
setTimeout(function() { setTimeout(function() {
assert.ok(pass); assert.ok(pass);
QUnit.start(); done();
}, 32); }, 32);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
}()); }());
@@ -3447,9 +3473,11 @@
QUnit.module('lodash.delay'); QUnit.module('lodash.delay');
(function() { (function() {
QUnit.asyncTest('should delay `func` execution', function(assert) { QUnit.test('should delay `func` execution', function(assert) {
assert.expect(2); assert.expect(2);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var pass = false; var pass = false;
_.delay(function() { pass = true; }, 32); _.delay(function() { pass = true; }, 32);
@@ -3460,18 +3488,20 @@
setTimeout(function() { setTimeout(function() {
assert.ok(pass); assert.ok(pass);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert, 2); skipTest(assert, 2);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('should provide additional arguments to `func`', function(assert) { QUnit.test('should provide additional arguments to `func`', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var args; var args;
@@ -3481,18 +3511,20 @@
setTimeout(function() { setTimeout(function() {
assert.deepEqual(args, [1, 2]); assert.deepEqual(args, [1, 2]);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('should be cancelable', function(assert) { QUnit.test('should be cancelable', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var pass = true; var pass = true;
@@ -3504,12 +3536,12 @@
setTimeout(function() { setTimeout(function() {
assert.ok(pass); assert.ok(pass);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
}()); }());
@@ -13163,9 +13195,11 @@
QUnit.module('lodash.now'); QUnit.module('lodash.now');
(function() { (function() {
QUnit.asyncTest('should return the number of milliseconds that have elapsed since the Unix epoch', function(assert) { QUnit.test('should return the number of milliseconds that have elapsed since the Unix epoch', function(assert) {
assert.expect(2); assert.expect(2);
var done = assert.async();
var stamp = +new Date, var stamp = +new Date,
actual = _.now(); actual = _.now();
@@ -13174,12 +13208,12 @@
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
setTimeout(function() { setTimeout(function() {
assert.ok(_.now() > actual); assert.ok(_.now() > actual);
QUnit.start(); done();
}, 32); }, 32);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
}()); }());
@@ -17735,9 +17769,11 @@
QUnit.module('lodash.throttle'); QUnit.module('lodash.throttle');
(function() { (function() {
QUnit.asyncTest('should throttle a function', function(assert) { QUnit.test('should throttle a function', function(assert) {
assert.expect(2); assert.expect(2);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var callCount = 0, var callCount = 0,
throttled = _.throttle(function() { callCount++; }, 32); throttled = _.throttle(function() { callCount++; }, 32);
@@ -17751,18 +17787,20 @@
setTimeout(function() { setTimeout(function() {
assert.ok(callCount > lastCount); assert.ok(callCount > lastCount);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert, 2); skipTest(assert, 2);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('subsequent calls should return the result of the first call', function(assert) { QUnit.test('subsequent calls should return the result of the first call', function(assert) {
assert.expect(5); assert.expect(5);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var throttled = _.throttle(_.identity, 32), var throttled = _.throttle(_.identity, 32),
result = [throttled('a'), throttled('b')]; result = [throttled('a'), throttled('b')];
@@ -17776,18 +17814,20 @@
assert.notEqual(result[1], 'y'); assert.notEqual(result[1], 'y');
assert.notStrictEqual(result[1], undefined); assert.notStrictEqual(result[1], undefined);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert, 5); skipTest(assert, 5);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('should clear timeout when `func` is called', function(assert) { QUnit.test('should clear timeout when `func` is called', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!isModularize) { if (!isModularize) {
var callCount = 0, var callCount = 0,
dateCount = 0; dateCount = 0;
@@ -17814,18 +17854,20 @@
setTimeout(function() { setTimeout(function() {
assert.strictEqual(callCount, 2); assert.strictEqual(callCount, 2);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('should not trigger a trailing call when invoked once', function(assert) { QUnit.test('should not trigger a trailing call when invoked once', function(assert) {
assert.expect(2); assert.expect(2);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var callCount = 0, var callCount = 0,
throttled = _.throttle(function() { callCount++; }, 32); throttled = _.throttle(function() { callCount++; }, 32);
@@ -17835,19 +17877,21 @@
setTimeout(function() { setTimeout(function() {
assert.strictEqual(callCount, 1); assert.strictEqual(callCount, 1);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert, 2); skipTest(assert, 2);
QUnit.start(); done();
} }
}); });
_.times(2, function(index) { _.times(2, function(index) {
QUnit.asyncTest('should trigger a call when invoked repeatedly' + (index ? ' and `leading` is `false`' : ''), function(assert) { QUnit.test('should trigger a call when invoked repeatedly' + (index ? ' and `leading` is `false`' : ''), function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var callCount = 0, var callCount = 0,
limit = (argv || isPhantom) ? 1000 : 320, limit = (argv || isPhantom) ? 1000 : 320,
@@ -17865,19 +17909,21 @@
setTimeout(function() { setTimeout(function() {
assert.ok(actual); assert.ok(actual);
QUnit.start(); done();
}, 1); }, 1);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
}); });
QUnit.asyncTest('should apply default options', function(assert) { QUnit.test('should apply default options', function(assert) {
assert.expect(3); assert.expect(3);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
@@ -17891,12 +17937,12 @@
setTimeout(function() { setTimeout(function() {
assert.strictEqual(callCount, 2); assert.strictEqual(callCount, 2);
QUnit.start(); done();
}, 128); }, 128);
} }
else { else {
skipTest(assert, 3); skipTest(assert, 3);
QUnit.start(); done();
} }
}); });
@@ -17915,9 +17961,11 @@
} }
}); });
QUnit.asyncTest('should support a `trailing` option', function(assert) { QUnit.test('should support a `trailing` option', function(assert) {
assert.expect(6); assert.expect(6);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var withCount = 0, var withCount = 0,
withoutCount = 0; withoutCount = 0;
@@ -17941,18 +17989,20 @@
setTimeout(function() { setTimeout(function() {
assert.strictEqual(withCount, 2); assert.strictEqual(withCount, 2);
assert.strictEqual(withoutCount, 1); assert.strictEqual(withoutCount, 1);
QUnit.start(); done();
}, 256); }, 256);
} }
else { else {
skipTest(assert, 6); skipTest(assert, 6);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('should not update `lastCalled`, at the end of the timeout, when `trailing` is `false`', function(assert) { QUnit.test('should not update `lastCalled`, at the end of the timeout, when `trailing` is `false`', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
@@ -17970,12 +18020,12 @@
setTimeout(function() { setTimeout(function() {
assert.ok(callCount > 1); assert.ok(callCount > 1);
QUnit.start(); done();
}, 192); }, 192);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
}()); }());
@@ -18001,9 +18051,11 @@
assert.ok(pass); assert.ok(pass);
}); });
QUnit.asyncTest('_.' + methodName + ' should have a default `wait` of `0`', function(assert) { QUnit.test('_.' + methodName + ' should have a default `wait` of `0`', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
@@ -18016,18 +18068,20 @@
setTimeout(function() { setTimeout(function() {
funced(); funced();
assert.strictEqual(callCount, isDebounce ? 1 : 2); assert.strictEqual(callCount, isDebounce ? 1 : 2);
QUnit.start(); done();
}, 32); }, 32);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('_.' + methodName + ' should invoke `func` with the correct `this` binding', function(assert) { QUnit.test('_.' + methodName + ' should invoke `func` with the correct `this` binding', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var object = { var object = {
'funced': func(function() { actual.push(this); }, 32) 'funced': func(function() { actual.push(this); }, 32)
@@ -18042,18 +18096,20 @@
} }
setTimeout(function() { setTimeout(function() {
assert.deepEqual(actual, expected); assert.deepEqual(actual, expected);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('_.' + methodName + ' supports recursive calls', function(assert) { QUnit.test('_.' + methodName + ' supports recursive calls', function(assert) {
assert.expect(2); assert.expect(2);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var actual = [], var actual = [],
args = _.map(['a', 'b', 'c'], function(chr) { return [{}, chr]; }), args = _.map(['a', 'b', 'c'], function(chr) { return [{}, chr]; }),
@@ -18077,18 +18133,20 @@
setTimeout(function() { setTimeout(function() {
assert.deepEqual(actual, expected.slice(0, actual.length)); assert.deepEqual(actual, expected.slice(0, actual.length));
QUnit.start(); done();
}, 256); }, 256);
} }
else { else {
skipTest(assert, 2); skipTest(assert, 2);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('_.' + methodName + ' should work if the system time is set backwards', function(assert) { QUnit.test('_.' + methodName + ' should work if the system time is set backwards', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!isModularize) { if (!isModularize) {
var callCount = 0, var callCount = 0,
dateCount = 0; dateCount = 0;
@@ -18114,18 +18172,20 @@
setTimeout(function() { setTimeout(function() {
funced(); funced();
assert.strictEqual(callCount, isDebounce ? 1 : 2); assert.strictEqual(callCount, isDebounce ? 1 : 2);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('_.' + methodName + ' should support cancelling delayed calls', function(assert) { QUnit.test('_.' + methodName + ' should support cancelling delayed calls', function(assert) {
assert.expect(1); assert.expect(1);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
@@ -18138,18 +18198,20 @@
setTimeout(function() { setTimeout(function() {
assert.strictEqual(callCount, 0); assert.strictEqual(callCount, 0);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert); skipTest(assert);
QUnit.start(); done();
} }
}); });
QUnit.asyncTest('_.' + methodName + ' should reset `lastCalled` after cancelling', function(assert) { QUnit.test('_.' + methodName + ' should reset `lastCalled` after cancelling', function(assert) {
assert.expect(3); assert.expect(3);
var done = assert.async();
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
@@ -18163,12 +18225,12 @@
setTimeout(function() { setTimeout(function() {
assert.strictEqual(callCount, 2); assert.strictEqual(callCount, 2);
QUnit.start(); done();
}, 64); }, 64);
} }
else { else {
skipTest(assert, 3); skipTest(assert, 3);
QUnit.start(); done();
} }
}); });
}); });