Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1.2 KB
Raw Blame
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { buildProxyTypes } from "../../src/shared/components/ProxyConfigModal.tsx";

describe("buildProxyTypes — #3508 runtime socks5 flag", () => {
  it("includes socks5 when socks5Enabled is true", () => {
    const types = buildProxyTypes(true);
    const values = types.map((t) => t.value);
    assert.ok(values.includes("socks5"), "socks5 should be present when enabled");
    assert.ok(values.includes("http"), "http should always be present");
    assert.ok(values.includes("https"), "https should always be present");
  });

  it("excludes socks5 when socks5Enabled is false", () => {
    const types = buildProxyTypes(false);
    const values = types.map((t) => t.value);
    assert.ok(!values.includes("socks5"), "socks5 should be absent when disabled");
    assert.ok(values.includes("http"), "http should always be present");
    assert.ok(values.includes("https"), "https should always be present");
  });

  it("returns a new array each call (no shared mutation)", () => {
    const a = buildProxyTypes(true);
    const b = buildProxyTypes(false);
    assert.notStrictEqual(a, b);
    assert.equal(a.length, 3);
    assert.equal(b.length, 2);
  });
});