lang-detect.test.ts
typescript
sha256:3ff9c9863a9891bdcde71b4a43228f66d0493e38b7cc1d09fe9eb7de774046b2
feat: add repair-commit wire endpoint (API parity with repa…
Opus 4.8
minor
⚠ breaking
1 day ago
| 1 | import { describe, it, expect } from 'vitest'; |
| 2 | import { extToLang } from './lang-detect.ts'; |
| 3 | |
| 4 | describe('extToLang', () => { |
| 5 | // Standard extensions |
| 6 | it('detects python', () => expect(extToLang('main.py')).toBe('python')); |
| 7 | it('detects typescript', () => expect(extToLang('app.ts')).toBe('typescript')); |
| 8 | it('detects bash by .sh', () => expect(extToLang('install.sh')).toBe('bash')); |
| 9 | it('detects toml by extension', () => expect(extToLang('pyproject.toml')).toBe('toml')); |
| 10 | it('detects yaml', () => expect(extToLang('config.yml')).toBe('yaml')); |
| 11 | it('detects json', () => expect(extToLang('data.json')).toBe('json')); |
| 12 | it('detects markdown', () => expect(extToLang('README.md')).toBe('markdown')); |
| 13 | |
| 14 | // Dotfiles (no extension) |
| 15 | it('detects .museattributes as toml', () => expect(extToLang('.museattributes')).toBe('toml')); |
| 16 | it('detects .museignore as toml', () => expect(extToLang('.museignore')).toBe('toml')); |
| 17 | |
| 18 | // Dotfiles in nested paths |
| 19 | it('detects nested .museattributes as toml', () => expect(extToLang('subdir/.museattributes')).toBe('toml')); |
| 20 | it('detects .muse/code_config.toml as toml', () => expect(extToLang('.muse/code_config.toml')).toBe('toml')); |
| 21 | |
| 22 | // bats |
| 23 | it('detects .bats as bash', () => expect(extToLang('tests/test_plugin.bats')).toBe('bash')); |
| 24 | |
| 25 | // Zsh completion files — _<command> with no extension |
| 26 | it('detects _muse as bash', () => expect(extToLang('_muse')).toBe('bash')); |
| 27 | it('detects completions/_muse as bash', () => expect(extToLang('completions/_muse')).toBe('bash')); |
| 28 | it('detects _git as bash', () => expect(extToLang('_git')).toBe('bash')); |
| 29 | |
| 30 | // Fallback |
| 31 | it('falls back to plaintext for unknown extension', () => expect(extToLang('data.bin')).toBe('plaintext')); |
| 32 | it('falls back to plaintext for unknown dotfile', () => expect(extToLang('.somethingelse')).toBe('plaintext')); |
| 33 | }); |
File History
1 commit
sha256:3ff9c9863a9891bdcde71b4a43228f66d0493e38b7cc1d09fe9eb7de774046b2
feat: add repair-commit wire endpoint (API parity with repa…
Opus 4.8
minor
⚠
1 day ago