import { sortEntriesByLabel } from './configUtils';

describe('configUtils', () => {
  test('sortEntriesByLabel orders entries alphabetically', () => {
    const entries = [
      { label: 'Zeta Markt' },
      { label: 'alpha Shop' },
      { label: 'Beta Store' }
    ];
    const sorted = sortEntriesByLabel(entries);
    expect(sorted.map((item) => item.label)).toEqual(['alpha Shop', 'Beta Store', 'Zeta Markt']);
  });

  test('sortEntriesByLabel handles missing labels', () => {
    const entries = [{}, { label: 'B' }, { label: 'A' }];
    const sorted = sortEntriesByLabel(entries);
    expect(sorted[0].label).toBe('A');
    expect(sorted[1].label).toBe('B');
    expect(sorted[2].label).toBeUndefined();
  });
});
