File size: 2,289 Bytes
782dc23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { describe, expect, test } from "bun:test";
import {
  padNumber,
  formatEpisodeChunk,
  formatEpisodeIndex,
  formatFileIndex,
  formatChunkIndex,
} from "@/utils/stringFormatting";

// These utilities are the foundation of v3.0 path construction.
// v2.x uses formatStringWithVars + manual padStart instead.

describe("padNumber", () => {
  test("pads single digit to 3", () => {
    expect(padNumber(1, 3)).toBe("001");
  });
  test("pads zero to 6", () => {
    expect(padNumber(0, 6)).toBe("000000");
  });
  test("does not truncate numbers longer than length", () => {
    expect(padNumber(1234, 3)).toBe("1234");
  });
  test("pads to exact length when already equal", () => {
    expect(padNumber(42, 2)).toBe("42");
  });
});

describe("formatEpisodeChunk β€” 3-digit padding (v2.x chunk_index, v3 chunk_index)", () => {
  test("chunk 0 β†’ '000'", () => {
    expect(formatEpisodeChunk(0)).toBe("000");
  });
  test("chunk 1 β†’ '001'", () => {
    expect(formatEpisodeChunk(1)).toBe("001");
  });
  test("chunk 42 β†’ '042'", () => {
    expect(formatEpisodeChunk(42)).toBe("042");
  });
  test("chunk 999 β†’ '999'", () => {
    expect(formatEpisodeChunk(999)).toBe("999");
  });
});

describe("formatEpisodeIndex β€” 6-digit padding (v2.x episode_index)", () => {
  test("index 0 β†’ '000000'", () => {
    expect(formatEpisodeIndex(0)).toBe("000000");
  });
  test("index 42 β†’ '000042'", () => {
    expect(formatEpisodeIndex(42)).toBe("000042");
  });
  test("index 999999 β†’ '999999'", () => {
    expect(formatEpisodeIndex(999999)).toBe("999999");
  });
});

describe("formatFileIndex β€” 3-digit padding (v3.0 file_index)", () => {
  test("file 0 β†’ '000'", () => {
    expect(formatFileIndex(0)).toBe("000");
  });
  test("file 5 β†’ '005'", () => {
    expect(formatFileIndex(5)).toBe("005");
  });
  test("file 100 β†’ '100'", () => {
    expect(formatFileIndex(100)).toBe("100");
  });
});

describe("formatChunkIndex β€” 3-digit padding (v3.0 chunk_index)", () => {
  test("chunk 0 β†’ '000'", () => {
    expect(formatChunkIndex(0)).toBe("000");
  });
  test("chunk 12 β†’ '012'", () => {
    expect(formatChunkIndex(12)).toBe("012");
  });
});

// v3.0 specific path builders