Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
import { describe, expect, it } from "vitest";
import { applyDotEnv } from "./dotEnv.js";
describe("applyDotEnv", () => {
it("copies a project's keys without overwriting what is already set", () => {
const env: NodeJS.ProcessEnv = { KEPT: "outer" };
applyDotEnv('export GEMINI_KEY="abc" # note\nKEPT=inner\n# comment\nPLAIN=x #c', env);
expect(env).toEqual({ KEPT: "outer", GEMINI_KEY: "abc", PLAIN: "x" });
});
it("never takes the feedback email from a project file", () => {
const env: NodeJS.ProcessEnv = {};
applyDotEnv("[email protected]\nOTHER=1", env);
expect(env).toEqual({ OTHER: "1" });
});
it("never takes the feedback email under another letter case", () => {
const env: NodeJS.ProcessEnv = {};
applyDotEnv(
"[email protected]\n[email protected]\nOTHER=1",
env,
);
expect(env).toEqual({ OTHER: "1" });
});
it("copies only exact allowed names when a caller limits the imported settings", () => {
const env: NodeJS.ProcessEnv = { GEMINI_API_KEY: "inherited" };
applyDotEnv(
"GEMINI_API_KEY=project\nGOOGLE_API_KEY=allowed\ngoogle_api_key=other\nPATH=/untrusted\nLD_PRELOAD=payload",
env,
["GEMINI_API_KEY", "GOOGLE_API_KEY"],
);
expect(env).toEqual({ GEMINI_API_KEY: "inherited", GOOGLE_API_KEY: "allowed" });
});
it("an allowlist cannot opt the feedback email back in", () => {
const env: NodeJS.ProcessEnv = {};
applyDotEnv("HyperFrames_Feedback_Email=private", env, ["HyperFrames_Feedback_Email"]);
expect(env).toEqual({});
});
it("an empty allowlist imports nothing", () => {
const env: NodeJS.ProcessEnv = {};
applyDotEnv("GEMINI_API_KEY=project", env, []);
expect(env).toEqual({});
});
});