mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
Make _.uniqueId consistently return a string value.
Former-commit-id: 5a5c626df83b0fc78e9bae37510680383f112c0b
This commit is contained in:
@@ -698,6 +698,10 @@
|
||||
equal(lodash.some([false, true, false]), true, '_.some: ' + basename);
|
||||
equal(lodash.template('${a}', object), '${a}', '_.template should ignore ES6 delimiters: ' + basename);
|
||||
|
||||
actual = [lodash.uniqueId(3), lodash.uniqueId(2), lodash.uniqueId(1)];
|
||||
equal(actual.join(','), '3,3,3', '_.uniqueId should not coerce the prefix argument to a string: ' + basename);
|
||||
equal(typeof lodash.uniqueId(), 'number', '_.uniqueId should return a number value when not passing a prefix argument: ' + basename);
|
||||
|
||||
var wrapped = lodash(1);
|
||||
equal(wrapped.clone() instanceof lodash, false, '_(...) wrapped values are not chainable by default: ' + basename);
|
||||
equal(String(wrapped) === '1', false, '_#toString should not be implemented: ' + basename);
|
||||
|
||||
15
test/test.js
15
test/test.js
@@ -1878,6 +1878,21 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.uniqueId');
|
||||
|
||||
(function() {
|
||||
test('should return a string value when not passing a prefix argument', function() {
|
||||
equal(typeof _.uniqueId(), 'string');
|
||||
});
|
||||
|
||||
test('should coerce the prefix argument to a string', function() {
|
||||
var actual = [_.uniqueId(3), _.uniqueId(2), _.uniqueId(1)];
|
||||
equal(/3\d+,2\d+,1\d+/.test(actual), true);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.where');
|
||||
|
||||
(function() {
|
||||
|
||||
Reference in New Issue
Block a user