Skip to content

Commit 6991307

Browse files
committed
add env tests
1 parent 0e454bf commit 6991307

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

test/ios/app.test.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { deepEqual, equal, fail, throws } from "node:assert/strict";
1+
import { deepEqual, equal, fail, ok, throws } from "node:assert/strict";
2+
import * as fs from "node:fs";
23
import { afterEach, before, describe, it } from "node:test";
34
import { fileURLToPath } from "node:url";
45
import { generateProject as generateProjectActual } from "../../ios/app.mjs";
@@ -9,7 +10,7 @@ import type {
910
JSONObject,
1011
ProjectConfiguration,
1112
} from "../../scripts/types.ts";
12-
import { fs, setMockFiles, toJSON } from "../fs.mock.ts";
13+
import { fs as mockfs, setMockFiles, toJSON } from "../fs.mock.ts";
1314

1415
const macosOnly = { skip: process.platform === "win32" };
1516

@@ -19,7 +20,7 @@ describe("generateProject()", macosOnly, () => {
1920
platform: ApplePlatform,
2021
options: JSONObject
2122
): ProjectConfiguration {
22-
return generateProjectActual(projectRoot, platform, options, fs);
23+
return generateProjectActual(projectRoot, platform, options, mockfs);
2324
}
2425

2526
function makeMockProject(overrides?: Record<string, unknown>) {
@@ -158,6 +159,28 @@ describe("generateProject()", macosOnly, () => {
158159
deepEqual(trimPaths(result, cwd), expected.result);
159160
});
160161

162+
it(`[${platform}] exports path to Node binary`, () => {
163+
setMockFiles(makeMockProject());
164+
165+
generateProject(platform, platform, { fabricEnabled: true });
166+
const xcode_env = readTextFile(`${platform}/.xcode.env`, mockfs);
167+
const xcode_m = xcode_env.match(/export NODE_BINARY='(.*?)'/);
168+
169+
ok(xcode_m);
170+
ok(xcode_m[1].startsWith("/"));
171+
ok(fs.existsSync(xcode_m[1]));
172+
173+
const env = readTextFile(
174+
`node_modules/.generated/${platform}/.env`,
175+
mockfs
176+
);
177+
const env_m = env.match(/export PATH='(.*?)':\$PATH/);
178+
179+
ok(env_m);
180+
ok(env_m[1].startsWith("/"));
181+
ok(fs.existsSync(env_m[1]));
182+
});
183+
161184
it(`[${platform}] applies build setting overrides`, () => {
162185
setMockFiles(makeMockProject());
163186

0 commit comments

Comments
 (0)