import { describe, expect, it } from 'vitest';

import type { FeatureMeta } from '../types';
import { groupFeaturesByCategory } from './features';

function feature(name: string, groupName: string): FeatureMeta {
  return { name, group: groupName, type: 'numeric' };
}

describe('feature grouping utilities', () => {
  it('keeps feature order inside grouped categories', () => {
    const groups = groupFeaturesByCategory([
      feature('A', 'Crime'),
      feature('B', 'Crime'),
      feature('C', 'Properties'),
    ]);

    expect(groups).toEqual([
      { name: 'Crime', features: [feature('A', 'Crime'), feature('B', 'Crime')] },
      { name: 'Properties', features: [feature('C', 'Properties')] },
    ]);
  });
});
