Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
test expected values more exaustively, error on count = 0
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Feb 22, 2012
1 parent d01ab32 commit c3292a7
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions test/stringify_object.js
Expand Up @@ -4,6 +4,9 @@ var fs = require ('fs')
, file = join(__dirname, 'fixtures','all_npm.json')
, JSONStream = require('../')
, it = require('it-is').style('colour')
, es = require('event-stream')
, pending = 10
, passed = true

function randomObj () {
return (
Expand All @@ -18,26 +21,26 @@ var fs = require ('fs')
)
}

var expected = {}
, stringify = JSONStream.stringifyObject()
, es = require('event-stream')
, stringified = ''
, called = 0
, count = 10
, ended = false

es.connect(
stringify,
es.writeArray(function (err, lines) {
it(JSON.parse(lines.join(''))).deepEqual(expected)
console.error('PASSED')
})
)
for (var ix = 0; ix < pending; ix++) (function (count) {
var expected = {}
, stringify = JSONStream.stringifyObject()

es.connect(
stringify,
es.writeArray(function (err, lines) {
it(JSON.parse(lines.join(''))).deepEqual(expected)
console.log(pending);
if (--pending === 0) {
console.error('PASSED')
}
})
)

while (count --) {
var key = Math.random().toString(16).slice(2)
expected[key] = randomObj()
stringify.write([ key, expected[key] ])
}
while (count --) {
var key = Math.random().toString(16).slice(2)
expected[key] = randomObj()
stringify.write([ key, expected[key] ])
}

stringify.end()
stringify.end()
})(ix)

0 comments on commit c3292a7

Please sign in to comment.