项目原始demo,不改动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

28 line
909 B

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