Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

update tests to cover excepted behaviour better

  • Loading branch information...
commit f2e5ac1717c437310b8a929653a78a8574a35a2b 1 parent 3134b61
@dominictarr authored
Showing with 11 additions and 6 deletions.
  1. +11 −6 test/multiple_objects.js
View
17 test/multiple_objects.js
@@ -6,25 +6,30 @@ var it = require('it-is');
var JSONStream = require('../');
var str = fs.readFileSync(file);
-var expected = JSON.parse(str);
+
+var datas = {}
var server = net.createServer(function(client) {
var root_calls = 0;
var data_calls = 0;
- var parser = JSONStream.parse();
+ var parser = JSONStream.parse(['rows', true, 'key']);
parser.on('root', function(root, count) {
++ root_calls;
});
parser.on('data', function(data) {
++ data_calls;
- it(data).deepEqual(expected)
+ datas[data] = (datas[data] || 0) + 1
+ it(data).typeof('string')
});
parser.on('end', function() {
- console.error('END');
+ console.log('END')
+ var min = Infinity
+ for (var d in datas)
+ min = min > datas[d] ? datas[d] : min
it(root_calls).equal(3);
- it(data_calls).equal(3);
+ it(min).equal(3);
server.close();
});
client.pipe(parser);
@@ -32,6 +37,6 @@ var server = net.createServer(function(client) {
server.listen(9999);
var client = net.connect({ port : 9999 }, function() {
- var msgs = [str, str, str].join('');
+ var msgs = str + ' ' + str + '\n\n' + str
client.end(msgs);
});
Please sign in to comment.
Something went wrong with that request. Please try again.