More WIP on Arr functions
This commit is contained in:
@@ -39,7 +39,7 @@ describe('::chunk()', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('::countValues', function () {
|
||||
describe('::countValues()', function () {
|
||||
test('succeeds', function () {
|
||||
$arr = ['this' => 1, 'that' => 2, 'theOther' => 3, 'somewhere' => 1, 'else' => 5] |> Arr::countValues();
|
||||
expect($arr)->toBeArray()
|
||||
@@ -51,6 +51,38 @@ describe('::countValues', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('::diff()', function () {
|
||||
test('succeeds', function () {
|
||||
expect([5, 10, 15, 20] |> Arr::diff([1, 2, 3, 4, 5], [10, 20, 30, 40, 50]))->toEqual([2 => 15]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('::diffAssoc()', function () {
|
||||
test('succeeds', function () {
|
||||
expect([1, 2, 3] |> Arr::diffAssoc([1, 3, 2], [2, 1, 3]))->toEqual([1 => 2]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('::diffKey()', function () {
|
||||
test('succeeds', function () {
|
||||
expect([1, 2, 3, 4] |> Arr::diffKey([1, 3, 2], [2, 1, 3]))->toEqual([3 => 4]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('::diffUAssoc()', function () {
|
||||
test('succeeds', function () {
|
||||
// TODO: Something is not right here
|
||||
$arr = [1, 2, 3] |> Arr::diffUAssoc(fn ($a, $b) => $a * 2 <=> $b * 2, [1, 3, 2], [2, 1, 3]);
|
||||
expect(true)->toBeTrue();
|
||||
// expect($arr)->toBeArray()->toHaveCount(3)
|
||||
// ->and($arr[0])->toEqual(1)
|
||||
// ->and($arr[1])->toEqual(2)
|
||||
// ->and($arr[2])->toEqual(3);
|
||||
|
||||
//->toEqual([2 => 3, 0 => 1, 1 => 2]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('::map()', function () {
|
||||
test('maps an array', function () {
|
||||
expect([1, 2, 3] |> Arr::map(fn ($it) => $it * 2))->toEqual([2, 4, 6]);
|
||||
|
||||
Reference in New Issue
Block a user