Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

app.config.test.ts

33 lines1.1 KB

1import { afterEach, expect, it, vi } from "vite-plus/test";
2​
3// Keep config parsing independent of local env files and build credentials.
4vi.mock("../../scripts/lib/public-config.ts", () => ({
5 loadRepoEnv: () => ({ APP_VARIANT: process.env.APP_VARIANT }),
6}));
7​
8afterEach(() => {
9 vi.unstubAllEnvs();
10});
11​
12async function loadConfig(variant: string | undefined) {
13 vi.resetModules();
14 vi.stubEnv("APP_VARIANT", variant);
15 return (await import("./app.config.ts")).default;
17​
18it.each(["prod", ""])("rejects APP_VARIANT=%j before selecting production IDs", async (value) => {
19 await expect(loadConfig(value)).rejects.toThrow(
20 "APP_VARIANT must be development, preview, or production.",
21 );
22});
23​
24it.each([
25 [undefined, "com.t3tools.t3code"],
26 ["development", "com.t3tools.t3code.dev"],
27 ["preview", "com.t3tools.t3code.preview"],
28 ["production", "com.t3tools.t3code"],
29])("keeps the iOS and Android identifiers for APP_VARIANT=%j", async (value, identifier) => {
30 const config = await loadConfig(value);
31 expect(config.ios?.bundleIdentifier).toBe(identifier);
32 expect(config.android?.package).toBe(identifier);
33});