mirror of https://git.tuxpa.in/a/code-server.git
Fix protocol fs test
This commit is contained in:
parent
c9f91e77cd
commit
0de7247868
|
@ -70,12 +70,12 @@ describe("fs", () => {
|
||||||
describe("chown", () => {
|
describe("chown", () => {
|
||||||
it("should chown existing file", async () => {
|
it("should chown existing file", async () => {
|
||||||
const file = await helper.createTmpFile();
|
const file = await helper.createTmpFile();
|
||||||
await expect(util.promisify(fs.chown)(file, 1, 1))
|
await expect(util.promisify(nativeFs.chown)(file, 1000, 1000))
|
||||||
.resolves.toBeUndefined();
|
.resolves.toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should fail to chown nonexistent file", async () => {
|
it("should fail to chown nonexistent file", async () => {
|
||||||
await expect(util.promisify(fs.chown)(helper.tmpFile(), 1, 1))
|
await expect(util.promisify(fs.chown)(helper.tmpFile(), 1000, 1000))
|
||||||
.rejects.toThrow("ENOENT");
|
.rejects.toThrow("ENOENT");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -198,13 +198,13 @@ describe("fs", () => {
|
||||||
it("should fchown existing file", async () => {
|
it("should fchown existing file", async () => {
|
||||||
const file = await helper.createTmpFile();
|
const file = await helper.createTmpFile();
|
||||||
const fd = await util.promisify(nativeFs.open)(file, "r");
|
const fd = await util.promisify(nativeFs.open)(file, "r");
|
||||||
await expect(util.promisify(fs.fchown)(fd, 1, 1))
|
await expect(util.promisify(fs.fchown)(fd, 1000, 1000))
|
||||||
.resolves.toBeUndefined();
|
.resolves.toBeUndefined();
|
||||||
await util.promisify(nativeFs.close)(fd);
|
await util.promisify(nativeFs.close)(fd);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should fail to fchown nonexistent file", async () => {
|
it("should fail to fchown nonexistent file", async () => {
|
||||||
await expect(util.promisify(fs.fchown)(99999, 1, 1))
|
await expect(util.promisify(fs.fchown)(99999, 1000, 1000))
|
||||||
.rejects.toThrow("EBADF");
|
.rejects.toThrow("EBADF");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -275,7 +275,7 @@ describe("fs", () => {
|
||||||
it("should futimes existing file", async () => {
|
it("should futimes existing file", async () => {
|
||||||
const file = await helper.createTmpFile();
|
const file = await helper.createTmpFile();
|
||||||
const fd = await util.promisify(nativeFs.open)(file, "w");
|
const fd = await util.promisify(nativeFs.open)(file, "w");
|
||||||
await expect(util.promisify(fs.futimes)(fd, 1, 1))
|
await expect(util.promisify(fs.futimes)(fd, 1000, 1000))
|
||||||
.resolves.toBeUndefined();
|
.resolves.toBeUndefined();
|
||||||
await util.promisify(nativeFs.close)(fd);
|
await util.promisify(nativeFs.close)(fd);
|
||||||
});
|
});
|
||||||
|
@ -311,12 +311,12 @@ describe("fs", () => {
|
||||||
describe("lchown", () => {
|
describe("lchown", () => {
|
||||||
it("should lchown existing file", async () => {
|
it("should lchown existing file", async () => {
|
||||||
const file = await helper.createTmpFile();
|
const file = await helper.createTmpFile();
|
||||||
await expect(util.promisify(fs.lchown)(file, 1, 1))
|
await expect(util.promisify(fs.lchown)(file, 1000, 1000))
|
||||||
.resolves.toBeUndefined();
|
.resolves.toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should fail to lchown nonexistent file", async () => {
|
it("should fail to lchown nonexistent file", async () => {
|
||||||
await expect(util.promisify(fs.lchown)(helper.tmpFile(), 1, 1))
|
await expect(util.promisify(fs.lchown)(helper.tmpFile(), 1000, 1000))
|
||||||
.rejects.toThrow("ENOENT");
|
.rejects.toThrow("ENOENT");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -621,7 +621,10 @@ describe("fs", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should dispose", () => {
|
it("should dispose", (done) => {
|
||||||
client.dispose();
|
setTimeout(() => {
|
||||||
|
client.dispose();
|
||||||
|
done();
|
||||||
|
}, 100);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,9 +27,10 @@ describe("spdlog", () => {
|
||||||
.toContain("critical");
|
.toContain("critical");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should dispose", () => {
|
it("should dispose", (done) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
client.dispose();
|
client.dispose();
|
||||||
|
done();
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,6 +3,8 @@ import * as util from "util";
|
||||||
import { Module } from "../src/common/proxy";
|
import { Module } from "../src/common/proxy";
|
||||||
import { createClient, Helper } from "./helpers";
|
import { createClient, Helper } from "./helpers";
|
||||||
|
|
||||||
|
// tslint:disable deprecation to use fs.exists
|
||||||
|
|
||||||
describe("trash", () => {
|
describe("trash", () => {
|
||||||
const client = createClient();
|
const client = createClient();
|
||||||
const trash = client.modules[Module.Trash];
|
const trash = client.modules[Module.Trash];
|
||||||
|
@ -18,9 +20,10 @@ describe("trash", () => {
|
||||||
expect(await util.promisify(fs.exists)(file)).toBeFalsy();
|
expect(await util.promisify(fs.exists)(file)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should dispose", () => {
|
it("should dispose", (done) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
client.dispose();
|
client.dispose();
|
||||||
|
done();
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,3 +21,15 @@ Object.defineProperty(fs.read, util.promisify.custom, {
|
||||||
global.requestAnimationFrame = (cb) => {
|
global.requestAnimationFrame = (cb) => {
|
||||||
setTimeout(cb, 0);
|
setTimeout(cb, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// lchmod might not be available. Jest runs graceful-fs which makes this a no-op
|
||||||
|
// when it doesn't exist but that doesn't seem to always run when running
|
||||||
|
// multiple tests (or maybe it gets undone after a test).
|
||||||
|
if (!fs.lchmod) {
|
||||||
|
fs.lchmod = function (path, mode, cb) {
|
||||||
|
if (cb) {
|
||||||
|
process.nextTick(cb);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fs.lchmodSync = function () {};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue