Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add a test for changes eventsource feed.

  • Loading branch information...
commit b510382e7a23cc26a3f4c0f42f22a56b6c3e8a11 1 parent 227a31c
@benoitc benoitc authored
Showing with 28 additions and 0 deletions.
  1. +28 −0 apps/couch_httpd/share/www/script/test/changes.js
View
28 apps/couch_httpd/share/www/script/test/changes.js
@@ -139,6 +139,34 @@ couchTests.changes = function(debug) {
// otherwise we'll continue to receive heartbeats forever
xhr.abort();
+
+ if (window.EventSource) {
+ var source = new EventSource(
+ "/test_suite_db/_changes?feed=eventsource");
+ var results = [];
+ var sourceListener = function(e) {
+ var data = JSON.parse(e.data);
+ results.push(data);
+
+ };
+
+ source.addEventListener('message', sourceListener , false);
+
+ waitForSuccess(function() {
+ if (results.length != 3)
+ throw "bad seq, try again";
+ });
+
+ source.removeEventListener('message', sourceListener, false);
+
+ T(results[0].seq == 1);
+ T(results[0].id == "foo");
+
+ T(results[1].seq == 2);
+ T(results[1].id == "bar");
+ T(results[1].changes[0].rev == docBar._rev);
+ }
+
// test longpolling
xhr = CouchDB.newXhr();
Please sign in to comment.
Something went wrong with that request. Please try again.