lang-detect.test.ts
typescript
sha256:969ddc5e88776e70af33c016b8777bb721356508ae5f304b3fb46c451494ece7
test(mwp3): Phase 4 — fix adjacent suite regressions, lock …
Sonnet 4.6
22 days 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
2 commits
sha256:969ddc5e88776e70af33c016b8777bb721356508ae5f304b3fb46c451494ece7
test(mwp3): Phase 4 — fix adjacent suite regressions, lock …
Sonnet 4.6
22 days ago
sha256:1749b9cc5cd2583c56d3261c4c00a342c27435f3946d4bc3e70f76aa2795458a
docs(mwp-3): TDD implementation plan for job-enqueue idempo…
Opus 4.8
22 days ago