Permalink
Browse files

[test] Add a test for throwing in `data` handler

  • Loading branch information...
1 parent aa904b7 commit 209598f9a836da59739aed6c0d105899b3fa79d9 @mmalecki committed Nov 24, 2012
Showing with 15 additions and 1 deletion.
  1. +1 −1 package.json
  2. +14 −0 test/throw-in-data-handler-test.js
View
@@ -5,6 +5,6 @@
"author": "Maciej Małecki <me@mmalecki.com>",
"main": "./lib/json-stream",
"scripts": {
- "test": "node test/pipe-test.js && node test/json-stream-test.js"
+ "test": "node test/pipe-test.js && node test/json-stream-test.js && node test/throw-in-data-handler-test.js"
}
}
@@ -0,0 +1,14 @@
+var assert = require('assert'),
+ jsonStream = require('../');
+
+var stream = jsonStream();
+
+stream.on('data', function (chunk) {
+ throw new Error('Error');
+});
+
+assert.throws(function () {
+ stream.write(JSON.stringify({ a: 42 }) + '\n');
+});
+
+stream.end();

0 comments on commit 209598f

Please sign in to comment.