@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 52 lines 2.05 KB
Raw
1 import { describe, expect, it } from "vitest";
2 import { makeAwsTarget, NITRO_HANDLER_SPECIFIER, NITRO_PRESET } from "../aws.ts";
3 import type { NitroConfigSlice } from "../UserConfig.ts";
4
5 describe("makeAwsTarget", () => {
6 it("declares the aws platform, the nitro preset, and node bundle settings", () => {
7 const target = makeAwsTarget();
8 expect(target.platform).toBe("aws");
9 expect(target.nitroPreset).toBe(NITRO_PRESET);
10 expect(target.bundle?.conditions).toEqual(["node", "import", "module"]);
11 expect(target.bundle?.external).toEqual(["@aws-sdk/"]);
12 // Nitro's aws-lambda output is already a complete Node deployment unit.
13 expect(target.finish).toBeUndefined();
14 });
15
16 it("runs the build in a disposable child process", () => {
17 expect(typeof makeAwsTarget().build).toBe("function");
18 });
19
20 it("enables response streaming by default", () => {
21 const config: NitroConfigSlice = {};
22 makeAwsTarget().configureNitro?.(config, { root: "/project" });
23 expect(config.awsLambda).toEqual({ streaming: true });
24 });
25
26 it("honors an explicit streaming opt-out (buffered handler)", () => {
27 const config: NitroConfigSlice = {};
28 makeAwsTarget({ streaming: false }).configureNitro?.(config, {
29 root: "/project",
30 });
31 expect(config.awsLambda).toEqual({ streaming: false });
32 });
33
34 it("preserves foreign awsLambda keys while overriding the owned one", () => {
35 const config: NitroConfigSlice = {
36 awsLambda: { streaming: false, someOtherKey: 1 },
37 };
38 makeAwsTarget().configureNitro?.(config, { root: "/project" });
39 expect(config.awsLambda).toEqual({ streaming: true, someOtherKey: 1 });
40 });
41
42 it("carries the caller's nitro overrides on the target config", () => {
43 const target = makeAwsTarget({ nitro: { prerender: { routes: ["/"] } } });
44 expect(target.config.nitro).toEqual({ prerender: { routes: ["/"] } });
45 });
46
47 it("exports the wrappable-handler specifier for custom entries", () => {
48 expect(NITRO_HANDLER_SPECIFIER).toBe(
49 "nitropack/presets/aws-lambda/runtime/aws-lambda-streaming",
50 );
51 });
52 });