-
Notifications
You must be signed in to change notification settings - Fork 432
Expand file tree
/
Copy pathtinytex.test.ts
More file actions
160 lines (143 loc) · 4.27 KB
/
tinytex.test.ts
File metadata and controls
160 lines (143 loc) · 4.27 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
* tinytex.test.ts
*
* Copyright (C) 2026 Posit Software, PBC
*/
import { unitTest } from "../../test.ts";
import { assert, assertEquals } from "testing/asserts";
import { tinyTexPkgName } from "../../../src/tools/impl/tinytex.ts";
import { getLatestRelease } from "../../../src/tools/github.ts";
import { GitHubRelease } from "../../../src/tools/types.ts";
// ---- Pure logic tests for tinyTexPkgName ----
unitTest("tinyTexPkgName - Linux aarch64 with version", async () => {
assertEquals(
tinyTexPkgName("TinyTeX", "v2026.04", { os: "linux", arch: "aarch64" }),
[
"TinyTeX-linux-arm64-v2026.04.tar.xz",
"TinyTeX-arm64-v2026.04.tar.gz",
],
);
});
unitTest("tinyTexPkgName - Linux x86_64 with version", async () => {
assertEquals(
tinyTexPkgName("TinyTeX", "v2026.04", { os: "linux", arch: "x86_64" }),
[
"TinyTeX-linux-x86_64-v2026.04.tar.xz",
"TinyTeX-v2026.04.tar.gz",
],
);
});
unitTest("tinyTexPkgName - macOS with version", async () => {
assertEquals(
tinyTexPkgName("TinyTeX", "v2026.04", { os: "darwin", arch: "aarch64" }),
[
"TinyTeX-darwin-v2026.04.tar.xz",
"TinyTeX-v2026.04.tgz",
],
);
});
unitTest("tinyTexPkgName - Windows with version", async () => {
assertEquals(
tinyTexPkgName("TinyTeX", "v2026.04", { os: "windows", arch: "x86_64" }),
[
"TinyTeX-windows-v2026.04.exe",
"TinyTeX-v2026.04.zip",
],
);
});
unitTest("tinyTexPkgName - versionless Linux aarch64", async () => {
assertEquals(
tinyTexPkgName("TinyTeX", undefined, { os: "linux", arch: "aarch64" }),
["TinyTeX.tar.gz"],
);
});
unitTest("tinyTexPkgName - TinyTeX-1 ARM64 Linux", async () => {
assertEquals(
tinyTexPkgName("TinyTeX-1", "v2026.04", {
os: "linux",
arch: "aarch64",
}),
[
"TinyTeX-1-linux-arm64-v2026.04.tar.xz",
"TinyTeX-1-arm64-v2026.04.tar.gz",
],
);
});
unitTest("tinyTexPkgName - default base", async () => {
assertEquals(
tinyTexPkgName(undefined, "v2026.04", { os: "linux", arch: "x86_64" }),
[
"TinyTeX-linux-x86_64-v2026.04.tar.xz",
"TinyTeX-v2026.04.tar.gz",
],
);
});
// ---- Asset-existence tests (network, verify against latest release) ----
const kTinyTexRepo = "rstudio/tinytex-releases";
let cachedRelease: GitHubRelease | undefined;
async function getRelease() {
if (!cachedRelease) {
cachedRelease = await getLatestRelease(kTinyTexRepo);
}
return cachedRelease;
}
function assertAssetExists(
candidates: string[],
assetNames: string[],
label: string,
) {
const found = candidates.some((c) => assetNames.includes(c));
assert(
found,
`No matching asset for ${label}. Candidates: ${candidates.join(", ")}. ` +
`Available TinyTeX assets: ${assetNames.filter((a) => a.startsWith("TinyTeX")).join(", ")}`,
);
}
unitTest(
"tinyTexPkgName - Linux x86_64 candidates match latest release",
async () => {
const release = await getRelease();
const assetNames = release.assets.map((a) => a.name);
const candidates = tinyTexPkgName("TinyTeX", release.tag_name, {
os: "linux",
arch: "x86_64",
});
assertAssetExists(candidates, assetNames, "Linux x86_64");
},
);
unitTest(
"tinyTexPkgName - Linux aarch64 candidates match latest release",
async () => {
const release = await getRelease();
const assetNames = release.assets.map((a) => a.name);
const candidates = tinyTexPkgName("TinyTeX", release.tag_name, {
os: "linux",
arch: "aarch64",
});
assertAssetExists(candidates, assetNames, "Linux aarch64");
},
);
unitTest(
"tinyTexPkgName - macOS candidates match latest release",
async () => {
const release = await getRelease();
const assetNames = release.assets.map((a) => a.name);
const candidates = tinyTexPkgName("TinyTeX", release.tag_name, {
os: "darwin",
arch: "aarch64",
});
assertAssetExists(candidates, assetNames, "macOS");
},
);
unitTest(
"tinyTexPkgName - Windows candidates match latest release",
async () => {
const release = await getRelease();
const assetNames = release.assets.map((a) => a.name);
const candidates = tinyTexPkgName("TinyTeX", release.tag_name, {
os: "windows",
arch: "x86_64",
});
assertAssetExists(candidates, assetNames, "Windows");
},
);