1
|
var path = require('path');
|
2
|
var test = require('tape');
|
3
|
var Buffer = require('safe-buffer').Buffer;
|
4
|
|
5
|
var Writable = require('../').Writable;
|
6
|
var inherits = require('inherits');
|
7
|
|
8
|
inherits(TestWritable, Writable);
|
9
|
|
10
|
function TestWritable(opt) {
|
11
|
if (!(this instanceof TestWritable))
|
12
|
return new TestWritable(opt);
|
13
|
Writable.call(this, opt);
|
14
|
this._written = [];
|
15
|
}
|
16
|
|
17
|
TestWritable.prototype._write = function(chunk, encoding, cb) {
|
18
|
this._written.push(chunk);
|
19
|
cb();
|
20
|
};
|
21
|
|
22
|
var buf = Buffer.from([ 88 ]);
|
23
|
|
24
|
test('.writable writing ArrayBuffer', function(t) {
|
25
|
var writable = new TestWritable();
|
26
|
|
27
|
writable.write(buf);
|
28
|
writable.end();
|
29
|
|
30
|
t.equal(writable._written.length, 1);
|
31
|
t.equal(writable._written[0].toString(), 'X')
|
32
|
t.end()
|
33
|
});
|