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

import { computeTableMinWidth } from '@/lib/tableLayout';

describe('computeTableMinWidth', () => {
  it('adds fixed widths and visible column widths', () => {
    expect(computeTableMinWidth({
      columnKeys: ['batch_id', 'source_file', 'created_at'],
      widths: {
        batch_id: 140,
        source_file: 160,
        created_at: 140,
      },
      fixedWidths: [40, 56, 100],
    })).toBe(636);
  });

  it('falls back for missing widths and ignores configured keys', () => {
    expect(computeTableMinWidth({
      columnKeys: ['_index', 'material_name', '_actions', 'created_by'],
      widths: {
        material_name: 180,
        created_by: 90,
        _actions: 100,
      },
      fixedWidths: [40, 56, 100],
      ignoredKeys: ['_index', '_actions'],
      fallbackWidth: 120,
    })).toBe(466);
  });
});