Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions apps/mobile/app.config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { afterEach, expect, it, vi } from "vite-plus/test";

// Keep config parsing independent of local env files and build credentials.
vi.mock("../../scripts/lib/public-config.ts", () => ({
loadRepoEnv: () => ({ APP_VARIANT: process.env.APP_VARIANT }),
}));

afterEach(() => {
vi.unstubAllEnvs();
});

async function loadConfig(variant: string | undefined) {
vi.resetModules();
vi.stubEnv("APP_VARIANT", variant);
return (await import("./app.config.ts")).default;
}

it.each(["prod", ""])("rejects APP_VARIANT=%j before selecting production IDs", async (value) => {
await expect(loadConfig(value)).rejects.toThrow(
"APP_VARIANT must be development, preview, or production.",
);
});

it.each([
[undefined, "com.t3tools.t3code"],
["development", "com.t3tools.t3code.dev"],
["preview", "com.t3tools.t3code.preview"],
["production", "com.t3tools.t3code"],
])("keeps the iOS and Android identifiers for APP_VARIANT=%j", async (value, identifier) => {
const config = await loadConfig(value);
expect(config.ios?.bundleIdentifier).toBe(identifier);
expect(config.android?.package).toBe(identifier);
});
4 changes: 3 additions & 1 deletion apps/mobile/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ function resolveAppVariant(value: string | undefined): AppVariant {
case "preview":
case "production":
return value;
default:
case undefined:
return "production";
default:
throw new Error("APP_VARIANT must be development, preview, or production.");
}
}

Expand Down
Loading