dialekt 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +8 -10
  2. package/TESTING.md +29 -29
  3. package/dist/cli/main.d.mts +1 -1
  4. package/dist/cli/main.mjs +549 -362
  5. package/dist/formatters-De4Q-X1d.mjs +516 -435
  6. package/dist/index.d.mts +162 -25
  7. package/dist/index.mjs +119 -34
  8. package/package.json +3 -3
  9. package/pnpm-workspace.yaml +3 -3
  10. package/src/adapter/types.test.ts +57 -57
  11. package/src/adapter/types.ts +7 -4
  12. package/src/benchmark/metrics.test.ts +141 -69
  13. package/src/benchmark/metrics.ts +6 -6
  14. package/src/benchmark/report.test.ts +38 -38
  15. package/src/benchmark/report.ts +6 -6
  16. package/src/benchmark/runner.test.ts +70 -72
  17. package/src/benchmark/runner.ts +4 -4
  18. package/src/cli/commands/add.test.ts +90 -109
  19. package/src/cli/commands/add.ts +40 -28
  20. package/src/cli/commands/benchmark.test.ts +77 -64
  21. package/src/cli/commands/benchmark.ts +64 -41
  22. package/src/cli/commands/languages.test.ts +45 -42
  23. package/src/cli/commands/languages.ts +16 -12
  24. package/src/cli/commands/missing.test.ts +143 -92
  25. package/src/cli/commands/missing.ts +24 -17
  26. package/src/cli/commands/translate.test.ts +79 -79
  27. package/src/cli/commands/translate.ts +41 -31
  28. package/src/cli/commands/unused.test.ts +62 -51
  29. package/src/cli/commands/unused.ts +18 -14
  30. package/src/cli/commands/validate.test.ts +130 -72
  31. package/src/cli/commands/validate.ts +25 -20
  32. package/src/cli/config-resolution.test.ts +169 -49
  33. package/src/cli/config-resolution.ts +5 -7
  34. package/src/cli/format.test.ts +50 -50
  35. package/src/cli/format.ts +57 -60
  36. package/src/cli/formatters.test.ts +128 -106
  37. package/src/cli/formatters.ts +72 -95
  38. package/src/cli/main.ts +13 -13
  39. package/src/config/define-config.test.ts +44 -29
  40. package/src/config/define-config.ts +1 -1
  41. package/src/config/load-config.test.ts +21 -18
  42. package/src/config/load-config.ts +5 -5
  43. package/src/config/types.test.ts +50 -44
  44. package/src/config/types.ts +2 -2
  45. package/src/index.ts +22 -26
  46. package/src/keys/flatten.test.ts +52 -52
  47. package/src/keys/flatten.ts +7 -9
  48. package/src/sdk/file-io.test.ts +47 -59
  49. package/src/sdk/file-io.ts +2 -2
  50. package/src/sdk/node-layer.test.ts +18 -18
  51. package/src/sdk/node-layer.ts +2 -2
  52. package/src/sdk/php-array-reader.test.ts +49 -40
  53. package/src/sdk/php-array-reader.ts +5 -5
  54. package/src/translation/chunking.test.ts +52 -44
  55. package/src/translation/chunking.ts +1 -1
  56. package/src/translation/missing-keys.test.ts +86 -93
  57. package/src/translation/missing-keys.ts +4 -6
  58. package/src/translation/model-registry.test.ts +41 -32
  59. package/src/translation/model-registry.ts +9 -9
  60. package/src/translation/one-shot-strategy.test.ts +105 -86
  61. package/src/translation/one-shot-strategy.ts +10 -12
  62. package/src/translation/orchestrator.test.ts +90 -101
  63. package/src/translation/orchestrator.ts +26 -26
  64. package/src/translation/prompt.test.ts +76 -76
  65. package/src/translation/prompt.ts +2 -2
  66. package/src/translation/tool-loop-strategy.test.ts +134 -107
  67. package/src/translation/tool-loop-strategy.ts +14 -18
  68. package/src/translation/types.test.ts +22 -22
  69. package/src/translation/types.ts +3 -3
  70. package/tsdown.config.ts +3 -3
  71. package/vitest.config.ts +3 -3
