@@ -3,32 +3,27 @@ var concat = require('concat-stream');
33var test = require ( 'tape' ) ;
44var fs = require ( 'fs' ) ;
55
6- test ( 'one chunk of compressed data piped into unbzip2-stream results in original file content ' , function ( t ) {
6+ test ( 'accepts data in both write and end ' , function ( t ) {
77 t . plan ( 1 ) ;
88 var compressed = fs . readFileSync ( 'test/fixtures/text.bz2' ) ;
99 var unbz2 = unbzip2Stream ( ) ;
1010 unbz2 . pipe ( concat ( function ( data ) {
1111 var expected = "Hello World!\nHow little you are. now.\n\n" ;
1212 t . equal ( data . toString ( 'utf-8' ) , expected ) ;
1313 } ) ) ;
14-
15- unbz2 . write ( compressed ) ;
16- unbz2 . end ( ) ;
17-
14+ unbz2 . write ( compressed . subarray ( 0 , 4 ) ) ;
15+ unbz2 . end ( compressed . subarray ( 4 ) ) ;
1816} ) ;
1917
20- test ( 'concatenated bz2 streams piped into unbzip2-stream results in original file content ' , function ( t ) {
18+ test ( 'accepts concatenated bz2 streams' , function ( t ) {
2119 t . plan ( 1 ) ;
2220 var compressed = fs . readFileSync ( 'test/fixtures/concatenated.bz2' ) ;
2321 var unbz2 = unbzip2Stream ( ) ;
2422 unbz2 . pipe ( concat ( function ( data ) {
2523 var expected = "ab\n" ;
2624 t . equal ( data . toString ( 'utf-8' ) , expected ) ;
2725 } ) ) ;
28-
29- unbz2 . write ( compressed ) ;
30- unbz2 . end ( ) ;
31-
26+ unbz2 . end ( compressed ) ;
3227} ) ;
3328
3429test ( 'should emit error when stream is broken' , function ( t ) {
@@ -42,10 +37,7 @@ test('should emit error when stream is broken', function(t) {
4237 var expected = "Hello World!\nHow little you are. now.\n\n" ;
4338 t . ok ( false , 'we should not get here' ) ;
4439 } ) ) ;
45-
46- unbz2 . write ( compressed ) ;
47- unbz2 . end ( ) ;
48-
40+ unbz2 . end ( compressed ) ;
4941} ) ;
5042
5143test ( 'should emit error when crc is broken' , function ( t ) {
@@ -59,10 +51,7 @@ test('should emit error when crc is broken', function(t) {
5951 var expected = "Hello World!\nHow little you are. now.\n\n" ;
6052 t . ok ( false , 'we should not get here' ) ;
6153 } ) ) ;
62-
63- unbz2 . write ( compressed ) ;
64- unbz2 . end ( ) ;
65-
54+ unbz2 . end ( compressed ) ;
6655} ) ;
6756
6857test ( 'should emit error when stream is broken in a different way?' , function ( t ) {
@@ -77,7 +66,5 @@ test('should emit error when stream is broken in a different way?', function(t)
7766 unbz2 . on ( 'close' , function ( err ) {
7867 t . ok ( false , "Should not reach end of stream without failing." ) ;
7968 } ) ;
80-
81- unbz2 . write ( truncated ) ;
82- unbz2 . end ( ) ;
69+ unbz2 . end ( truncated ) ;
8370} ) ;
0 commit comments