refactor(commands): remove unused sandbox counters

This commit is contained in:
Vincent Koc
2026-06-18 22:47:29 +08:00
parent af3acf0626
commit ab25e340f9
2 changed files with 2 additions and 88 deletions

View File

@@ -1,13 +1,7 @@
// Sandbox formatter tests cover duration, mismatch, and sandbox diagnostic display helpers.
// Sandbox formatter tests cover duration and sandbox diagnostic display helpers.
import { describe, expect, it } from "vitest";
import { formatDurationCompact } from "../infra/format-time/format-duration.js";
import {
countMismatches,
countRunning,
formatImageMatch,
formatSimpleStatus,
formatStatus,
} from "./sandbox-formatters.js";
import { formatImageMatch, formatSimpleStatus, formatStatus } from "./sandbox-formatters.js";
/** Helper matching old formatAge behavior: spaced compound duration */
const formatAge = (ms: number) => formatDurationCompact(ms, { spaced: true }) ?? "0s";
@@ -63,76 +57,4 @@ describe("sandbox-formatters", () => {
expect(formatAge(ms)).toBe(expected);
});
});
describe("countRunning", () => {
it.each([
{
items: [
{ running: true, name: "a" },
{ running: false, name: "b" },
{ running: true, name: "c" },
{ running: false, name: "d" },
],
expected: 2,
},
{
items: [
{ running: false, name: "a" },
{ running: false, name: "b" },
],
expected: 0,
},
{
items: [
{ running: true, name: "a" },
{ running: true, name: "b" },
{ running: true, name: "c" },
],
expected: 3,
},
])("counts running items", ({ items, expected }) => {
expect(countRunning(items)).toBe(expected);
});
});
describe("countMismatches", () => {
it.each([
{
items: [
{ imageMatch: true, name: "a" },
{ imageMatch: false, name: "b" },
{ imageMatch: true, name: "c" },
{ imageMatch: false, name: "d" },
{ imageMatch: false, name: "e" },
],
expected: 3,
},
{
items: [
{ imageMatch: true, name: "a" },
{ imageMatch: true, name: "b" },
],
expected: 0,
},
{
items: [
{ imageMatch: false, name: "a" },
{ imageMatch: false, name: "b" },
{ imageMatch: false, name: "c" },
],
expected: 3,
},
])("counts image mismatches", ({ items, expected }) => {
expect(countMismatches(items)).toBe(expected);
});
});
describe("counter empty inputs", () => {
it.each([
{ fn: countRunning as (items: unknown[]) => number },
{ fn: countMismatches as (items: unknown[]) => number },
])("should return 0 for empty array", ({ fn }) => {
expect(fn([])).toBe(0);
});
});
});

View File

@@ -13,11 +13,3 @@ export function formatSimpleStatus(running: boolean): string {
export function formatImageMatch(matches: boolean): string {
return matches ? "✓" : "⚠️ mismatch";
}
export function countRunning(items: readonly { running: boolean }[]): number {
return items.filter((item) => item.running).length;
}
export function countMismatches(items: readonly { imageMatch: boolean }[]): number {
return items.filter((item) => !item.imageMatch).length;
}