Spaces:
Sleeping
Sleeping
Download src/utils/__tests__/stringFormatting.test.ts from Chunte/lerobot-visualizer-test: direct link, hf CLI and curl.
- Browser
- Download file 2.29 kB
-
https://huggingface.co/spaces/Chunte/lerobot-visualizer-test/resolve/main/src/utils/__tests__/stringFormatting.test.ts
- Command line
-
hf download hf://spaces/Chunte/lerobot-visualizer-test/src/utils/__tests__/stringFormatting.test.ts
-
curl -L -o stringFormatting.test.ts https://huggingface.co/spaces/Chunte/lerobot-visualizer-test/resolve/main/src/utils/__tests__/stringFormatting.test.ts
2.29 kB
| 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 | |