mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
test: scope channel prompts locale
This commit is contained in:
@@ -1,17 +1,13 @@
|
||||
// Channel setup prompt tests cover prompt choices and validation.
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { ChannelSetupDmPolicy } from "../commands/channel-setup/types.js";
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import { withEnvAsync } from "../test-utils/env.js";
|
||||
import type { WizardPrompter } from "../wizard/prompts.js";
|
||||
import { maybeConfigureDmPolicies } from "./channel-setup.prompts.js";
|
||||
|
||||
beforeEach(() => {
|
||||
delete process.env.OPENCLAW_LOCALE;
|
||||
});
|
||||
|
||||
describe("maybeConfigureDmPolicies", () => {
|
||||
it("localizes DM policy guidance and options", async () => {
|
||||
process.env.OPENCLAW_LOCALE = "zh-CN";
|
||||
const note = vi.fn<WizardPrompter["note"]>(async () => {});
|
||||
const select = vi.fn(async () => "pairing") as unknown as WizardPrompter["select"];
|
||||
const prompter = {
|
||||
@@ -28,11 +24,13 @@ describe("maybeConfigureDmPolicies", () => {
|
||||
setPolicy: (cfg: OpenClawConfig) => cfg,
|
||||
};
|
||||
|
||||
await maybeConfigureDmPolicies({
|
||||
cfg: {},
|
||||
selection: ["telegram" as never],
|
||||
prompter,
|
||||
resolveAdapter: () => ({ dmPolicy: policy }) as never,
|
||||
await withEnvAsync({ OPENCLAW_LOCALE: "zh-CN" }, async () => {
|
||||
await maybeConfigureDmPolicies({
|
||||
cfg: {},
|
||||
selection: ["telegram" as never],
|
||||
prompter,
|
||||
resolveAdapter: () => ({ dmPolicy: policy }) as never,
|
||||
});
|
||||
});
|
||||
|
||||
expect(note.mock.calls[0]?.[0]).toContain("默认:配对");
|
||||
|
||||
Reference in New Issue
Block a user