|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { toMcpContextOptions } from "./contextOptions.js"; |
| 3 | +import type { McpCommandOptions } from "../commands/mcp.js"; |
| 4 | + |
| 5 | +// The dev-only guards only work if `--dev-only` is threaded from the parsed |
| 6 | +// CLI options into the McpContext. These tests pin that wiring. |
| 7 | +const baseOptions = { |
| 8 | + projectRef: "proj_123", |
| 9 | + apiUrl: "https://api.example.com", |
| 10 | + profile: "default", |
| 11 | + readonly: false, |
| 12 | + devOnly: false, |
| 13 | +} as unknown as McpCommandOptions; |
| 14 | + |
| 15 | +describe("toMcpContextOptions", () => { |
| 16 | + it("threads devOnly=true through to the context options", () => { |
| 17 | + expect(toMcpContextOptions({ ...baseOptions, devOnly: true }, undefined).devOnly).toBe(true); |
| 18 | + }); |
| 19 | + |
| 20 | + it("threads devOnly=false through to the context options", () => { |
| 21 | + expect(toMcpContextOptions({ ...baseOptions, devOnly: false }, undefined).devOnly).toBe(false); |
| 22 | + }); |
| 23 | + |
| 24 | + it("carries the other relevant options across", () => { |
| 25 | + const result = toMcpContextOptions(baseOptions, undefined); |
| 26 | + expect(result.projectRef).toBe("proj_123"); |
| 27 | + expect(result.apiUrl).toBe("https://api.example.com"); |
| 28 | + expect(result.profile).toBe("default"); |
| 29 | + expect(result.readonly).toBe(false); |
| 30 | + }); |
| 31 | +}); |
0 commit comments