Permalink
Browse files

Add test to cancel replication

  • Loading branch information...
1 parent c0824b5 commit 101d468f4f8d1242cddc32ed6550e5e0b32b21ec @daleharvey committed May 5, 2012
Showing with 28 additions and 0 deletions.
  1. +28 −0 tests/test.replication.js
View
@@ -208,3 +208,31 @@ asyncTest("Test basic continous push replication", function() {
});
});
});
+
+asyncTest("Test cancel pull replication", function() {
+ var self = this;
+ var doc1 = {_id: 'adoc', foo:'bar'};
+ initDBPair(this.name, this.remote, function(db, remote) {
+ remote.bulkDocs({docs: docs}, {}, function(err, results) {
+ var count = 0;
+ var rep = db.replicate.from(self.remote, {continuous: true});
+ var change = db.changes({
+ onChange: function(change) {
+ ++count;
+ if (count === 4) {
+ rep.cancel();
+ remote.put(doc2);
+ setTimeout(function() {
+ ok(count === 4, 'got no more docs');
+ start();
+ }, 500);
+ }
+ },
+ continuous: true,
+ });
+ setTimeout(function() {
+ remote.put(doc1);
+ }, 50);
+ });
+ });
+});

0 comments on commit 101d468

Please sign in to comment.