import { SpectatorPipe, createPipeFactory } from '@ngneat/spectator';
import { GroupByPipe } from './group-by.pipe';

describe('GroupByPipe', () => {
  let spectator: SpectatorPipe<GroupByPipe>;
  const createPipe = createPipeFactory(GroupByPipe);

  it('should call groupBy with a Function', () => {
    const selectGroup = (item: any) => 2;
    spectator = createPipe(`{{ [1, 2] | groupBy:selectGroup }}`, {
      hostProps: {
        selectGroup: selectGroup,
      },
    });
    expect(spectator.element).toEqual(jasmine.any(Object));
  });

  it('should call groupBy without a Function', () => {
    spectator = createPipe(`{{ [] | groupBy }}`);
    expect(spectator.element).toHaveText('');
  });
});
