Skip to content

Commit fb25ee1

Browse files
committed
Add tests for stream.pipe()
1 parent 717c809 commit fb25ee1

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

test/common.test.ts

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from 'chai';
2-
import { toStream, readToEnd, slice } from '@openpgp/web-stream-tools';
2+
// @ts-ignore Missing type definitions
3+
import { toStream, toArrayStream, readToEnd, slice, pipe, ArrayStream } from '@openpgp/web-stream-tools';
34

45
describe('Common integration tests', () => {
56
it('toStream/readToEnd', async () => {
@@ -13,5 +14,37 @@ describe('Common integration tests', () => {
1314
const streamedData = toStream(input);
1415
const slicedStream = slice(streamedData, 8);
1516
expect(await readToEnd(slicedStream)).to.equal('chunk');
16-
})
17-
})
17+
});
18+
19+
it('pipe from stream to stream', async () => {
20+
const input = 'chunk';
21+
const inputStream = toStream(input);
22+
const outputStream = new TransformStream();
23+
pipe(inputStream, outputStream.writable);
24+
expect(await readToEnd(outputStream.readable)).to.equal('chunk');
25+
});
26+
27+
it('pipe from stream to arraystream', async () => {
28+
const input = 'chunk';
29+
const inputStream = toStream(input);
30+
const outputStream = new ArrayStream();
31+
pipe(inputStream, outputStream);
32+
expect(await readToEnd(outputStream)).to.equal('chunk');
33+
});
34+
35+
it('pipe from arraystream to stream', async () => {
36+
const input = 'chunk';
37+
const inputStream = toArrayStream(input);
38+
const outputStream = new TransformStream();
39+
pipe(inputStream, outputStream.writable);
40+
expect(await readToEnd(outputStream.readable)).to.equal('chunk');
41+
});
42+
43+
it('pipe from arraystream to arraystream', async () => {
44+
const input = 'chunk';
45+
const inputStream = toArrayStream(input);
46+
const outputStream = new ArrayStream();
47+
pipe(inputStream, outputStream);
48+
expect(await readToEnd(outputStream)).to.equal('chunk');
49+
});
50+
});

0 commit comments

Comments
 (0)