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/backend/get-listing.test.ts
Views: 687
1
import getListing from "./get-listing";
2
3
test("it gets a directory listing", async () => {
4
const listing = await getListing(".");
5
// we just check that each entry has name, mtime and size properties.
6
// it's getting $HOME so there's not much more we can do in general.
7
for (const entry of listing) {
8
// check properties
9
expect(entry).toHaveProperty("name");
10
expect(entry).toHaveProperty("mtime");
11
expect(entry).toHaveProperty("size");
12
13
// check something about types
14
expect(typeof entry.name).toBe("string");
15
expect(typeof entry.mtime).toBe("number");
16
expect(typeof entry.size).toBe("number");
17
}
18
});
19
20