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

import {
  isSupportedExcelFileName,
  sourceNameFromExcelFileName,
} from './datacenter-excel-upload';

describe('datacenter Excel upload', () => {
  it('accepts only xls and xlsx extensions', () => {
    expect(isSupportedExcelFileName('预算表.XLS')).toBe(true);
    expect(isSupportedExcelFileName('预算表.xlsx')).toBe(true);
    expect(isSupportedExcelFileName('预算表.xlsm')).toBe(false);
    expect(isSupportedExcelFileName('预算表.csv')).toBe(false);
  });

  it('derives the connection name from the final extension', () => {
    expect(sourceNameFromExcelFileName('ama 实验基线模型预算.xlsx')).toBe(
      'ama 实验基线模型预算',
    );
    expect(sourceNameFromExcelFileName('模型预算.v2.xls')).toBe('模型预算.v2');
  });
});
