@function test-group-by-1($num, $args...) {
  @return floor($num);
}
@include test-module('_group-by') {
  $list: 4.2 6.1 6.4;

  @include test('should use _identity when iteratee is nullish') {
    $list: 4 6 6;
    $expected: (4: (4,), 6: (6, 6));

    @include assert-maps-equal(_group-by($list), $expected);
    @include assert-maps-equal(_group-by($list, null), $expected);

  }

  @include test('should work with a _pluck style iteratee') {
    $map: ('number': 'one', 'len': 3) ('number': 'two', 'len': 3) ('number': 'three', 'len': 5);
    $expected: (3: (("number": "one", "len": 3), ("number": "two", "len": 3)), 5: ((("number": "three", "len": 5),)));

    @include assert-maps-equal(_group-by($map, 'len'), $expected);
  }

  @include test('should work with a number for iteratee') {
    $list: (1 'a', 2 'a', 2 'b');

    @include assert-maps-equal(_group-by($list, 1), (1: (1 'a',), 2: (2 'a', 2 'b')));
    @include assert-maps-equal(_group-by($list, 2), ('a': (1 'a', 2 'a'), 'b': (2 'b',)));
  }

  @include test('should work with a map for collection') {
    $actual: _group-by(('a': 4.2, 'b': 6.1, 'c': 6.4), test-group-by-1);
    $expected: (4: (4.2,), 6: (6.1, 6.4));

    @include assert-maps-equal($actual, $expected);
  }
}

@include test-module('_group-by-keys') {
    $list: (('a': 1, 'b': 2), ('a': 3, 'b': 4, 'c': 5));

    @include test('should group a list of maps by keys') {
        $actual: _group-by-keys($list);
        $expected: ('a': (1, 3), 'b': (2, 4), 'c': (5,));

        @include assert-equal($actual, $expected);
    }

    @include test('should treat lists as maps and use indexes as keys') {
        $list: (1 2, 3 4, 5 6 7);

        $actual: _group-by-keys($list);
        $expected: (1: (1, 3, 5), 2: (2, 4, 6), 3: (7,));

        @include assert-equal($actual, $expected);
    }

    @include test('should work with falsey values') {
        @each $value in $test-falsey {
            $list: (('a': 1), $value, ('a': 2));
            $expected: ('a': (1, 2));

            @include assert-equal(_group-by-keys($list), $expected);
        }
    }
}