package/src/cli/format.ts CHANGED
@@ -12,21 +12,21 @@
12
12
 
13
13
  // ─── Output format ──────────────────────────────────────────────────────────
14
14
 
15
- export type OutputFormat = 'pretty' | 'json';
15
+ export type OutputFormat = "pretty" | "json";
16
16
 
17
17
  /**
18
18
  * Environment variables that signal dialekt is running inside an AI agent.
19
19
  * When any is set (truthy), or stdout is not a TTY, JSON mode is the default.
20
20
  */
21
21
  export const AGENT_ENV_VARS = [
22
- 'CLAUDE_CODE',
23
- 'CLAUDECODE',
24
- 'CURSOR',
25
- 'CURSOR_TRACE_ID',
26
- 'DEVIN',
27
- 'GEMINI_CLI',
28
- 'AGENT_TASK_ID',
29
- 'AIDER_CHAT',
22
+ "CLAUDE_CODE",
23
+ "CLAUDECODE",
24
+ "CURSOR",
25
+ "CURSOR_TRACE_ID",
26
+ "DEVIN",
27
+ "GEMINI_CLI",
28
+ "AGENT_TASK_ID",
29
+ "AIDER_CHAT",
30
30
  ] as const;
31
31
 
32
32
  /**
@@ -38,23 +38,23 @@ export const AGENT_ENV_VARS = [
38
38
  */
39
39
  export function detectFormat(explicit?: OutputFormat | undefined): OutputFormat {
40
40
  if (explicit !== undefined) return explicit;
41
- if (!process.stdout.isTTY) return 'json';
42
- if (AGENT_ENV_VARS.some((k) => process.env[k])) return 'json';
43
- return 'pretty';
41
+ if (!process.stdout.isTTY) return "json";
42
+ if (AGENT_ENV_VARS.some((k) => process.env[k])) return "json";
43
+ return "pretty";
44
44
  }
45
45
 
46
46
  // ─── ANSI colours ────────────────────────────────────────────────────────────
47
47
 
48
48
  const C = {
49
- reset: '\x1b[0m',
50
- bold: '\x1b[1m',
51
- dim: '\x1b[2m',
52
- red: '\x1b[31m',
53
- green: '\x1b[32m',
54
- yellow: '\x1b[33m',
55
- blue: '\x1b[34m',
56
- cyan: '\x1b[36m',
57
- white: '\x1b[37m',
49
+ reset: "\x1b[0m",
50
+ bold: "\x1b[1m",
51
+ dim: "\x1b[2m",
52
+ red: "\x1b[31m",
53
+ green: "\x1b[32m",
54
+ yellow: "\x1b[33m",
55
+ blue: "\x1b[34m",
56
+ cyan: "\x1b[36m",
57
+ white: "\x1b[37m",
58
58
  } as const;
59
59
 
