|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { buildDeploymentS2Client } from "~/v3/s2Client.server"; |
| 3 | + |
| 4 | +const BASIN = "trigger-local"; |
| 5 | + |
| 6 | +describe("buildDeploymentS2Client", () => { |
| 7 | + it("uses the SDK's hosted defaults when no endpoint is configured", () => { |
| 8 | + const client = buildDeploymentS2Client({ accessToken: "token" }); |
| 9 | + |
| 10 | + expect(client.endpoints.accountBaseUrl()).toBe("https://a.s2.dev/v1"); |
| 11 | + expect(client.endpoints.basinBaseUrl(BASIN)).toBe(`https://${BASIN}.b.s2.dev/v1`); |
| 12 | + expect(client.endpoints.includeBasinHeader).toBe(false); |
| 13 | + }); |
| 14 | + |
| 15 | + it("points both the account and basin hosts at a configured endpoint", () => { |
| 16 | + const client = buildDeploymentS2Client({ |
| 17 | + accessToken: "token", |
| 18 | + endpoint: "http://localhost:4566", |
| 19 | + }); |
| 20 | + |
| 21 | + expect(client.endpoints.accountBaseUrl()).toBe("http://localhost:4566/v1"); |
| 22 | + expect(client.endpoints.basinBaseUrl(BASIN)).toBe("http://localhost:4566/v1"); |
| 23 | + expect(client.endpoints.includeBasinHeader).toBe(true); |
| 24 | + }); |
| 25 | + |
| 26 | + // A split configuration would send the access token to the hosted service while the operator |
| 27 | + // believed the client was entirely local, so one value has to drive both hosts. |
| 28 | + it("never leaves one host hosted while the other is overridden", () => { |
| 29 | + const client = buildDeploymentS2Client({ |
| 30 | + accessToken: "token", |
| 31 | + endpoint: "http://localhost:4566", |
| 32 | + }); |
| 33 | + |
| 34 | + expect(client.endpoints.accountBaseUrl()).not.toContain("s2.dev"); |
| 35 | + expect(client.endpoints.basinBaseUrl(BASIN)).not.toContain("s2.dev"); |
| 36 | + }); |
| 37 | +}); |
0 commit comments