gabriel / musehub public
lang-detect.test.ts typescript
33 lines 1.8 KB
Raw
sha256:e519738f2102d625d47828a17d113283cd744577b43551013cb668fd04f1c3fe chore(mwp8/phase5): tick all RG checkboxes; close-out doc (… Sonnet 4.6 18 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:e519738f2102d625d47828a17d113283cd744577b43551013cb668fd04f1c3fe chore(mwp8/phase5): tick all RG checkboxes; close-out doc (… Sonnet 4.6 18 days ago
sha256:0e5174da777684df43b2db71f282079030ef28bacffb93e19c29ee712b2a8bc4 test(mwp8/phase0): audit — repair+force-push leave stale ca… Sonnet 4.6 20 days ago