mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:21:09 +02:00
docs+test: add audio format docs and shared-storage utils tests
- Document all supported audio formats in mukke CLAUDE.md with browser compatibility matrix and notes on formats needing transcoding - Add utils.test.ts for shared-storage: MIME type mappings, audio extension validation, and AUDIO_EXTENSIONS completeness checks (19 tests) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7a1ae1284c
commit
99091ecf9e
2 changed files with 95 additions and 0 deletions
73
packages/shared-storage/src/utils.test.ts
Normal file
73
packages/shared-storage/src/utils.test.ts
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
import { describe, it, expect } from 'vitest';
|
||||
import { getContentType, validateFileExtension, AUDIO_EXTENSIONS } from './utils';
|
||||
|
||||
describe('getContentType', () => {
|
||||
describe('audio formats', () => {
|
||||
const audioMappings: [string, string][] = [
|
||||
['.mp3', 'audio/mpeg'],
|
||||
['.wav', 'audio/wav'],
|
||||
['.ogg', 'audio/ogg'],
|
||||
['.m4a', 'audio/mp4'],
|
||||
['.aac', 'audio/aac'],
|
||||
['.flac', 'audio/flac'],
|
||||
['.aiff', 'audio/aiff'],
|
||||
['.aif', 'audio/aiff'],
|
||||
['.opus', 'audio/opus'],
|
||||
['.wma', 'audio/x-ms-wma'],
|
||||
['.alac', 'audio/mp4'],
|
||||
['.ape', 'audio/x-ape'],
|
||||
['.wv', 'audio/x-wavpack'],
|
||||
['.dsf', 'audio/dsf'],
|
||||
['.dff', 'audio/dff'],
|
||||
];
|
||||
|
||||
it.each(audioMappings)('%s → %s', (ext, expected) => {
|
||||
expect(getContentType(`song${ext}`)).toBe(expected);
|
||||
});
|
||||
|
||||
it('handles uppercase extensions', () => {
|
||||
expect(getContentType('song.FLAC')).toBe('audio/flac');
|
||||
expect(getContentType('song.M4A')).toBe('audio/mp4');
|
||||
});
|
||||
|
||||
it('returns application/octet-stream for unknown extensions', () => {
|
||||
expect(getContentType('song.xyz')).toBe('application/octet-stream');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('AUDIO_EXTENSIONS', () => {
|
||||
it('contains all common audio formats', () => {
|
||||
const expected = [
|
||||
'.mp3',
|
||||
'.wav',
|
||||
'.ogg',
|
||||
'.m4a',
|
||||
'.aac',
|
||||
'.flac',
|
||||
'.aiff',
|
||||
'.aif',
|
||||
'.opus',
|
||||
'.wma',
|
||||
'.webm',
|
||||
'.alac',
|
||||
'.ape',
|
||||
'.wv',
|
||||
'.dsf',
|
||||
'.dff',
|
||||
];
|
||||
for (const ext of expected) {
|
||||
expect(AUDIO_EXTENSIONS).toContain(ext);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateFileExtension', () => {
|
||||
it('validates audio files against AUDIO_EXTENSIONS', () => {
|
||||
expect(validateFileExtension('song.flac', AUDIO_EXTENSIONS)).toBe(true);
|
||||
expect(validateFileExtension('song.mp3', AUDIO_EXTENSIONS)).toBe(true);
|
||||
expect(validateFileExtension('song.opus', AUDIO_EXTENSIONS)).toBe(true);
|
||||
expect(validateFileExtension('song.exe', AUDIO_EXTENSIONS)).toBe(false);
|
||||
expect(validateFileExtension('song.pdf', AUDIO_EXTENSIONS)).toBe(false);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue