UNPKG

909 BJavaScriptView Raw
1'use strict';
2
3var assert = require('assert');
4var stream = require('stream');
5var hash = require('../index');
6
7describe('writeToStream', function() {
8 it('should emit information about an object to a stream', function() {
9 var strm = new stream.PassThrough();
10
11 hash.writeToStream({foo: 'bar'}, strm);
12 var result = strm.read().toString();
13 assert.strictEqual(typeof result, 'string');
14 assert.notStrictEqual(result.indexOf('foo'), -1);
15 assert.notStrictEqual(result.indexOf('bar'), -1);
16 });
17
18 it('should leave out keys when excludeValues = true', function() {
19 var strm = new stream.PassThrough();
20
21 hash.writeToStream({foo: 'bar'}, {excludeValues: true}, strm);
22 var result = strm.read().toString();
23 assert.strictEqual(typeof result, 'string');
24 assert.notStrictEqual(result.indexOf('foo'), -1);
25 assert. strictEqual(result.indexOf('bar'), -1);
26 });
27});