Files
lodash/test/concat.spec.js
tison bd518dd906 test: partially fix broken tests (#5733)
* test: fix throttle.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix pickBy.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix isBuffer.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: partially fix attempt.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: partially fix dropRightWhile.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix defer.spec.js and rest.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix invoke.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix isArray.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: partially fix iteration-methods.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix xor-methods.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix property.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix ary.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix omit-methods.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix debounce-and-throttle.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix unzip-and-zip.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix toPairs-methods.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix exit-early.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: temporarily comment out takeWhile and dropWhile tests

Signed-off-by: tison <wander4096@gmail.com>

* test: partially fix union*.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix startsWith-and-endsWith.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix isNil.spec.js

Signed-off-by: tison <wander4096@gmail.com>

* test: fix some of syntax errors

Signed-off-by: tison <wander4096@gmail.com>

---------

Signed-off-by: tison <wander4096@gmail.com>
2023-09-21 07:40:27 -07:00

57 lines
1.7 KiB
JavaScript

import lodashStable from 'lodash';
import concat from '../src/concat';
describe('concat', () => {
it('should shallow clone `array`', () => {
const array = [1, 2, 3];
const actual = concat(array);
expect(actual).toEqual(array);
assert.notStrictEqual(actual, array);
});
it('should concat arrays and values', () => {
const array = [1];
const actual = concat(array, 2, [3], [[4]]);
expect(actual).toEqual([1, 2, 3, [4]]);
expect(array).toEqual([1]);
});
it('should cast non-array `array` values to arrays', () => {
const values = [, null, undefined, false, true, 1, NaN, 'a'];
let expected = lodashStable.map(values, (value, index) => (index ? [value] : []));
let actual = lodashStable.map(values, (value, index) => (index ? concat(value) : concat()));
expect(actual).toEqual(expected);
expected = lodashStable.map(values, (value) => [value, 2, [3]]);
actual = lodashStable.map(values, (value) => concat(value, [2], [[3]]));
expect(actual).toEqual(expected);
});
it('should treat sparse arrays as dense', () => {
const expected = [];
const actual = concat(Array(1), Array(1));
expected.push(undefined, undefined);
expect('0' in actual).toBeTruthy();
expect('1' in actual).toBeTruthy();
expect(actual).toEqual(expected);
});
it('should return a new wrapped array', () => {
const array = [1];
const wrapped = _(array).concat([2, 3]);
const actual = wrapped.value();
expect(array).toEqual([1]);
expect(actual).toEqual([1, 2, 3]);
});
});