test: avoid filter allocation assertions · openclaw/openclaw@9bc8237
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -13,11 +13,11 @@ import {
|
13 | 13 | } from "./fs-bridge.test-helpers.js"; |
14 | 14 | |
15 | 15 | function expectNoScriptsContaining(scripts: string[], needle: string) { |
16 | | -expect(scripts.filter((script) => script.includes(needle))).toEqual([]); |
| 16 | +expect(scripts.some((script) => script.includes(needle))).toBe(false); |
17 | 17 | } |
18 | 18 | |
19 | 19 | function expectSomeScriptContaining(scripts: string[], needle: string) { |
20 | | -expect(scripts.filter((script) => script.includes(needle)).length).toBeGreaterThan(0); |
| 20 | +expect(scripts.some((script) => script.includes(needle))).toBe(true); |
21 | 21 | } |
22 | 22 | |
23 | 23 | describe("sandbox fs bridge shell compatibility", () => { |
@@ -49,8 +49,8 @@ describe("sandbox fs bridge shell compatibility", () => {
|
49 | 49 | const scripts = getScriptsFromCalls(); |
50 | 50 | const executables = mockedExecDockerRaw.mock.calls.map(([args]) => args[3] ?? ""); |
51 | 51 | |
52 | | -expect(executables.filter((shell) => shell !== "sh")).toEqual([]); |
53 | | -expect(scripts.filter((script) => !/set -eu[;\n]/.test(script))).toEqual([]); |
| 52 | +expect(executables.every((shell) => shell === "sh")).toBe(true); |
| 53 | +expect(scripts.every((script) => /set -eu[;\n]/.test(script))).toBe(true); |
54 | 54 | expectNoScriptsContaining(scripts, "pipefail"); |
55 | 55 | }); |
56 | 56 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -373,7 +373,7 @@ describe("createStatusReactionController", () => {
|
373 | 373 | // Should only have set calls, no remove |
374 | 374 | const removeCalls = calls.filter((c) => c.method === "remove"); |
375 | 375 | expect(removeCalls).toHaveLength(0); |
376 | | -expect(calls.filter((c) => c.method === "set").length).toBeGreaterThan(0); |
| 376 | +expect(calls.some((c) => c.method === "set")).toBe(true); |
377 | 377 | }); |
378 | 378 | |
379 | 379 | it("should clear all known emojis when adapter supports removeReaction", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -759,7 +759,7 @@ describe.skipIf(isWindows)("restart-stale-pids", () => {
|
759 | 759 | cleanStaleGatewayProcessesSync(); |
760 | 760 | |
761 | 761 | expect(events).toContain("port-free"); |
762 | | -expect(events.filter((e) => e.startsWith("busy-poll")).length).toBeGreaterThan(0); |
| 762 | +expect(events.some((e) => e.startsWith("busy-poll"))).toBe(true); |
763 | 763 | }); |
764 | 764 | |
765 | 765 | it("bails immediately when lsof is permanently unavailable (ENOENT) — Greptile edge case", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -385,7 +385,7 @@ describe("secrets apply", () => {
|
385 | 385 | expect(dryRunAllowed.mode).toBe("dry-run"); |
386 | 386 | expect(dryRunAllowed.skippedExecRefs).toBe(0); |
387 | 387 | const callLog = await fs.readFile(execLogPath, "utf8"); |
388 | | -expect(callLog.split("\n").filter((line) => line.trim().length > 0).length).toBeGreaterThan(0); |
| 388 | +expect(callLog.split("\n").some((line) => line.trim().length > 0)).toBe(true); |
389 | 389 | }); |
390 | 390 | |
391 | 391 | it("ignores unrelated auth-profile store refs during allowExec dry-run preflight", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -8,11 +8,11 @@ import {
|
8 | 8 | } from "../../scripts/lib/bundled-plugin-build-entries.mjs"; |
9 | 9 | |
10 | 10 | function expectNoPrefixMatches(values: string[], prefix: string) { |
11 | | -expect(values.filter((value) => value.startsWith(prefix))).toEqual([]); |
| 11 | +expect(values.some((value) => value.startsWith(prefix))).toBe(false); |
12 | 12 | } |
13 | 13 | |
14 | 14 | function expectSomePrefixMatch(values: string[], prefix: string) { |
15 | | -expect(values.filter((value) => value.startsWith(prefix)).length).toBeGreaterThan(0); |
| 15 | +expect(values.some((value) => value.startsWith(prefix))).toBe(true); |
16 | 16 | } |
17 | 17 | |
18 | 18 | describe("bundled plugin build entries", () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。