1
0
mirror of https://git.tuxpa.in/a/code-server.git synced 2024-12-26 20:25:25 +00:00
code-server-2/packages/requirefs/test/requirefs.test.ts
2019-02-05 11:15:42 -06:00

57 lines
1.4 KiB
TypeScript

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");
});
});
}
});