import { checkboxOptionKeysHelper } from './checkbox-option-keys.helper';
import { CheckboxFilterInputOption } from '../core';

describe('checkboxOptionKeysHelper', () => {
  it('should extract option keys from path excluding group and groupKey', () => {
    const option: CheckboxFilterInputOption = {
      path: ['group', 'key', 'level1', 'level2', 'level3'],
      key: 'level3',
      label: 'Level 3 Option',
      value: 'level3',
    };

    const result = checkboxOptionKeysHelper(option);
    
    expect(result).toEqual(['level1', 'level2', 'level3']);
  });

  it('should return single key when path has only one option level', () => {
    const option: CheckboxFilterInputOption = {
      path: ['group', 'key', 'singleOption'],
      key: 'singleOption',
      label: 'Single Option',
      value: 'singleOption',
    };

    const result = checkboxOptionKeysHelper(option);
    
    expect(result).toEqual(['singleOption']);
  });

  it('should handle deep nested option paths', () => {
    const option: CheckboxFilterInputOption = {
      path: ['category', 'products', 'electronics', 'phones', 'smartphones', 'android'],
      key: 'android',
      label: 'Android Phones',
      value: 'android',
    };

    const result = checkboxOptionKeysHelper(option);
    
    expect(result).toEqual(['electronics', 'phones', 'smartphones', 'android']);
  });

  it('should return empty array when path only contains group and groupKey', () => {
    const option: CheckboxFilterInputOption = {
      path: ['group', 'key'],
      key: 'key',
      label: 'Root Option',
      value: 'key',
    };

    const result = checkboxOptionKeysHelper(option);
    
    expect(result).toEqual([]);
  });
});