forked from flickr/yakbak
-
Notifications
You must be signed in to change notification settings - Fork 1
/
buffer.js
45 lines (35 loc) · 1014 Bytes
/
buffer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2016 Yahoo Inc.
// Licensed under the terms of the MIT license. Please see LICENSE file in the project root for terms.
/* eslint-env mocha */
var subject = require('../lib/buffer');
var stream = require('stream');
var assert = require('assert');
describe('buffer', function () {
it('yields the stream contents', function (done) {
var str = new stream.PassThrough;
subject(str).then(function (body) {
assert.deepEqual(body, [
new Buffer('a'),
new Buffer('b'),
new Buffer('c')
]);
done();
}).catch(function (err) {
done(err);
});
str.write('a');
str.write('b');
str.write('c');
str.end();
});
it('yields an error', function (done) {
var str = new stream.PassThrough;
subject(str).then(function () {
done(new Error('should have yielded an error'));
}).catch(function (err) {
assert.equal(err.message, 'boom');
done();
});
str.emit('error', new Error('boom'));
});
});