mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Add _.toArray tests for ES6 iterables.
This commit is contained in:
21
test/test.js
21
test/test.js
@@ -15376,18 +15376,27 @@
|
|||||||
QUnit.module('lodash.toArray');
|
QUnit.module('lodash.toArray');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
test('should return the values of objects', 1, function() {
|
test('should convert objects to arrays', 1, function() {
|
||||||
var array = [1, 2],
|
deepEqual(_.toArray({ 'a': 1, 'b': 2 }), [1, 2]);
|
||||||
object = { 'a': 1, 'b': 2 };
|
|
||||||
|
|
||||||
deepEqual(_.toArray(object), array);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should work with a string for `collection`', 2, function() {
|
test('should convert strings to arrays', 2, function() {
|
||||||
deepEqual(_.toArray('ab'), ['a', 'b']);
|
deepEqual(_.toArray('ab'), ['a', 'b']);
|
||||||
deepEqual(_.toArray(Object('ab')), ['a', 'b']);
|
deepEqual(_.toArray(Object('ab')), ['a', 'b']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should convert iterables to arrays', 1, function() {
|
||||||
|
if (!isNpm && Symbol && Symbol.iterator) {
|
||||||
|
var object = { '0': 'a', 'length': 1 };
|
||||||
|
object[Symbol.iterator] = arrayProto[Symbol.iterator];
|
||||||
|
|
||||||
|
deepEqual(_.toArray(object), ['a']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('should work in a lazy chain sequence', 2, function() {
|
test('should work in a lazy chain sequence', 2, function() {
|
||||||
if (!isNpm) {
|
if (!isNpm) {
|
||||||
var array = _.range(LARGE_ARRAY_SIZE + 1),
|
var array = _.range(LARGE_ARRAY_SIZE + 1),
|
||||||
|
|||||||
Reference in New Issue
Block a user