File size: 784 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import fillEmptyArray from '../../utils/fillEmptyArray';

describe('fillEmptyArray', () => {
  it('should return an array of undefined or empty array when value is an array', () => {
    expect(fillEmptyArray([1])).toEqual([undefined]);
    expect(fillEmptyArray([])).toEqual([]);
    expect(fillEmptyArray(['2', true])).toEqual([undefined, undefined]);
    expect(fillEmptyArray([{}, {}])).toEqual([undefined, undefined]);
    expect(fillEmptyArray([[], [3]])).toEqual([undefined, undefined]);
  });

  it('should return undefined when value is not an array', () => {
    expect(fillEmptyArray(1)).toEqual(undefined);
    expect(fillEmptyArray({})).toEqual(undefined);
    expect(fillEmptyArray('')).toEqual(undefined);
    expect(fillEmptyArray(true)).toEqual(undefined);
  });
});