forked from coder/code-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequirefs.test.ts
More file actions
56 lines (46 loc) · 1.42 KB
/
requirefs.test.ts
File metadata and controls
56 lines (46 loc) · 1.42 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
import { RequireFS } from "../src/requirefs";
import { TestCaseArray, isMac } from "./requirefs.util";
const toTest = new TestCaseArray();
describe("requirefs", () => {
for (let i = 0; i < toTest.length(); i++) {
const testCase = toTest.byID(i);
if (!isMac && testCase.name === "gtar") {
break;
}
if (isMac && testCase.name === "tar") {
break;
}
describe(testCase.name, () => {
let rfs: RequireFS;
beforeAll(async () => {
rfs = await testCase.rfs;
});
it("should parse individual module", () => {
expect(rfs.require("./individual.js").frog).toEqual("hi");
});
it("should parse chained modules", () => {
expect(rfs.require("./chained-1").text).toEqual("moo");
});
it("should parse through subfolders", () => {
expect(rfs.require("./subfolder").orangeColor).toEqual("blue");
});
it("should be able to move up directories", () => {
expect(rfs.require("./subfolder/goingUp").frog).toEqual("hi");
});
it("should resolve node_modules", () => {
expect(rfs.require("./nodeResolve").banana).toEqual("potato");
});
it("should access global scope", () => {
// tslint:disable-next-line no-any for testing
(window as any).coder = {
test: "hi",
};
expect(rfs.require("./scope")).toEqual("hi");
});
it("should find custom module", () => {
rfs.provide("donkey", "ok");
expect(rfs.require("./customModule")).toEqual("ok");
});
});
}
});