mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
test: isolate qr/setup-code token env in unit tests
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Command } from "commander";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { encodePairingSetupCode } from "../pairing/setup-code.js";
|
||||
|
||||
const runtime = {
|
||||
@@ -30,6 +30,14 @@ const { registerQrCli } = await import("./qr-cli.js");
|
||||
describe("registerQrCli", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.stubEnv("OPENCLAW_GATEWAY_TOKEN", "");
|
||||
vi.stubEnv("CLAWDBOT_GATEWAY_TOKEN", "");
|
||||
vi.stubEnv("OPENCLAW_GATEWAY_PASSWORD", "");
|
||||
vi.stubEnv("CLAWDBOT_GATEWAY_PASSWORD", "");
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
it("prints setup code only when requested", async () => {
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { encodePairingSetupCode, resolvePairingSetupFromConfig } from "./setup-code.js";
|
||||
|
||||
describe("pairing setup code", () => {
|
||||
beforeEach(() => {
|
||||
vi.stubEnv("OPENCLAW_GATEWAY_TOKEN", "");
|
||||
vi.stubEnv("CLAWDBOT_GATEWAY_TOKEN", "");
|
||||
vi.stubEnv("OPENCLAW_GATEWAY_PASSWORD", "");
|
||||
vi.stubEnv("CLAWDBOT_GATEWAY_PASSWORD", "");
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
it("encodes payload as base64url JSON", () => {
|
||||
const code = encodePairingSetupCode({
|
||||
url: "wss://gateway.example.com:443",
|
||||
|
||||
Reference in New Issue
Block a user