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/project/jupyter/test/basic.ts
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import expect from "expect";
7
8
import { kernel, exec, JupyterKernel } from "./common";
9
10
describe("compute 2+3 using python2", function () {
11
this.timeout(10000);
12
let k: JupyterKernel;
13
14
it("creates a python2 kernel", function () {
15
k = kernel("test-python2");
16
});
17
18
it("spawn", async function () {
19
await k.spawn();
20
expect(k.get_state()).toBe("running");
21
});
22
23
it("evaluate 2+3", async function () {
24
expect(await exec(k, "2+3")).toEqual('{"text/plain":"5"}');
25
});
26
27
it("closes the kernel", function () {
28
k.close();
29
expect(k.get_state()).toBe("closed");
30
});
31
});
32
33
describe("compute 2/3 using python3", function () {
34
this.timeout(10000);
35
let k: JupyterKernel;
36
37
it("creates a python3 kernel", function () {
38
k = kernel("test-python3");
39
});
40
41
it("spawn", async function () {
42
await k.spawn();
43
expect(k.get_state()).toBe("running");
44
});
45
46
it("evaluate 2/3", async function () {
47
expect(await exec(k, "2/3")).toEqual('{"text/plain":"0.6666666666666666"}');
48
});
49
50
it("closes the kernel", function () {
51
k.close();
52
expect(k.get_state()).toBe("closed");
53
});
54
});
55
56