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/next/lib/landing/landing.test.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { toPairs } from "lodash";
7
8
import { SOFTWARE_ENV_NAMES } from "@cocalc/util/consts/software-envs";
9
import { SOFTWARE_FALLBACK, SOFTWARE_URLS } from "./software-data";
10
import { EnvData } from "./types";
11
12
test("3 known software environments", () => {
13
expect(SOFTWARE_ENV_NAMES.length).toBe(3);
14
});
15
16
describe("Download URLs", () => {
17
it.each(toPairs(SOFTWARE_URLS))("check %s", async (name, url) => {
18
// TODO: jest can't use fetch? well, we just check the URLs
19
expect(url.startsWith("https://")).toBe(true);
20
expect(url.endsWith(`/software-inventory-${name}.json`)).toBe(true);
21
// const response = await fetch(url);
22
// expect(response.status).toBe(200);
23
// const spec = await response.json();
24
// checkSoftwareSpec(spec as any);
25
});
26
27
it.each(toPairs(SOFTWARE_FALLBACK))(
28
"check fallback %s",
29
(_, fallbackSpec) => {
30
checkSoftwareSpec(fallbackSpec);
31
}
32
);
33
});
34
35
function checkSoftwareSpec(spec: EnvData) {
36
// check that data has the expected structure
37
expect(spec.timestamp).toBeTruthy();
38
const inventory = spec.inventory;
39
expect(inventory).toBeTruthy();
40
expect(inventory.julia).toBeTruthy();
41
expect(inventory.language_exes).toBeTruthy();
42
expect(inventory.octave).toBeTruthy();
43
expect(inventory.python).toBeTruthy();
44
expect(inventory.R).toBeTruthy();
45
const data = spec.data;
46
expect(data).toBeTruthy();
47
expect(data.executables).toBeTruthy();
48
expect(data.julia).toBeTruthy();
49
expect(data.octave).toBeTruthy();
50
expect(data.python).toBeTruthy();
51
expect(data.R).toBeTruthy();
52
}
53
54