[Pkg-javascript-commits] [node-jsonstream] 31/214: failing test for empty results

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 1 12:58:35 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-jsonstream.

commit 21e76cb7b1b663e712a6e705cb8f74f220ee2ccf
Author: James Halliday <mail at substack.net>
Date:   Wed Jun 13 17:39:12 2012 -0700

    failing test for empty results
---
 test/empty.js | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/test/empty.js b/test/empty.js
new file mode 100644
index 0000000..19e888c
--- /dev/null
+++ b/test/empty.js
@@ -0,0 +1,44 @@
+var JSONStream = require('../')
+  , stream = require('stream')
+  , it = require('it-is')
+
+var output = [ [], [] ]
+
+var parser1 = JSONStream.parse(['docs', /./])
+parser1.on('data', function(data) {
+  output[0].push(data)
+})
+
+var parser2 = JSONStream.parse(['docs', /./])
+parser2.on('data', function(data) {
+  output[1].push(data)
+})
+
+var pending = 2
+function onend () {
+  if (--pending > 0) return
+  it(output).deepEqual([
+    [], [{hello: 'world'}]
+  ])
+  console.error('PASSED')
+}
+parser1.on('end', onend)
+parser2.on('end', onend)
+
+function makeReadableStream() {
+  var readStream = new stream.Stream()
+  readStream.readable = true
+  readStream.write = function (data) { this.emit('data', data) }
+  readStream.end = function (data) { this.emit('end') }
+  return readStream
+}
+
+var emptyArray = makeReadableStream()
+emptyArray.pipe(parser1)
+emptyArray.write('{"docs":[]}')
+emptyArray.end()
+
+var objectArray = makeReadableStream()
+objectArray.pipe(parser2)
+objectArray.write('{"docs":[{"hello":"world"}]}')
+objectArray.end()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-jsonstream.git



More information about the Pkg-javascript-commits mailing list