test: isolate qr/setup-code token env in unit tests

feature/PAZ-358-fe-credit-error-display
Peter Steinberger 9 months ago
parent c9f2c3aef9
commit bc55ffb160

@ -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",

Loading…
Cancel
Save