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,8 +2985,10 @@
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,
@@ -2998,17 +3002,19 @@
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);
@@ -3020,17 +3026,19 @@
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 }),
@@ -3041,17 +3049,19 @@
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,17 +3075,19 @@
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,17 +3117,19 @@
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,
@@ -3137,17 +3151,19 @@
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,
@@ -3171,17 +3187,19 @@
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,17 +3212,19 @@
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,
@@ -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,8 +3399,10 @@
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;
@@ -3388,17 +3410,19 @@
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,17 +3433,19 @@
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,8 +3473,10 @@
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;
@@ -3460,17 +3488,19 @@
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,17 +3511,19 @@
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,8 +13195,10 @@
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,8 +17769,10 @@
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,
@@ -17751,17 +17787,19 @@
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),
@@ -17776,17 +17814,19 @@
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,
@@ -17814,17 +17854,19 @@
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,
@@ -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,18 +17909,20 @@
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,8 +17961,10 @@
} }
}); });
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,
@@ -17941,17 +17989,19 @@
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,8 +18051,10 @@
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,17 +18068,19 @@
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 = {
@@ -18042,17 +18096,19 @@
} }
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 = [],
@@ -18077,17 +18133,19 @@
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,
@@ -18114,17 +18172,19 @@
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,17 +18198,19 @@
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();
} }
}); });
}); });