mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Remove try-catches in tests where possible.
This commit is contained in:
61
test/test.js
61
test/test.js
@@ -11956,14 +11956,8 @@
|
|||||||
|
|
||||||
lodashStable.each(funcs, function(methodName) {
|
lodashStable.each(funcs, function(methodName) {
|
||||||
if (xml) {
|
if (xml) {
|
||||||
var pass = true;
|
_[methodName](xml);
|
||||||
|
assert.ok(true, '`_.' + methodName + '` should not error');
|
||||||
try {
|
|
||||||
_[methodName](xml);
|
|
||||||
} catch (e) {
|
|
||||||
pass = false;
|
|
||||||
}
|
|
||||||
assert.ok(pass, '`_.' + methodName + '` should not error');
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skipAssert(assert);
|
skipAssert(assert);
|
||||||
@@ -16526,20 +16520,14 @@
|
|||||||
QUnit.test('should not throw more than once', function(assert) {
|
QUnit.test('should not throw more than once', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var pass = true;
|
|
||||||
|
|
||||||
var once = _.once(function() {
|
var once = _.once(function() {
|
||||||
throw new Error;
|
throw new Error;
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.raises(once);
|
assert.raises(once);
|
||||||
|
|
||||||
try {
|
once();
|
||||||
once();
|
assert.ok(true);
|
||||||
} catch (e) {
|
|
||||||
pass = false;
|
|
||||||
}
|
|
||||||
assert.ok(pass);
|
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
@@ -22246,23 +22234,11 @@
|
|||||||
QUnit.test('should not error for non-object `data` and `options` values', function(assert) {
|
QUnit.test('should not error for non-object `data` and `options` values', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var pass = true;
|
_.template('')(1);
|
||||||
|
assert.ok(true, '`data` value');
|
||||||
|
|
||||||
try {
|
_.template('', 1)(1);
|
||||||
_.template('')(1);
|
assert.ok(true, '`options` value');
|
||||||
} catch (e) {
|
|
||||||
pass = false;
|
|
||||||
}
|
|
||||||
assert.ok(pass, '`data` value');
|
|
||||||
|
|
||||||
pass = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
_.template('', 1)(1);
|
|
||||||
} catch (e) {
|
|
||||||
pass = false;
|
|
||||||
}
|
|
||||||
assert.ok(pass, '`options` value');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should expose the source on compiled templates', function(assert) {
|
QUnit.test('should expose the source on compiled templates', function(assert) {
|
||||||
@@ -22694,14 +22670,8 @@
|
|||||||
QUnit.test('`_.' + methodName + '` should not error for non-object `options` values', function(assert) {
|
QUnit.test('`_.' + methodName + '` should not error for non-object `options` values', function(assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
var pass = true;
|
func(noop, 32, 1);
|
||||||
|
assert.ok(true);
|
||||||
try {
|
|
||||||
func(noop, 32, 1);
|
|
||||||
} catch (e) {
|
|
||||||
pass = false;
|
|
||||||
}
|
|
||||||
assert.ok(pass);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('`_.' + methodName + '` should use a default `wait` of `0`', function(assert) {
|
QUnit.test('`_.' + methodName + '` should use a default `wait` of `0`', function(assert) {
|
||||||
@@ -26521,15 +26491,10 @@
|
|||||||
|
|
||||||
lodashStable.each(acceptFalsey, function(methodName) {
|
lodashStable.each(acceptFalsey, function(methodName) {
|
||||||
var expected = arrays,
|
var expected = arrays,
|
||||||
func = _[methodName],
|
func = _[methodName];
|
||||||
pass = true;
|
|
||||||
|
|
||||||
var actual = lodashStable.map(falsey, function(value, index) {
|
var actual = lodashStable.map(falsey, function(value, index) {
|
||||||
try {
|
return index ? func(value) : func();
|
||||||
return index ? func(value) : func();
|
|
||||||
} catch (e) {
|
|
||||||
pass = false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (methodName == 'noConflict') {
|
if (methodName == 'noConflict') {
|
||||||
@@ -26541,7 +26506,7 @@
|
|||||||
if (lodashStable.includes(returnArrays, methodName) && methodName != 'sample') {
|
if (lodashStable.includes(returnArrays, methodName) && methodName != 'sample') {
|
||||||
assert.deepEqual(actual, expected, '_.' + methodName + ' returns an array');
|
assert.deepEqual(actual, expected, '_.' + methodName + ' returns an array');
|
||||||
}
|
}
|
||||||
assert.ok(pass, '`_.' + methodName + '` accepts falsey arguments');
|
assert.ok(true, '`_.' + methodName + '` accepts falsey arguments');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Skip tests for missing methods of modularized builds.
|
// Skip tests for missing methods of modularized builds.
|
||||||
|
|||||||
Reference in New Issue
Block a user