mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 00:27:50 +00:00
wip: code formatting nits continued
This commit is contained in:
35
test/toArray.spec.js
Normal file
35
test/toArray.spec.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import lodashStable from 'lodash';
|
||||
import { arrayProto, LARGE_ARRAY_SIZE } from './utils';
|
||||
import toArray from '../src/toArray';
|
||||
|
||||
describe('toArray', () => {
|
||||
it('should convert objects to arrays', () => {
|
||||
expect(toArray({ a: 1, b: 2 })).toEqual([1, 2]);
|
||||
});
|
||||
|
||||
it('should convert iterables to arrays', () => {
|
||||
if (Symbol && Symbol.iterator) {
|
||||
const object = { 0: 'a', length: 1 };
|
||||
object[Symbol.iterator] = arrayProto[Symbol.iterator];
|
||||
expect(toArray(object)).toEqual(['a']);
|
||||
}
|
||||
});
|
||||
|
||||
it('should convert maps to arrays', () => {
|
||||
if (Map) {
|
||||
const map = new Map();
|
||||
map.set('a', 1);
|
||||
map.set('b', 2);
|
||||
expect(toArray(map)).toEqual([
|
||||
['a', 1],
|
||||
['b', 2],
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
it('should convert strings to arrays', () => {
|
||||
expect(toArray('')).toEqual([]);
|
||||
expect(toArray('ab')).toEqual(['a', 'b']);
|
||||
expect(toArray(Object('ab'))).toEqual(['a', 'b']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user