mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Add _.flatten test to ensure consistent behavior with sparse arrays.
Former-commit-id: 5505f4d0542596e4c6469aa038fa1bfecaa79800
This commit is contained in:
21
test/test.js
21
test/test.js
@@ -174,6 +174,27 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.flatten');
|
||||
|
||||
(function() {
|
||||
test('should treat sparse arrays as dense', function() {
|
||||
var array = [[1, 2, 3], Array(3)],
|
||||
expected = [1, 2, 3],
|
||||
actual1 = _.flatten(array),
|
||||
actual2 = _.flatten(array, true);
|
||||
|
||||
expected.push(undefined, undefined, undefined);
|
||||
|
||||
deepEqual(actual1, expected);
|
||||
ok('4' in actual1);
|
||||
|
||||
deepEqual(actual2, expected);
|
||||
ok('4' in actual2);
|
||||
});
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.forEach');
|
||||
|
||||
(function() {
|
||||
|
||||
Reference in New Issue
Block a user