Repository navigation
Expand file tree
/
Copy pathnative-mapbox-version.test.mjs
More file actions
58 lines (56 loc) · 1.81 KB
/
Copy pathnative-mapbox-version.test.mjs
File metadata and controls
58 lines (56 loc) · 1.81 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
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import {
nativeMapboxSdkVersion,
pinNativeMapboxVersion,
} from "./native-mapbox-version.mjs";
const podfile =
"platform :ios, '15.0'\ntarget 'Example' do\n use_native_modules!\nend\n";
const buildGradle =
"buildscript {\n ext {\n minSdkVersion = 24\n }\n}\n";
const result = pinNativeMapboxVersion(podfile, buildGradle);
assert.match(result.podfile, /^\$RNMapboxMapsVersion = '= 11\.23\.1'\n/);
assert.match(
result.buildGradle,
/ext \{\n RNMapboxMapsVersion = '11\.23\.1'/
);
assert(result.podfile.endsWith(podfile));
assert(result.buildGradle.includes("minSdkVersion = 24"));
assert.deepEqual(
pinNativeMapboxVersion(result.podfile, result.buildGradle),
result
);
assert.deepEqual(
pinNativeMapboxVersion(
"$RNMapboxMapsVersion = '~> 11.23.1'\n" + podfile,
"buildscript {\n ext {\n RNMapboxMapsVersion = '10.19.0'\n minSdkVersion = 24\n }\n}\n"
),
result
);
assert.throws(
() => pinNativeMapboxVersion(podfile, "invalid template"),
/buildscript.ext/
);
const matrix = JSON.parse(
readFileSync(
new URL("../records/support-matrix.json", import.meta.url),
"utf8"
)
);
assert.equal(matrix.nativeSdkPin.mapbox.ios, nativeMapboxSdkVersion);
assert.equal(matrix.nativeSdkPin.mapbox.android, nativeMapboxSdkVersion);
const wrapperGradle = readFileSync(
new URL(
"../node_modules/@rnmapbox/maps/android/build.gradle",
import.meta.url
),
"utf8"
);
assert.match(wrapperGradle, /rootProject\.ext\.has\(prop\)/);
assert.match(
wrapperGradle,
/safeExtGet\("RNMapboxMapsVersion", defaultMapboxMapsVersion\)/
);
console.log(
"PASS native Mapbox SDK pin: exact public settings, idempotence, replacement, malformed template and support matrix agreement; no native build"
);