test: avoid filter allocation assertions

This commit is contained in:
Peter Steinberger
2026-05-08 21:26:50 +01:00
parent c7a0a7af7b
commit 9bc8237f7b
5 changed files with 9 additions and 9 deletions

View File

@@ -13,11 +13,11 @@ import {
} from "./fs-bridge.test-helpers.js";
function expectNoScriptsContaining(scripts: string[], needle: string) {
expect(scripts.filter((script) => script.includes(needle))).toEqual([]);
expect(scripts.some((script) => script.includes(needle))).toBe(false);
}
function expectSomeScriptContaining(scripts: string[], needle: string) {
expect(scripts.filter((script) => script.includes(needle)).length).toBeGreaterThan(0);
expect(scripts.some((script) => script.includes(needle))).toBe(true);
}
describe("sandbox fs bridge shell compatibility", () => {
@@ -49,8 +49,8 @@ describe("sandbox fs bridge shell compatibility", () => {
const scripts = getScriptsFromCalls();
const executables = mockedExecDockerRaw.mock.calls.map(([args]) => args[3] ?? "");
expect(executables.filter((shell) => shell !== "sh")).toEqual([]);
expect(scripts.filter((script) => !/set -eu[;\n]/.test(script))).toEqual([]);
expect(executables.every((shell) => shell === "sh")).toBe(true);
expect(scripts.every((script) => /set -eu[;\n]/.test(script))).toBe(true);
expectNoScriptsContaining(scripts, "pipefail");
});
});

View File

@@ -373,7 +373,7 @@ describe("createStatusReactionController", () => {
// Should only have set calls, no remove
const removeCalls = calls.filter((c) => c.method === "remove");
expect(removeCalls).toHaveLength(0);
expect(calls.filter((c) => c.method === "set").length).toBeGreaterThan(0);
expect(calls.some((c) => c.method === "set")).toBe(true);
});
it("should clear all known emojis when adapter supports removeReaction", async () => {

View File

@@ -759,7 +759,7 @@ describe.skipIf(isWindows)("restart-stale-pids", () => {
cleanStaleGatewayProcessesSync();
expect(events).toContain("port-free");
expect(events.filter((e) => e.startsWith("busy-poll")).length).toBeGreaterThan(0);
expect(events.some((e) => e.startsWith("busy-poll"))).toBe(true);
});
it("bails immediately when lsof is permanently unavailable (ENOENT) — Greptile edge case", () => {

View File

@@ -385,7 +385,7 @@ describe("secrets apply", () => {
expect(dryRunAllowed.mode).toBe("dry-run");
expect(dryRunAllowed.skippedExecRefs).toBe(0);
const callLog = await fs.readFile(execLogPath, "utf8");
expect(callLog.split("\n").filter((line) => line.trim().length > 0).length).toBeGreaterThan(0);
expect(callLog.split("\n").some((line) => line.trim().length > 0)).toBe(true);
});
it("ignores unrelated auth-profile store refs during allowExec dry-run preflight", async () => {

View File

@@ -8,11 +8,11 @@ import {
} from "../../scripts/lib/bundled-plugin-build-entries.mjs";
function expectNoPrefixMatches(values: string[], prefix: string) {
expect(values.filter((value) => value.startsWith(prefix))).toEqual([]);
expect(values.some((value) => value.startsWith(prefix))).toBe(false);
}
function expectSomePrefixMatch(values: string[], prefix: string) {
expect(values.filter((value) => value.startsWith(prefix)).length).toBeGreaterThan(0);
expect(values.some((value) => value.startsWith(prefix))).toBe(true);
}
describe("bundled plugin build entries", () => {