1
0
mirror of https://github.com/coder/code-server.git synced 2024-12-04 15:00:38 +08:00
code-server/packages/protocol/test/spdlog.test.ts

37 lines
970 B
TypeScript
Raw Normal View History

import * as fs from "fs";
import * as util from "util";
import { Module } from "../src/common/proxy";
import { createClient, Helper } from "./helpers";
describe("spdlog", () => {
const client = createClient();
const spdlog = client.modules[Module.Spdlog];
const helper = new Helper("spdlog");
beforeAll(async () => {
await helper.prepare();
});
it("should log to a file", async () => {
const file = await helper.createTmpFile();
const logger = new spdlog.RotatingLogger("test logger", file, 10000, 10);
logger.trace("trace");
logger.debug("debug");
logger.info("info");
logger.warn("warn");
logger.error("error");
logger.critical("critical");
logger.flush();
await new Promise((resolve): number | NodeJS.Timer => setTimeout(resolve, 1000));
expect(await util.promisify(fs.readFile)(file, "utf8"))
.toContain("critical");
});
2019-04-25 07:15:56 +08:00
it("should dispose", (done) => {
setTimeout(() => {
client.dispose();
2019-04-25 07:15:56 +08:00
done();
}, 100);
});
});