Swap-Aggregator-Subgraph/node_modules/fs-jetpack/spec/streams.spec.ts
Richa-iitr d211083153 Revert "Revert "added handler""
This reverts commit c36ee8c5ca.
2022-07-03 07:30:05 +05:30

37 lines
995 B
TypeScript

import * as fse from "fs-extra";
import { expect } from "chai";
import path from "./assert_path";
import helper from "./helper";
import * as jetpack from "..";
describe("streams", () => {
beforeEach(helper.setCleanTestCwd);
afterEach(helper.switchBackToCorrectCwd);
it("exposes vanilla stream methods", done => {
fse.outputFileSync("a.txt", "abc");
const input = jetpack.createReadStream("a.txt");
const output = jetpack.createWriteStream("b.txt");
output.on("finish", () => {
path("b.txt").shouldBeFileWithContent("abc");
done();
});
input.pipe(output);
});
it("stream methods respect jetpack internal CWD", done => {
const dir = jetpack.cwd("dir");
fse.outputFileSync("dir/a.txt", "abc");
const input = dir.createReadStream("a.txt");
const output = dir.createWriteStream("b.txt");
output.on("finish", () => {
path("dir/b.txt").shouldBeFileWithContent("abc");
done();
});
input.pipe(output);
});
});