import { describe, it, expect } from 'vitest'; import { extToLang } from './lang-detect.ts'; describe('extToLang', () => { // Standard extensions it('detects python', () => expect(extToLang('main.py')).toBe('python')); it('detects typescript', () => expect(extToLang('app.ts')).toBe('typescript')); it('detects bash by .sh', () => expect(extToLang('install.sh')).toBe('bash')); it('detects toml by extension', () => expect(extToLang('pyproject.toml')).toBe('toml')); it('detects yaml', () => expect(extToLang('config.yml')).toBe('yaml')); it('detects json', () => expect(extToLang('data.json')).toBe('json')); it('detects markdown', () => expect(extToLang('README.md')).toBe('markdown')); // Dotfiles (no extension) it('detects .museattributes as toml', () => expect(extToLang('.museattributes')).toBe('toml')); it('detects .museignore as toml', () => expect(extToLang('.museignore')).toBe('toml')); // Dotfiles in nested paths it('detects nested .museattributes as toml', () => expect(extToLang('subdir/.museattributes')).toBe('toml')); it('detects .muse/code_config.toml as toml', () => expect(extToLang('.muse/code_config.toml')).toBe('toml')); // bats it('detects .bats as bash', () => expect(extToLang('tests/test_plugin.bats')).toBe('bash')); // Zsh completion files — _ with no extension it('detects _muse as bash', () => expect(extToLang('_muse')).toBe('bash')); it('detects completions/_muse as bash', () => expect(extToLang('completions/_muse')).toBe('bash')); it('detects _git as bash', () => expect(extToLang('_git')).toBe('bash')); // Fallback it('falls back to plaintext for unknown extension', () => expect(extToLang('data.bin')).toBe('plaintext')); it('falls back to plaintext for unknown dotfile', () => expect(extToLang('.somethingelse')).toBe('plaintext')); });