gabriel / musehub public
lang-detect.test.ts typescript
33 lines 1.8 KB
Raw
sha256:c73281cffffbc70487969720af074e54b34326d59ec6aff0827fa16512a4e512 docs(mwp-2): mark all acceptance criteria met; add closing … Sonnet 4.6 82 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:c73281cffffbc70487969720af074e54b34326d59ec6aff0827fa16512a4e512 docs(mwp-2): mark all acceptance criteria met; add closing … Sonnet 4.6 82 days ago
sha256:4dd2a937f66f8e36d9aa59bd1bf3cb880ca1d503fef67300a0cba3b482784081 test(mwp2): Phase 0 RED — reproduction tests for _walk_comm… Sonnet 4.6 82 days ago