File size: 1,547 Bytes
94004a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { describe, it, expect, vi } from 'vitest';

// Stub Tauri globals before import so isTauri is false
delete globalThis.window?.__TAURI_INTERNALS__;
delete globalThis.window?.__TAURI__;

describe('media utils', () => {
  it('isTauri is false in jsdom', async () => {
    const { isTauri } = await import('../utils/media');
    expect(isTauri).toBe(false);
  });

  it('playPing does not throw in jsdom', async () => {
    const { playPing } = await import('../utils/media');
    // Should be a no-op (no AudioContext in jsdom), not an error
    expect(() => playPing()).not.toThrow();
  });
});

describe('format utils', () => {
  it('formatTime returns m:ss.d', async () => {
    const { formatTime } = await import('../utils/format');
    expect(formatTime(0)).toBe('0:00.0');
    expect(formatTime(61)).toBe('1:01.0');
    expect(formatTime(3661)).toBe('61:01.0');
  });
});

describe('constants', () => {
  it('POPULAR_LANGS is non-empty', async () => {
    const { POPULAR_LANGS } = await import('../utils/constants');
    expect(POPULAR_LANGS.length).toBeGreaterThan(0);
  });

  it('CLONE_MAX_SECONDS is a positive number', async () => {
    const { CLONE_MAX_SECONDS } = await import('../utils/constants');
    expect(CLONE_MAX_SECONDS).toBeGreaterThan(0);
  });

  it('PRESETS array has entries with attrs', async () => {
    const { PRESETS } = await import('../utils/constants');
    expect(PRESETS.length).toBeGreaterThan(0);
    expect(PRESETS[0]).toHaveProperty('attrs');
    expect(PRESETS[0]).toHaveProperty('id');
  });
});