

























@@ -245,20 +245,23 @@ describe("resolveDiscordPresenceUpdate", () => {
245245246246it("returns status-only presence when activity is omitted", () => {
247247const presence = resolveDiscordPresenceUpdate({ status: "dnd" });
248-expect(presence).not.toBeNull();
249-expect(presence?.status).toBe("dnd");
250-expect(presence?.activities).toEqual([]);
248+expect(presence).toMatchObject({
249+status: "dnd",
250+activities: [],
251+});
251252});
252253253254it("defaults to custom activity type when activity is set without type", () => {
254255const presence = resolveDiscordPresenceUpdate({ activity: "Focus time" });
255-expect(presence).not.toBeNull();
256-expect(presence?.status).toBe("online");
257-expect(presence?.activities).toHaveLength(1);
258-expect(presence?.activities[0]).toMatchObject({
259-type: 4,
260-name: "Custom Status",
261-state: "Focus time",
256+expect(presence).toMatchObject({
257+status: "online",
258+activities: [
259+expect.objectContaining({
260+type: 4,
261+name: "Custom Status",
262+state: "Focus time",
263+}),
264+],
262265});
263266});
264267@@ -268,12 +271,14 @@ describe("resolveDiscordPresenceUpdate", () => {
268271activityType: 1,
269272activityUrl: "https://twitch.tv/openclaw",
270273});
271-expect(presence).not.toBeNull();
272-expect(presence?.activities).toHaveLength(1);
273-expect(presence?.activities[0]).toMatchObject({
274-type: 1,
275-name: "Live",
276-url: "https://twitch.tv/openclaw",
274+expect(presence).toMatchObject({
275+activities: [
276+expect.objectContaining({
277+type: 1,
278+name: "Live",
279+url: "https://twitch.tv/openclaw",
280+}),
281+],
277282});
278283});
279284});
@@ -331,17 +336,16 @@ describe("resolveDiscordAutoThreadContext", () => {
331336continue;
332337}
333338334-expect(context, testCase.name).not.toBeNull();
335-expect(context?.To, testCase.name).toBe("channel:thread");
336-expect(context?.From, testCase.name).toBe("discord:channel:thread");
337-expect(context?.OriginatingTo, testCase.name).toBe("channel:thread");
338-expect(context?.SessionKey, testCase.name).toBe(
339-buildAgentSessionKey({
339+expect(context, testCase.name).toMatchObject({
340+To: "channel:thread",
341+From: "discord:channel:thread",
342+OriginatingTo: "channel:thread",
343+SessionKey: buildAgentSessionKey({
340344agentId: "agent",
341345channel: "discord",
342346peer: { kind: "channel", id: "thread" },
343347}),
344-);
348+});
345349expect(context?.ParentSessionKey, testCase.name).toBe(testCase.expectedParentSessionKey);
346350expect(context?.ModelParentSessionKey, testCase.name).toBe(
347351testCase.expectedModelParentSessionKey,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。