mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Make pad methods default to a chars of " " if chars is an empty string.
This commit is contained in:
47
test/test.js
47
test/test.js
@@ -16169,6 +16169,19 @@
|
||||
assert.strictEqual(_.pad(Object('abc'), 4), 'abc ');
|
||||
assert.strictEqual(_.pad({ 'toString': lodashStable.constant('abc') }, 5), ' abc ');
|
||||
});
|
||||
|
||||
QUnit.test('should use " " in place of `undefined` or empty string `chars` values', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var values = [undefined, ''],
|
||||
expected = lodashStable.map(values, lodashStable.constant(' abc '));
|
||||
|
||||
var actual = lodashStable.map(values, function(value) {
|
||||
return _.pad('abc', 6, value);
|
||||
});
|
||||
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -16194,6 +16207,19 @@
|
||||
assert.strictEqual(_.padEnd(Object('abc'), 4), 'abc ');
|
||||
assert.strictEqual(_.padEnd({ 'toString': lodashStable.constant('abc') }, 5), 'abc ');
|
||||
});
|
||||
|
||||
QUnit.test('should use " " in place of `undefined` or empty string `chars` values', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var values = [undefined, ''],
|
||||
expected = lodashStable.map(values, lodashStable.constant('abc '));
|
||||
|
||||
var actual = lodashStable.map(values, function(value) {
|
||||
return _.padEnd('abc', 6, value);
|
||||
});
|
||||
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -16219,6 +16245,19 @@
|
||||
assert.strictEqual(_.padStart(Object('abc'), 4), ' abc');
|
||||
assert.strictEqual(_.padStart({ 'toString': lodashStable.constant('abc') }, 5), ' abc');
|
||||
});
|
||||
|
||||
QUnit.test('should use " " in place of `undefined` or empty string `chars` values', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var values = [undefined, ''],
|
||||
expected = lodashStable.map(values, lodashStable.constant(' abc'));
|
||||
|
||||
var actual = lodashStable.map(values, function(value) {
|
||||
return _.padStart('abc', 6, value);
|
||||
});
|
||||
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@@ -16264,14 +16303,6 @@
|
||||
assert.strictEqual(func('', 2, chars), expected);
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should work with nullish or empty string values for `chars`', function(assert) {
|
||||
assert.expect(3);
|
||||
|
||||
assert.notStrictEqual(func('abc', 6, null), 'abc');
|
||||
assert.notStrictEqual(func('abc', 6, undefined), 'abc');
|
||||
assert.strictEqual(func('abc', 6, ''), 'abc');
|
||||
});
|
||||
});
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user