mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 19:14:33 +00:00
refactor(test): use env helper for telegram TZ override
This commit is contained in:
@@ -4,6 +4,7 @@ import path from "node:path";
|
|||||||
import type { Chat, Message } from "@grammyjs/types";
|
import type { Chat, Message } from "@grammyjs/types";
|
||||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import { escapeRegExp, formatEnvelopeTimestamp } from "../../test/helpers/envelope-timestamp.js";
|
import { escapeRegExp, formatEnvelopeTimestamp } from "../../test/helpers/envelope-timestamp.js";
|
||||||
|
import { withEnvAsync } from "../test-utils/env.js";
|
||||||
import {
|
import {
|
||||||
answerCallbackQuerySpy,
|
answerCallbackQuerySpy,
|
||||||
botCtorSpy,
|
botCtorSpy,
|
||||||
@@ -225,10 +226,7 @@ describe("createTelegramBot", () => {
|
|||||||
expect(answerCallbackQuerySpy).toHaveBeenCalledWith("cbq-1");
|
expect(answerCallbackQuerySpy).toHaveBeenCalledWith("cbq-1");
|
||||||
});
|
});
|
||||||
it("wraps inbound message with Telegram envelope", async () => {
|
it("wraps inbound message with Telegram envelope", async () => {
|
||||||
const originalTz = process.env.TZ;
|
await withEnvAsync({ TZ: "Europe/Vienna" }, async () => {
|
||||||
process.env.TZ = "Europe/Vienna";
|
|
||||||
|
|
||||||
try {
|
|
||||||
onSpy.mockReset();
|
onSpy.mockReset();
|
||||||
replySpy.mockReset();
|
replySpy.mockReset();
|
||||||
|
|
||||||
@@ -262,9 +260,7 @@ describe("createTelegramBot", () => {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(payload.Body).toContain("hello world");
|
expect(payload.Body).toContain("hello world");
|
||||||
} finally {
|
});
|
||||||
process.env.TZ = originalTz;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
it("requests pairing by default for unknown DM senders", async () => {
|
it("requests pairing by default for unknown DM senders", async () => {
|
||||||
onSpy.mockReset();
|
onSpy.mockReset();
|
||||||
|
|||||||
Reference in New Issue
Block a user