mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 17:37:50 +00:00
lodash: Cleanup compiled code and check for a toArray method on objects before others in _.toArray. [jddalton]
Former-commit-id: 9fdde9bbbecd0480e7d3d6674b43cea0810d2aed
This commit is contained in:
20
test/test.js
20
test/test.js
@@ -128,6 +128,26 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('lodash.toArray');
|
||||
|
||||
(function() {
|
||||
var args = arguments;
|
||||
|
||||
test('should call custom `toArray` method of an array', function() {
|
||||
var array = [1, 2, 3];
|
||||
array.toArray = function() { return [3, 2, 1] };
|
||||
deepEqual(_.toArray(array), [3, 2, 1]);
|
||||
});
|
||||
|
||||
test('should treat array-like-objects like arrays', function() {
|
||||
var object = { '0': 'a', '1': 'b', '2': 'c', 'length': 3 };
|
||||
deepEqual(_.toArray(object), ['a', 'b', 'c']);
|
||||
deepEqual(_.toArray(args), [1, 2, 3]);
|
||||
});
|
||||
}(1, 2, 3));
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// explicitly call `QUnit.start()` in a CLI environment
|
||||
if (!window.document) {
|
||||
QUnit.start();
|
||||
|
||||
Reference in New Issue
Block a user