60
60
  function isTty(): boolean {
@@ -64,7 +64,7 @@ function isTty(): boolean {
64
64
  /** Wraps text in ANSI codes only when stdout is a TTY; otherwise returns it bare. */
65
65
  export function color(text: string, ...codes: string[]): string {
66
66
  if (!isTty()) return text;
67
- return `${codes.join('')}${text}${C.reset}`;
67
+ return `${codes.join("")}${text}${C.reset}`;
68
68
  }
69
69
 
70
70
  // ─── Box-drawing glyphs ──────────────────────────────────────────────────────
@@ -91,39 +91,39 @@ interface Glyphs {
91
91
  const PRETTY_GLYPHS: Glyphs = {
92
92
  hLine: String.fromCharCode(0x2500),
93
93
  vLine: String.fromCharCode(0x2502),
94
- cornerTL: String.fromCharCode(0x250C),
94
+ cornerTL: String.fromCharCode(0x250c),
95
95
  cornerTR: String.fromCharCode(0x2510),
96
96
  cornerBL: String.fromCharCode(0x2514),
97
97
  cornerBR: String.fromCharCode(0x2518),
98
- teeRight: String.fromCharCode(0x251C),
98
+ teeRight: String.fromCharCode(0x251c),
99
99
  teeLeft: String.fromCharCode(0x2524),
100
- teeDown: String.fromCharCode(0x252C),
100
+ teeDown: String.fromCharCode(0x252c),
101
101
  teeUp: String.fromCharCode(0x2534),
102
- cross: String.fromCharCode(0x253C),
102
+ cross: String.fromCharCode(0x253c),
103
103
  bullet: String.fromCharCode(0x2022),
104
104
  arrow: String.fromCharCode(0x2192),
105
105
  check: String.fromCharCode(0x2713),
106
106
  crossMark: String.fromCharCode(0x2717),
107
- warn: String.fromCharCode(0x26A0),
107
+ warn: String.fromCharCode(0x26a0),
108
108
  };
109
109
 
110
110
  const ASCII_GLYPHS: Glyphs = {
111
- hLine: '-',
112
- vLine: '|',
113
- cornerTL: '+',
114
- cornerTR: '+',
115
- cornerBL: '+',
116
- cornerBR: '+',
117
- teeRight: '+',
118
- teeLeft: '+',
119
- teeDown: '+',
120
- teeUp: '+',
121
- cross: '+',
122
- bullet: '*',
123
- arrow: '>',
124
- check: '+',
125
- crossMark: 'x',
126
- warn: '!',
111
+ hLine: "-",
112
+ vLine: "|",
113
+ cornerTL: "+",
114
+ cornerTR: "+",
115
+ cornerBL: "+",
116
+ cornerBR: "+",
117
+ teeRight: "+",
118
+ teeLeft: "+",
119
+ teeDown: "+",
120
+ teeUp: "+",
121
+ cross: "+",
122
+ bullet: "*",
123
+ arrow: ">",
124
+ check: "+",
125
+ crossMark: "x",
126
+ warn: "!",
127
127
  };
128
128
 
129
129
  export function glyphs(): Glyphs {
@@ -134,38 +134,35 @@ export function glyphs(): Glyphs {
134
134
 
135
135
  export function drawTable(
136
136
  headers: readonly string[],
137
- rows: readonly (readonly string[])[]
137
+ rows: readonly (readonly string[])[],
138
138
  ): string {
139
139
  const g = glyphs();
140
140
  const colWidths = headers.map((h, i) =>
141
- Math.max(h.length, ...rows.map((r) => (r[i] ?? '').length))
141
+ Math.max(h.length, ...rows.map((r) => (r[i] ?? "").length)),
142
142
  );
143
143
 
144
144
  const pad = (text: string, width: number) => text.padEnd(width);
145
145
 
146
- const hLine = g.cornerTL +
147
- colWidths.map((w) => g.hLine.repeat(w + 2)).join(g.teeDown) +
148
- g.cornerTR;
146
+ const hLine =
147
+ g.cornerTL + colWidths.map((w) => g.hLine.repeat(w + 2)).join(g.teeDown) + g.cornerTR;
149
148
 
150
- const headerRow = g.vLine +
149
+ const headerRow =
150
+ g.vLine +
151
151
  headers.map((h, i) => ` ${color(pad(h, colWidths[i]!), C.bold)} `).join(g.vLine) +
152
152
  g.vLine;
153
153
 
154
- const separator = g.teeRight +
155
- colWidths.map((w) => g.hLine.repeat(w + 2)).join(g.cross) +
156
- g.teeLeft;
154
+ const separator =
155
+ g.teeRight + colWidths.map((w) => g.hLine.repeat(w + 2)).join(g.cross) + g.teeLeft;
157
156
 
158
- const dataRows = rows.map((row) =>
159
- g.vLine +
160
- row.map((cell, i) => ` ${pad(cell, colWidths[i]!)} `).join(g.vLine) +
161
- g.vLine
157
+ const dataRows = rows.map(
158
+ (row) =>
159
+ g.vLine + row.map((cell, i) => ` ${pad(cell, colWidths[i]!)} `).join(g.vLine) + g.vLine,
162
160
  );
163
161
 
164
- const bottomLine = g.cornerBL +
165
- colWidths.map((w) => g.hLine.repeat(w + 2)).join(g.teeUp) +
166
- g.cornerBR;
162
+ const bottomLine =
163
+ g.cornerBL + colWidths.map((w) => g.hLine.repeat(w + 2)).join(g.teeUp) + g.cornerBR;
167
164
 
168
- return [hLine, headerRow, separator, ...dataRows, bottomLine].join('\n');
165
+ return [hLine, headerRow, separator, ...dataRows, bottomLine].join("\n");
169
166
  }
170
167
 
171
168
  // ─── Banner / header helpers ─────────────────────────────────────────────────
@@ -1,4 +1,4 @@
1
- import { describe, expect, it } from 'vitest';
1
+ import { describe, expect, it } from "vitest";
2
2
  import {
3
3
  formatMissingKeys,
4
4
  formatUnusedKeys,
@@ -8,179 +8,201 @@ import {
8
8
  formatAdd,
9
9
  formatBenchmark,
10
10
  formatError,
11
- } from './formatters.js';
11
+ } from "./formatters.js";
12
12
 
13
- describe('formatMissingKeys', () => {
14
- it('returns JSON array in json mode', () => {
15
- const entries = [{ adapter: 'a', locale: 'de', resource: 'r', key: 'k' }];
16
- const result = formatMissingKeys(entries, 'json');
13
+ describe("formatMissingKeys", () => {
14
+ it("returns JSON array in json mode", () => {
15
+ const entries = [{ adapter: "a", locale: "de", resource: "r", key: "k" }];
16
+ const result = formatMissingKeys(entries, "json");
17
17
  expect(JSON.parse(result)).toEqual(entries);
18
18
  });
19
19
 
20
- it('returns success message when empty in pretty mode', () => {
21
- const result = formatMissingKeys([], 'pretty');
22
- expect(result).toContain('complete');
20
+ it("returns success message when empty in pretty mode", () => {
21
+ const result = formatMissingKeys([], "pretty");
22
+ expect(result).toContain("complete");
23
23
  });
24
24
 
25
- it('groups by adapter, locale, resource in pretty mode', () => {
25
+ it("groups by adapter, locale, resource in pretty mode", () => {
26
26
  const entries = [
27
- { adapter: 'a1', locale: 'de', resource: 'auth', key: 'k1' },
28
- { adapter: 'a1', locale: 'de', resource: 'auth', key: 'k2' },
29
- { adapter: 'a1', locale: 'fr', resource: 'auth', key: 'k3' },
27
+ { adapter: "a1", locale: "de", resource: "auth", key: "k1" },
28
+ { adapter: "a1", locale: "de", resource: "auth", key: "k2" },
29
+ { adapter: "a1", locale: "fr", resource: "auth", key: "k3" },
30
30
  ];
31
- const result = formatMissingKeys(entries, 'pretty');
32
- expect(result).toContain('a1');
33
- expect(result).toContain('de');
34
- expect(result).toContain('fr');
35
- expect(result).toContain('auth');
36
- expect(result).toContain('k1');
37
- expect(result).toContain('k2');
38
- expect(result).toContain('k3');
31
+ const result = formatMissingKeys(entries, "pretty");
32
+ expect(result).toContain("a1");
33
+ expect(result).toContain("de");
34
+ expect(result).toContain("fr");
35
+ expect(result).toContain("auth");
36
+ expect(result).toContain("k1");
37
+ expect(result).toContain("k2");
38
+ expect(result).toContain("k3");
39
39
  });
40
40
  });
41
41
 
42
- describe('formatUnusedKeys', () => {
43
- it('returns JSON array in json mode', () => {
44
- const entries = [{ adapter: 'a', locale: 'en', resource: 'r', key: 'old' }];
45
- const result = formatUnusedKeys(entries, 'json');
42
+ describe("formatUnusedKeys", () => {
43
+ it("returns JSON array in json mode", () => {
44
+ const entries = [{ adapter: "a", locale: "en", resource: "r", key: "old" }];
45
+ const result = formatUnusedKeys(entries, "json");
46
46
  expect(JSON.parse(result)).toEqual(entries);
47
47
  });
48
48
 
49
- it('returns success message when empty in pretty mode', () => {
50
- const result = formatUnusedKeys([], 'pretty');
51
- expect(result).toContain('referenced');
49
+ it("returns success message when empty in pretty mode", () => {
50
+ const result = formatUnusedKeys([], "pretty");
51
+ expect(result).toContain("referenced");
52
52
  });
53
53
 
54
- it('groups entries in pretty mode', () => {
55
- const entries = [{ adapter: 'a', locale: 'en', resource: 'r', key: 'old' }];
56
- const result = formatUnusedKeys(entries, 'pretty');
57
- expect(result).toContain('a');
58
- expect(result).toContain('old');
54
+ it("groups entries in pretty mode", () => {
55
+ const entries = [{ adapter: "a", locale: "en", resource: "r", key: "old" }];
56
+ const result = formatUnusedKeys(entries, "pretty");
57
+ expect(result).toContain("a");
58
+ expect(result).toContain("old");
59
59
  });
60
60
  });
61
61
 
62
- describe('formatValidate', () => {
63
- it('returns JSON in json mode', () => {
64
- const result = formatValidate({ passing: true, entries: [] }, 'json');
62
+ describe("formatValidate", () => {
63
+ it("returns JSON in json mode", () => {
64
+ const result = formatValidate({ passing: true, entries: [] }, "json");
65
65
  const parsed = JSON.parse(result);
66
66
  expect(parsed.passing).toBe(true);
67
67
  });
68
68
 
69
- it('returns success message when passing in pretty mode', () => {
70
- const result = formatValidate({ passing: true, entries: [] }, 'pretty');
71
- expect(result).toContain('up to date');
69
+ it("returns success message when passing in pretty mode", () => {
70
+ const result = formatValidate({ passing: true, entries: [] }, "pretty");
71
+ expect(result).toContain("up to date");
72
72
  });
73
73
 
74
- it('returns table when failing in pretty mode', () => {
74
+ it("returns table when failing in pretty mode", () => {
75
75
  const result = formatValidate(
76
- { passing: false, entries: [{ adapter: 'a', locale: 'de', resource: 'r', count: 3 }] },
77
- 'pretty',
76
+ { passing: false, entries: [{ adapter: "a", locale: "de", resource: "r", count: 3 }] },
77
+ "pretty",
78
78
  );
79
- expect(result).toContain('Missing');
80
- expect(result).toContain('a');
81
- expect(result).toContain('de');
82
- expect(result).toContain('3');
79
+ expect(result).toContain("Missing");
80
+ expect(result).toContain("a");
81
+ expect(result).toContain("de");
82
+ expect(result).toContain("3");
83
83
  });
84
84
  });
85
85
 
86
- describe('formatLanguages', () => {
87
- it('returns JSON in json mode', () => {
88
- const result = formatLanguages([{ adapter: 'a', locales: ['en', 'de'] }], 'json');
89
- expect(JSON.parse(result)).toEqual([{ adapter: 'a', locales: ['en', 'de'] }]);
86
+ describe("formatLanguages", () => {
87
+ it("returns JSON in json mode", () => {
88
+ const result = formatLanguages([{ adapter: "a", locales: ["en", "de"] }], "json");
89
+ expect(JSON.parse(result)).toEqual([{ adapter: "a", locales: ["en", "de"] }]);
90
90
  });
91
91
 
92
- it('returns warning when empty in pretty mode', () => {
93
- const result = formatLanguages([], 'pretty');
94
- expect(result).toContain('No adapters');
92
+ it("returns warning when empty in pretty mode", () => {
93
+ const result = formatLanguages([], "pretty");
94
+ expect(result).toContain("No adapters");
95
95
  });
96
96
 
97
- it('lists adapters and locales in pretty mode', () => {
98
- const result = formatLanguages([{ adapter: 'laravel', locales: ['en', 'de'] }], 'pretty');
99
- expect(result).toContain('laravel');
100
- expect(result).toContain('en');
101
- expect(result).toContain('de');
97
+ it("lists adapters and locales in pretty mode", () => {
98
+ const result = formatLanguages([{ adapter: "laravel", locales: ["en", "de"] }], "pretty");
99
+ expect(result).toContain("laravel");
100
+ expect(result).toContain("en");
101
+ expect(result).toContain("de");
102
102
  });
103
103
  });
104
104
 
105
- describe('formatTranslate', () => {
106
- it('returns JSON in json mode', () => {
107
- const result = formatTranslate({ success: true, message: 'Done' }, 'json');
108
- expect(JSON.parse(result)).toEqual({ success: true, message: 'Done' });
105
+ describe("formatTranslate", () => {
106
+ it("returns JSON in json mode", () => {
107
+ const result = formatTranslate({ success: true, message: "Done" }, "json");
108
+ expect(JSON.parse(result)).toEqual({ success: true, message: "Done" });
109
109
  });
110
110
 
111
- it('returns success text in pretty mode', () => {
112
- const result = formatTranslate({ success: true, message: 'Done' }, 'pretty');
113
- expect(result).toContain('Done');
111
+ it("returns success text in pretty mode", () => {
112
+ const result = formatTranslate({ success: true, message: "Done" }, "pretty");
113
+ expect(result).toContain("Done");
114
114
  });
115
115
 
116
- it('includes stats in pretty mode', () => {
116
+ it("includes stats in pretty mode", () => {
117
117
  const result = formatTranslate(
118
- { success: true, message: 'Done', stats: { adaptersProcessed: 1, localesTranslated: 2, keysTranslated: 5 } },
119
- 'pretty',
118
+ {
119
+ success: true,
120
+ message: "Done",
121
+ stats: { adaptersProcessed: 1, localesTranslated: 2, keysTranslated: 5 },
122
+ },
123
+ "pretty",
120
124
  );
121
- expect(result).toContain('Adapters:');
122
- expect(result).toContain('1');
123
- expect(result).toContain('Locales:');
124
- expect(result).toContain('2');
125
+ expect(result).toContain("Adapters:");
126
+ expect(result).toContain("1");
127
+ expect(result).toContain("Locales:");
128
+ expect(result).toContain("2");
125
129
  });
126
130
 
127
- it('returns failure text in pretty mode', () => {
128
- const result = formatTranslate({ success: false, message: 'Failed' }, 'pretty');
129
- expect(result).toContain('Failed');
131
+ it("returns failure text in pretty mode", () => {
132
+ const result = formatTranslate({ success: false, message: "Failed" }, "pretty");
133
+ expect(result).toContain("Failed");
130
134
  });
131
135
  });
132
136
 
133
- describe('formatAdd', () => {
134
- it('returns JSON in json mode', () => {
135
- const result = formatAdd({ success: true, message: 'Done' }, 'json');
136
- expect(JSON.parse(result)).toEqual({ success: true, message: 'Done' });
137
+ describe("formatAdd", () => {
138
+ it("returns JSON in json mode", () => {
139
+ const result = formatAdd({ success: true, message: "Done" }, "json");
140
+ expect(JSON.parse(result)).toEqual({ success: true, message: "Done" });
137
141
  });
138
142
 
139
- it('returns success text in pretty mode', () => {
140
- const result = formatAdd({ success: true, message: 'Done' }, 'pretty');
141
- expect(result).toContain('Done');
143
+ it("returns success text in pretty mode", () => {
144
+ const result = formatAdd({ success: true, message: "Done" }, "pretty");
145
+ expect(result).toContain("Done");
142
146
  });
143
147
 
144
- it('lists added resources in pretty mode', () => {
148
+ it("lists added resources in pretty mode", () => {
145
149
  const result = formatAdd(
146
- { success: true, message: 'Done', addedResources: ['a/en/messages'] },
147
- 'pretty',
150
+ { success: true, message: "Done", addedResources: ["a/en/messages"] },
151
+ "pretty",
148
152
  );
149
- expect(result).toContain('a/en/messages');
153
+ expect(result).toContain("a/en/messages");
150
154
  });
151
155
  });
152
156
 
153
- describe('formatBenchmark', () => {
154
- it('returns JSON in json mode', () => {
155
- const entries = [{ strategyName: 's', totalChunks: 1, succeededChunks: 1, failedChunks: 0, totalDurationMs: 100, averageDurationMsPerChunk: 100, totalAttempts: 1 }];
156
- const result = formatBenchmark(entries, 'json');
157
+ describe("formatBenchmark", () => {
158
+ it("returns JSON in json mode", () => {
159
+ const entries = [
160
+ {
161
+ strategyName: "s",
162
+ totalChunks: 1,
163
+ succeededChunks: 1,
164
+ failedChunks: 0,
165
+ totalDurationMs: 100,
166
+ averageDurationMsPerChunk: 100,
167
+ totalAttempts: 1,
168
+ },
169
+ ];
170
+ const result = formatBenchmark(entries, "json");
157
171
  expect(JSON.parse(result)).toEqual(entries);
158
172
  });
159
173
 
160
- it('returns warning when empty in pretty mode', () => {
161
- const result = formatBenchmark([], 'pretty');
162
- expect(result).toContain('No benchmark');
174
+ it("returns warning when empty in pretty mode", () => {
175
+ const result = formatBenchmark([], "pretty");
176
+ expect(result).toContain("No benchmark");
163
177
  });
164
178
 
165
- it('renders table in pretty mode', () => {
179
+ it("renders table in pretty mode", () => {
166
180
  const entries = [
167
- { strategyName: 'one-shot', totalChunks: 2, succeededChunks: 2, failedChunks: 0, totalDurationMs: 200, averageDurationMsPerChunk: 100, totalAttempts: 2 },
181
+ {
182
+ strategyName: "one-shot",
183
+ totalChunks: 2,
184
+ succeededChunks: 2,
185
+ failedChunks: 0,
186
+ totalDurationMs: 200,
187
+ averageDurationMsPerChunk: 100,
188
+ totalAttempts: 2,
189
+ },
168
190
  ];
169
- const result = formatBenchmark(entries, 'pretty');
170
- expect(result).toContain('Benchmark');
171
- expect(result).toContain('one-shot');
172
- expect(result).toContain('2/2');
191
+ const result = formatBenchmark(entries, "pretty");
192
+ expect(result).toContain("Benchmark");
193
+ expect(result).toContain("one-shot");
194
+ expect(result).toContain("2/2");
173
195
  });
174
196
  });
175
197
 
176
- describe('formatError', () => {
177
- it('returns JSON in json mode', () => {
178
- const result = formatError('Something broke', 'json');
179
- expect(JSON.parse(result)).toEqual({ error: 'Something broke' });
198
+ describe("formatError", () => {
199
+ it("returns JSON in json mode", () => {
200
+ const result = formatError("Something broke", "json");
201
+ expect(JSON.parse(result)).toEqual({ error: "Something broke" });
180
202
  });
181
203
 
182
- it('returns failure text in pretty mode', () => {
183
- const result = formatError('Something broke', 'pretty');
184
- expect(result).toContain('Something broke');
204
+ it("returns failure text in pretty mode", () => {
205
+ const result = formatError("Something broke", "pretty");
206
+ expect(result).toContain("Something broke");
185
207
  });
186
208
  });