@@ -21,11 +21,12 @@ var Chunker = require('../../lib/v1/internal/chunking').Chunker;
21
21
var Dechunker = require ( '../../lib/v1/internal/chunking' ) . Dechunker ;
22
22
var alloc = require ( '../../lib/v1/internal/buf' ) . alloc ;
23
23
var CombinedBuffer = require ( '../../lib/v1/internal/buf' ) . CombinedBuffer ;
24
+ var DummyChannel = require ( '../../lib/v1/internal/ch-dummy.js' ) . channel ;
24
25
25
26
describe ( 'Chunker' , function ( ) {
26
27
it ( 'should chunk simple data' , function ( ) {
27
28
// Given
28
- var ch = new TestChannel ( ) ;
29
+ var ch = new DummyChannel ( ) ;
29
30
var chunker = new Chunker ( ch ) ;
30
31
31
32
// When
@@ -38,7 +39,7 @@ describe('Chunker', function() {
38
39
} ) ;
39
40
it ( 'should chunk blobs larger than the output buffer' , function ( ) {
40
41
// Given
41
- var ch = new TestChannel ( ) ;
42
+ var ch = new DummyChannel ( ) ;
42
43
var chunker = new Chunker ( ch , 4 ) ;
43
44
44
45
// When
@@ -50,7 +51,7 @@ describe('Chunker', function() {
50
51
} ) ;
51
52
it ( 'should include message boundaries' , function ( ) {
52
53
// Given
53
- var ch = new TestChannel ( ) ;
54
+ var ch = new DummyChannel ( ) ;
54
55
var chunker = new Chunker ( ch ) ;
55
56
56
57
// When
@@ -87,7 +88,7 @@ describe('Dechunker', function() {
87
88
88
89
it ( 'should handle message split at any point' , function ( ) {
89
90
// Given
90
- var ch = new TestChannel ( ) ;
91
+ var ch = new DummyChannel ( ) ;
91
92
var chunker = new Chunker ( ch ) ;
92
93
93
94
// And given the following message
@@ -121,34 +122,6 @@ describe('Dechunker', function() {
121
122
} ) ;
122
123
} ) ;
123
124
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
-
152
125
function bytes ( ) {
153
126
var b = alloc ( arguments . length ) ;
154
127
for ( var i = 0 ; i < arguments . length ; i ++ ) {
0 commit comments