import { calculatePercentages } from './calculatePercentages';

describe('calculatePercentages', () => {
  test('should calculate percentages for array of numbers', () => {
    const data = [6, 12, 18];
    const result = calculatePercentages(data);
    expect(result).toHaveLength(3);
    expect(Number(result[0])).toBe(16.67);
    expect(Number(result[1])).toBe(33.33);
    expect(Number(result[2])).toBe(50);
  });

  test('should handle single item', () => {
    const data = [100];
    const result = calculatePercentages(data);
    expect(result).toHaveLength(1);
    expect(Number(result[0])).toBe(100);
  });

  test('should handle array of numbers', () => {
    const data = [10, 20, 30];
    const result = calculatePercentages(data);
    expect(Array.isArray(result)).toBe(true);
    expect(result.length).toBe(3);
  });

  test('should return percentages as strings with fixed decimals', () => {
    const data = [1, 2, 3];
    const result = calculatePercentages(data);
    expect(typeof result[0]).toBe('string');
    result.forEach(percentage => {
      expect(percentage).toMatch(/\d+\.\d{2}/);
    });
  });
});
