| 1 | import { makeDeployTarget } from "../../core/index.ts"; |
| 2 | import { describe, expect, it } from "vitest"; |
| 3 | import { |
| 4 | DEFAULT_TARGET_SPECIFIER, |
| 5 | isVocsTarget, |
| 6 | selectVocsTargetInput, |
| 7 | } from "../Target.ts"; |
| 8 | |
| 9 | describe("Vocs target selection", () => { |
| 10 | it("uses the Vocs Cloudflare target by default", () => { |
| 11 | expect(selectVocsTargetInput()).toEqual({ |
| 12 | input: DEFAULT_TARGET_SPECIFIER, |
| 13 | config: undefined, |
| 14 | }); |
| 15 | }); |
| 16 | |
| 17 | it("unwraps the E2E harness Cloudflare worker configuration", () => { |
| 18 | const worker = { compatibilityDate: "2026-03-10" }; |
| 19 | expect( |
| 20 | selectVocsTargetInput({ target: { cloudflare: { worker } } }), |
| 21 | ).toEqual({ input: DEFAULT_TARGET_SPECIFIER, config: worker }); |
| 22 | }); |
| 23 | |
| 24 | it("preserves an explicit target and its factory configuration", () => { |
| 25 | const factory = () => |
| 26 | makeDeployTarget({ |
| 27 | platform: "test", |
| 28 | config: undefined, |
| 29 | adapter: () => { |
| 30 | throw new Error("not called"); |
| 31 | }, |
| 32 | vitePlugins: () => { |
| 33 | throw new Error("not called"); |
| 34 | }, |
| 35 | }); |
| 36 | const config = { region: "test" }; |
| 37 | expect(selectVocsTargetInput({ target: factory, vite: config })).toEqual({ |
| 38 | input: factory, |
| 39 | config, |
| 40 | }); |
| 41 | }); |
| 42 | |
| 43 | it("recognizes only deploy targets with the Waku runtime hooks", () => { |
| 44 | expect( |
| 45 | isVocsTarget( |
| 46 | makeDeployTarget({ |
| 47 | platform: "test", |
| 48 | config: undefined, |
| 49 | adapter: () => { |
| 50 | throw new Error("not called"); |
| 51 | }, |
| 52 | vitePlugins: () => { |
| 53 | throw new Error("not called"); |
| 54 | }, |
| 55 | }), |
| 56 | ), |
| 57 | ).toBe(true); |
| 58 | expect( |
| 59 | isVocsTarget(makeDeployTarget({ platform: "test", config: undefined })), |
| 60 | ).toBe(false); |
| 61 | }); |
| 62 | }); |