gabriel / musehub public
lang-detect.test.ts typescript
33 lines 1.8 KB
Raw
sha256:f65847c6a4ae29872f3ccbc2420f91a8948949b84a06320bdaf2ac281c89ff8a docs(F7b): governance sync — BUILT awaiting Gabriel; carry … Human patch 26 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:f65847c6a4ae29872f3ccbc2420f91a8948949b84a06320bdaf2ac281c89ff8a docs(F7b): governance sync — BUILT awaiting Gabriel; carry … Human patch 26 days ago
sha256:417c976b0b9320bb758749eb014d9087354fa3186e2abd2fc949e74a670237e7 merge(F7b B1): carry overseer provenance onto dev; resolve … Human minor 26 days ago