2019-03-26 18:01:25 +00:00
|
|
|
import * as fs from "fs";
|
|
|
|
import * as util from "util";
|
|
|
|
import { Module } from "../src/common/proxy";
|
|
|
|
import { createClient, Helper } from "./helpers";
|
|
|
|
|
2019-04-24 23:15:56 +00:00
|
|
|
// tslint:disable deprecation to use fs.exists
|
|
|
|
|
2019-03-26 18:01:25 +00:00
|
|
|
describe("trash", () => {
|
|
|
|
const client = createClient();
|
|
|
|
const trash = client.modules[Module.Trash];
|
|
|
|
const helper = new Helper("trash");
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
await helper.prepare();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should trash a file", async () => {
|
|
|
|
const file = await helper.createTmpFile();
|
|
|
|
await trash.trash(file);
|
|
|
|
expect(await util.promisify(fs.exists)(file)).toBeFalsy();
|
|
|
|
});
|
|
|
|
|
2019-04-24 23:15:56 +00:00
|
|
|
it("should dispose", (done) => {
|
2019-03-26 18:01:25 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
client.dispose();
|
2019-04-24 23:15:56 +00:00
|
|
|
done();
|
2019-03-26 18:01:25 +00:00
|
|
|
}, 100);
|
|
|
|
});
|
|
|
|
});
|