mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 19:30:44 +00:00
test: avoid filter allocation assertions
This commit is contained in:
@@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user