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

import { getSubtableColumnLabel, isDmsBusinessCategory } from './subtableLabels';

describe('dms subtable labels', () => {
  const categories = [
    { id: 'dms-id', enCode: 'DMS', fullName: '文档管理' },
    { id: 'lims-id', enCode: 'LIMS', fullName: '实验室' },
  ];

  it('recognizes DMS by dictionary category rather than a fixed id', () => {
    expect(isDmsBusinessCategory('dms-id', categories)).toBe(true);
    expect(isDmsBusinessCategory('lims-id', categories)).toBe(false);
    expect(isDmsBusinessCategory('unknown', categories)).toBe(false);
  });

  it('uses bilingual defaults while retaining custom labels', () => {
    expect(getSubtableColumnLabel('index', undefined, true)).toBe('序号\nNo.');
    expect(getSubtableColumnLabel('action', '操作', true)).toBe('操作\nAction');
    expect(getSubtableColumnLabel('action', '审批\nApprove', true)).toBe('审批\nApprove');
    expect(getSubtableColumnLabel('index', undefined, false)).toBe('序号');
  });
});
