CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/util/compute-images.test.ts
Views: 687
1
import { FALLBACK_SOFTWARE_ENV } from "./compute-images";
2
3
test("fallback name exists", () => {
4
expect(
5
FALLBACK_SOFTWARE_ENV.environments[FALLBACK_SOFTWARE_ENV.default]
6
).toBeDefined();
7
});
8
9
test("consistent naming", () => {
10
const envs = FALLBACK_SOFTWARE_ENV.environments;
11
const groups = FALLBACK_SOFTWARE_ENV.groups;
12
for (const [name, info] of Object.entries(envs)) {
13
const i = name.indexOf("-");
14
const [base, ts] =
15
i > 0 ? [name.slice(0, i), name.slice(i + 1)] : [name, ""];
16
expect(info.title).toBeDefined();
17
expect(groups.includes(info.group)).toBe(true);
18
const { group, title, short } = info;
19
20
expect(short).toBeDefined();
21
switch (group) {
22
case "Main":
23
expect(
24
["default", "ubuntu2004", "ubuntu2204", "ubuntu1804"].includes(base)
25
).toBe(true);
26
break;
27
28
case "Ubuntu 16.04":
29
expect(["old"].includes(base)).toBe(true);
30
expect(title?.indexOf(ts) ?? 0 > 0);
31
break;
32
33
case "Ubuntu 18.04":
34
expect(["exp", "stable", "previous"].includes(base)).toBe(true);
35
expect(title?.indexOf(ts) ?? 0 > 0);
36
if (base === "stable") {
37
expect(ts.startsWith(short ?? "")).toBe(true);
38
}
39
break;
40
41
case "Ubuntu 20.04":
42
expect(["ubuntu2004", "exp"].includes(base)).toBe(true);
43
expect(title?.indexOf(ts) ?? 0 > 0);
44
if (ts === "dev" || ts === "previous") {
45
} else if (base === "ubuntu2004") {
46
expect(ts.startsWith(short ?? "")).toBe(true);
47
}
48
break;
49
50
case "Ubuntu 22.04":
51
expect(["ubuntu2204", "exp"].includes(base)).toBe(true);
52
expect(title?.indexOf(ts) ?? 0 > 0);
53
if (ts === "dev" || ts === "previous") {
54
} else if (base === "ubuntu2204") {
55
expect(ts.startsWith(short ?? "")).toBe(true);
56
}
57
break;
58
59
default:
60
expect(
61
["stable", "old", "exp", "previous", "default", ""].includes(base)
62
).toBe(true);
63
}
64
}
65
});
66
67