@@ -21,11 +21,12 @@ var Chunker = require('../../lib/v1/internal/chunking').Chunker;
2121var Dechunker = require ( '../../lib/v1/internal/chunking' ) . Dechunker ;
2222var alloc = require ( '../../lib/v1/internal/buf' ) . alloc ;
2323var CombinedBuffer = require ( '../../lib/v1/internal/buf' ) . CombinedBuffer ;
24+ var DummyChannel = require ( '../../lib/v1/internal/ch-dummy.js' ) . channel ;
2425
2526describe ( 'Chunker' , function ( ) {
2627 it ( 'should chunk simple data' , function ( ) {
2728 // Given
28- var ch = new TestChannel ( ) ;
29+ var ch = new DummyChannel ( ) ;
2930 var chunker = new Chunker ( ch ) ;
3031
3132 // When
@@ -38,7 +39,7 @@ describe('Chunker', function() {
3839 } ) ;
3940 it ( 'should chunk blobs larger than the output buffer' , function ( ) {
4041 // Given
41- var ch = new TestChannel ( ) ;
42+ var ch = new DummyChannel ( ) ;
4243 var chunker = new Chunker ( ch , 4 ) ;
4344
4445 // When
@@ -50,7 +51,7 @@ describe('Chunker', function() {
5051 } ) ;
5152 it ( 'should include message boundaries' , function ( ) {
5253 // Given
53- var ch = new TestChannel ( ) ;
54+ var ch = new DummyChannel ( ) ;
5455 var chunker = new Chunker ( ch ) ;
5556
5657 // When
@@ -87,7 +88,7 @@ describe('Dechunker', function() {
8788
8889 it ( 'should handle message split at any point' , function ( ) {
8990 // Given
90- var ch = new TestChannel ( ) ;
91+ var ch = new DummyChannel ( ) ;
9192 var chunker = new Chunker ( ch ) ;
9293
9394 // And given the following message
@@ -121,34 +122,6 @@ describe('Dechunker', function() {
121122 } ) ;
122123} ) ;
123124
124- function TestChannel ( ) {
125- this . _written = [ ] ;
126- }
127-
128- TestChannel . prototype . write = function ( buf ) {
129- this . _written . push ( buf ) ;
130- } ;
131-
132- TestChannel . prototype . toHex = function ( ) {
133- var out = "" ;
134- for ( var i = 0 ; i < this . _written . length ; i ++ ) {
135- out += this . _written [ i ] . toHex ( ) ;
136- }
137- return out ;
138- } ;
139-
140- TestChannel . prototype . toBuffer = function ( ) {
141- return new CombinedBuffer ( this . _written ) ;
142- } ;
143-
144- TestChannel . prototype . toHex = function ( ) {
145- var out = "" ;
146- for ( var i = 0 ; i < this . _written . length ; i ++ ) {
147- out += this . _written [ i ] . toHex ( ) ;
148- }
149- return out ;
150- } ;
151-
152125function bytes ( ) {
153126 var b = alloc ( arguments . length ) ;
154127 for ( var i = 0 ; i < arguments . length ; i ++ ) {
0 commit comments