[Pkg-javascript-commits] [node-jsonstream] 36/214: new fn test from copying test.js and changing the regex to a function, presently fails

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 2fb5d39e7727437b8cafa81baadd4d61234868b0
Author: James Halliday <mail at substack.net>
Date:   Thu Jun 14 04:02:44 2012 -0700

    new fn test from copying test.js and changing the regex to a function, presently fails
---
 test/fn.js | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/test/fn.js b/test/fn.js
new file mode 100644
index 0000000..4acc672
--- /dev/null
+++ b/test/fn.js
@@ -0,0 +1,39 @@
+
+
+var fs = require ('fs')
+  , join = require('path').join
+  , file = join(__dirname, 'fixtures','all_npm.json')
+  , JSONStream = require('../')
+  , it = require('it-is')
+
+function fn (s) {
+  return !isNaN(parseInt(s, 10))
+}
+
+var expected = JSON.parse(fs.readFileSync(file))
+  , parser = JSONStream.parse(['rows', fn])
+  , called = 0
+  , ended = false
+  , parsed = []
+
+fs.createReadStream(file).pipe(parser)
+  
+parser.on('data', function (data) {
+  called ++
+  it.has({
+    id: it.typeof('string'),
+    value: {rev: it.typeof('string')},
+    key:it.typeof('string')
+  })
+  parsed.push(data)
+})
+
+parser.on('end', function () {
+  ended = true
+})
+
+process.on('exit', function () {
+  it(called).equal(expected.rows.length)
+  it(parsed).deepEqual(expected.rows)
+  console.error('PASSED')
+})

-- 
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