Skip to content
Browse files

added back stream end handling through event emitter

  • Loading branch information...
1 parent bf14bb2 commit 8921db0fe0740059eef92bba0f71b1d95b43e218 Florian Traverse committed Feb 18, 2011
Showing with 40 additions and 35 deletions.
  1. +40 −35 vows/changes-test.js
View
75 vows/changes-test.js
@@ -1,39 +1,44 @@
-// var vows = require('vows'),
-// assert = require('assert'),
-// couchdb = require('../lib/couchdb');
-//
-// var client = couchdb.createClient(),
-// db = client.db('node-couchdb-test');
-//
-// vows.
-// describe('db').
-// addBatch({
-// 'changesStream': {
-// topic: function() {
-// var callback = this.callback;
-// db.remove(function() {
-// db.create(function() {
-// var stream = db.changesStream();
-// stream.addListener('data', function(change) {
-// stream.close();
-// callback(null, change);
-// });
-// db.saveDoc({test: 1});
-// });
-// });
-// },
-//
-// 'should allow retrieving changes through listeners': function(err, response) {
-// console.log(response);
-// }
-// }
-// }).
-// export(module);
+ var vows = require('vows'),
+ assert = require('assert'),
+ couchdb = require('../lib/couchdb');
+
+ var client = couchdb.createClient(),
+ db = client.db('node-couchdb-test');
-
- // .addListener('end', function() {
- // callbacks.C = true;
- // })
+ var stream;
+ vows.
+ describe('db').
+ addBatch({
+ 'changesStream': {
+ topic: function() {
+ var callback= this.callback;
+ db.remove(function() {
+ db.create(function() {
+ stream = db.changesStream();
+
+ stream.addListener('data', function(changes){callback(null,changes)});
+
+ db.saveDoc({test: 1});
+ });
+ });
+ },
+
+ 'should allow retrieving changes through listeners': function(err,response) {
+ console.log(typeof response);
+ assert.isObject(response);
+ assert.isTrue(response.seq == 1);
+ },
+ 'should terminate': { topic: function(err) {
+ stream.addListener('end', this.callback).close();
+ },
+ 'when streams end, with no error': function(error) {
+ assert.isFalse(error);
+ }
+ }
+ }
+ }).
+ export(module);
+
// db.remove();

0 comments on commit 8921db0

Please sign in to comment.
Something went wrong with that request. Please try again.