test: tighten generic matcher assertions · openclaw/openclaw@190c07a
steipete
·
2026-05-08
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -58,7 +58,7 @@ describe("profile unicode attacks", () => {
|
58 | 58 | |
59 | 59 | // UI should escape or handle this |
60 | 60 | const sanitized = sanitizeProfileForDisplay(result.profile); |
61 | | -expect(sanitized.name).toEqual(expect.any(String)); |
| 61 | +expect(sanitized.name).toBe("\u202Eevil\u202C"); |
62 | 62 | }); |
63 | 63 | |
64 | 64 | it("handles bidi embedding in about", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -443,7 +443,8 @@ describe("verifyPlivoWebhook", () => {
|
443 | 443 | ); |
444 | 444 | |
445 | 445 | expect(first.ok).toBe(true); |
446 | | -expect(first.verifiedRequestKey).toEqual(expect.any(String)); |
| 446 | +expect(first.verifiedRequestKey).toBeTypeOf("string"); |
| 447 | +expect(first.verifiedRequestKey).not.toBe(""); |
447 | 448 | expect(second.ok).toBe(true); |
448 | 449 | expect(second.verifiedRequestKey).toBe(first.verifiedRequestKey); |
449 | 450 | expect(second.isReplay).toBe(true); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -8,6 +8,7 @@ import { LoginQRCallbackEventType } from "./zca-constants.js";
|
8 | 8 | |
9 | 9 | const createZaloMock = vi.hoisted(() => vi.fn()); |
10 | 10 | const TEST_MTIME_TICK_MS = 20; |
| 11 | +const ISO_TIMESTAMP_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u; |
11 | 12 | |
12 | 13 | vi.mock("./zca-client.js", () => ({ |
13 | 14 | createZalo: createZaloMock, |
@@ -197,7 +198,7 @@ describe("zalouser credential persistence", () => {
|
197 | 198 | const stored = await readStoredCredentials(stateDir, profile); |
198 | 199 | expect(stored.cookie).toEqual(refreshedCookie); |
199 | 200 | expect(stored.createdAt).toBe("2026-04-01T00:00:00.000Z"); |
200 | | -expect(stored.lastUsedAt).toEqual(expect.any(String)); |
| 201 | +expect(stored.lastUsedAt).toMatch(ISO_TIMESTAMP_RE); |
201 | 202 | }); |
202 | 203 | } finally { |
203 | 204 | await rm(stateDir, { recursive: true, force: true }); |
@@ -262,7 +263,7 @@ describe("zalouser credential persistence", () => {
|
262 | 263 | const stored = await readStoredCredentials(stateDir, profile); |
263 | 264 | expect(stored.cookie).toEqual(refreshedCookie); |
264 | 265 | expect(stored.createdAt).toBe("2026-04-01T00:00:00.000Z"); |
265 | | -expect(stored.lastUsedAt).toEqual(expect.any(String)); |
| 266 | +expect(stored.lastUsedAt).toMatch(ISO_TIMESTAMP_RE); |
266 | 267 | }); |
267 | 268 | } finally { |
268 | 269 | await rm(stateDir, { recursive: true, force: true }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -143,7 +143,7 @@ describe("i18n", () => {
|
143 | 143 | |
144 | 144 | it("keeps the version label available in shipped locales", () => { |
145 | 145 | for (const [locale, value] of Object.entries(shippedLocales)) { |
146 | | -expect((value.common as { version?: string }).version, locale).toEqual(expect.any(String)); |
| 146 | +expect((value.common as { version?: string }).version, locale).toBeTypeOf("string"); |
147 | 147 | expect((value.common as { version?: string }).version?.trim(), locale).not.toBe(""); |
148 | 148 | } |
149 | 149 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。