-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathgetConfig.test.ts
More file actions
127 lines (113 loc) · 4.01 KB
/
getConfig.test.ts
File metadata and controls
127 lines (113 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { deepEqual } from "node:assert/strict";
import * as path from "node:path";
import { describe, it } from "node:test";
import {
getConfig as getConfigActual,
getPlatformPackage,
} from "../../scripts/configure.mjs";
import type { ConfigureParams, Platform } from "../../scripts/types.ts";
import { templatePath } from "../template.ts";
import { mockParams } from "./mockParams.ts";
describe("getConfig()", () => {
const getConfig: typeof getConfigActual = (params, platform) =>
getConfigActual({ ...params, templatePath }, platform, true);
/**
* Gets the list of dependencies from specified config.
*/
function getDependencies(
platform: Platform,
{ targetVersion }: ConfigureParams
): string[] | undefined {
const dependencies = getPlatformPackage(platform, targetVersion);
return dependencies && Object.keys(dependencies);
}
it("returns common scripts and files", () => {
const params = mockParams();
const config = getConfig(params, "common");
deepEqual(Object.keys(config.files).sort(), [
".gitignore",
".watchmanconfig",
"babel.config.js",
"metro.config.js",
"react-native.config.js",
]);
deepEqual(config.oldFiles, []);
deepEqual(Object.keys(config.scripts).sort(), ["mkdist", "start"]);
deepEqual(getDependencies("common", params), []);
});
it("returns more common scripts and files when initializing", () => {
const params = mockParams({ init: true });
const config = getConfig(params, "common");
deepEqual(Object.keys(config.files).sort(), [
".bundle/config",
".gitignore",
".watchmanconfig",
"App.tsx",
"Gemfile",
"app.json",
"babel.config.js",
"index.js",
"metro.config.js",
"package.json",
"react-native.config.js",
"tsconfig.json",
]);
deepEqual(config.oldFiles, []);
deepEqual(Object.keys(config.scripts).sort(), ["mkdist", "start"]);
deepEqual(getDependencies("common", params), []);
});
it("returns Android specific scripts and additional files", () => {
const params = mockParams();
const config = getConfig(params, "android");
deepEqual(Object.keys(config.scripts).sort(), ["android", "build:android"]);
deepEqual(getDependencies("android", params), []);
deepEqual(Object.keys(config.files).sort(), [
"build.gradle",
"gradle.properties",
"gradle/wrapper/gradle-wrapper.jar",
"gradle/wrapper/gradle-wrapper.properties",
"gradlew",
"gradlew.bat",
"settings.gradle",
]);
deepEqual(config.oldFiles, []);
});
it("returns iOS specific scripts and additional files", () => {
const params = mockParams();
const config = getConfig(params, "ios");
deepEqual(Object.keys(config.scripts).sort(), ["build:ios", "ios"]);
deepEqual(getDependencies("ios", params), []);
deepEqual(Object.keys(config.files).sort(), ["Podfile"]);
deepEqual(config.oldFiles.sort(), [
"Podfile.lock",
"Pods",
"Test.xcodeproj",
"Test.xcworkspace",
]);
});
it("returns macOS specific scripts and additional files", () => {
const params = mockParams();
const config = getConfig(params, "macos");
deepEqual(Object.keys(config.scripts).sort(), ["build:macos", "macos"]);
deepEqual(Object.keys(config.files).sort(), ["Podfile"]);
deepEqual(getDependencies("macos", params), ["react-native-macos"]);
deepEqual(config.oldFiles.sort(), [
"Podfile.lock",
"Pods",
"Test.xcodeproj",
"Test.xcworkspace",
]);
});
it("returns Windows specific scripts and additional files", () => {
const params = mockParams();
const config = getConfig(params, "windows");
deepEqual(Object.keys(config.scripts).sort(), ["build:windows", "windows"]);
deepEqual(getDependencies("windows", params), ["react-native-windows"]);
deepEqual(Object.keys(config.files).sort(), [".gitignore"]);
deepEqual(config.oldFiles.sort(), [
"Test.sln",
"Test.vcxproj",
path.join("Test", "Test.vcxproj"),
]);
});
});