UNPKG

995 BPlain TextView Raw
1import * as fse from "fs-extra";
2import { expect } from "chai";
3import path from "./assert_path";
4import helper from "./helper";
5import * as jetpack from "..";
6
7describe("streams", () => {
8 beforeEach(helper.setCleanTestCwd);
9 afterEach(helper.switchBackToCorrectCwd);
10
11 it("exposes vanilla stream methods", done => {
12 fse.outputFileSync("a.txt", "abc");
13
14 const input = jetpack.createReadStream("a.txt");
15 const output = jetpack.createWriteStream("b.txt");
16 output.on("finish", () => {
17 path("b.txt").shouldBeFileWithContent("abc");
18 done();
19 });
20 input.pipe(output);
21 });
22
23 it("stream methods respect jetpack internal CWD", done => {
24 const dir = jetpack.cwd("dir");
25
26 fse.outputFileSync("dir/a.txt", "abc");
27
28 const input = dir.createReadStream("a.txt");
29 const output = dir.createWriteStream("b.txt");
30 output.on("finish", () => {
31 path("dir/b.txt").shouldBeFileWithContent("abc");
32 done();
33 });
34 input.pipe(output);
35 });
36});