Archived
1
0
This repository has been archived on 2024-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
code-server/packages/server/test/evaluate.test.ts
2019-02-05 11:15:44 -06:00

39 lines
898 B
TypeScript

import { createClient } from "./helpers";
describe("Evaluate", () => {
const client = createClient();
it("should transfer string", async () => {
const value = await client.evaluate(function () {
return "hi";
});
expect(value).toEqual("hi");
}, 100);
it("should compute from object", async () => {
const value = await client.evaluate((arg) => {
return arg.bananas * 2;
}, { bananas: 1 });
expect(value).toEqual(2);
}, 100);
it("should transfer object", async () => {
const value = await client.evaluate(() => {
return { alpha: "beta" };
});
expect(value.alpha).toEqual("beta");
}, 100);
it("should require", async () => {
const value = await client.evaluate(() => {
const fs = require("fs") as typeof import("fs");
return Object.keys(fs).filter((f) => f === "readFileSync");
});
expect(value[0]).toEqual("readFileSync");
}, 100);
});