1
1
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' ;
3
4
4
5
describe ( 'Common integration tests' , ( ) => {
5
6
it ( 'toStream/readToEnd' , async ( ) => {
@@ -13,5 +14,37 @@ describe('Common integration tests', () => {
13
14
const streamedData = toStream ( input ) ;
14
15
const slicedStream = slice ( streamedData , 8 ) ;
15
16
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