
























@@ -73,9 +73,12 @@ function latestNodeInvokeCall() {
7373return call;
7474}
757576-function expectNonEmptyString(value: unknown) {
77-expect(typeof value).toBe("string");
78-expect((value as string).length).toBeGreaterThan(0);
76+function expectUuidString(value: unknown) {
77+expect(value).toEqual(
78+expect.stringMatching(
79+/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
80+),
81+);
7982}
80838184describe("cli program (nodes media)", () => {
@@ -102,10 +105,7 @@ describe("cli program (nodes media)", () => {
102105runtime.error.mockClear();
103106104107await expect(parseProgram.parseAsync(args, { from: "user" })).rejects.toThrow(/exit/i);
105-const matchingErrors = runtime.error.mock.calls
106-.map(([msg]) => String(msg))
107-.filter((msg) => expectedError.test(msg));
108-expect(matchingErrors.length).toBeGreaterThan(0);
108+expect(runtime.error).toHaveBeenCalledWith(expect.stringMatching(expectedError));
109109}
110110111111async function runAndExpectUrlPayloadMediaFile(params: {
@@ -178,7 +178,7 @@ describe("cli program (nodes media)", () => {
178178expect(invoke.params.nodeId).toBe("ios-node");
179179expect(invoke.params.command).toBe("camera.clip");
180180expect(invoke.params.timeoutMs).toBe(90000);
181-expectNonEmptyString(invoke.params.idempotencyKey);
181+expectUuidString(invoke.params.idempotencyKey);
182182expect(invoke.commandParams.facing).toBe("front");
183183expect(invoke.commandParams.durationMs).toBe(3000);
184184expect(invoke.commandParams.includeAudio).toBe(true);
@@ -215,7 +215,7 @@ describe("cli program (nodes media)", () => {
215215expect(invoke.params.nodeId).toBe("ios-node");
216216expect(invoke.params.command).toBe("camera.snap");
217217expect(invoke.params.timeoutMs).toBe(20000);
218-expectNonEmptyString(invoke.params.idempotencyKey);
218+expectUuidString(invoke.params.idempotencyKey);
219219expect(invoke.commandParams.facing).toBe("front");
220220expect(invoke.commandParams.maxWidth).toBe(640);
221221expect(invoke.commandParams.quality).toBe(0.8);
@@ -251,7 +251,7 @@ describe("cli program (nodes media)", () => {
251251expect(invoke.params.nodeId).toBe("ios-node");
252252expect(invoke.params.command).toBe("camera.clip");
253253expect(invoke.params.timeoutMs).toBe(90000);
254-expectNonEmptyString(invoke.params.idempotencyKey);
254+expectUuidString(invoke.params.idempotencyKey);
255255expect(invoke.commandParams.includeAudio).toBe(false);
256256expect(invoke.commandParams.deviceId).toBe("cam-123");
257257此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。