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

import {
  basename,
  languageForPath,
} from '../../src/components/agent-workspace/languages';

describe('workspace language helpers', () => {
  it('maps common code file extensions to Monaco languages', () => {
    expect(languageForPath('src/app.ts')).toBe('typescript');
    expect(languageForPath('src/app.tsx')).toBe('typescript');
    expect(languageForPath('src/app.js')).toBe('javascript');
    expect(languageForPath('package.json')).toBe('json');
    expect(languageForPath('README.md')).toBe('markdown');
    expect(languageForPath('.env.local')).toBe('plaintext');
  });

  it('lets Monaco fall back for unknown paths', () => {
    expect(languageForPath('Gemfile')).toBeUndefined();
    expect(languageForPath()).toBeUndefined();
  });

  it('returns a useful basename for file tabs', () => {
    expect(basename('src/components/button.tsx')).toBe('button.tsx');
    expect(basename('README.md')).toBe('README.md');
  });
});
