Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

failing test for stringifyObject

  • Loading branch information...
commit bfbf5ccbc2777febf53162d1bc7816fab5e88982 1 parent 446562f
@substack authored
Showing with 37 additions and 2 deletions.
  1. +2 −2 index.js
  2. +35 −0 test/object.js
View
4 index.js
@@ -1,4 +1,4 @@
-var sjson = require('JSONStream');
+var JSONStream = require('JSONStream');
var traverse = require('traverse');
var BufferedStream = require('morestreams').BufferedStream;
var EventEmitter = require('events').EventEmitter;
@@ -62,7 +62,7 @@ module.exports = function (obj) {
pop();
}
else {
- var s = sjson.stringify();
+ var s = JSONStream.stringify();
s.on('data', function (buf) {
output.emit('data', buf);
});
View
35 test/object.js
@@ -0,0 +1,35 @@
+var gutter = require('../');
+var test = require('tap').test;
+
+var EventEmitter = require('events').EventEmitter;
+
+test('object stream', function (t) {
+ t.plan(1);
+
+ var ev = new EventEmitter;
+ var i = 0;
+ var iv = setInterval(function () {
+ if (++i === 5) {
+ clearInterval(iv);
+ ev.emit('end');
+ }
+ else ev.emit('data', [ String.fromCharCode(i + 97), i ])
+ }, 10);
+
+ var s = gutter([
+ 'foo', 5, 'bar', { baz : ev }
+ ]);
+
+ var data = '';
+ s.on('data', function (buf) {
+ data += buf;
+ });
+
+ s.on('end', function () {
+ t.deepEqual(
+ JSON.parse(data),
+ [ 'foo', 5, 'bar', { baz : { a : 1, b : 2 } } ]
+ );
+ t.end();
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.