summaryrefslogtreecommitdiff
path: root/share/www/script/test/list_views.js
diff options
context:
space:
mode:
Diffstat (limited to 'share/www/script/test/list_views.js')
-rw-r--r--share/www/script/test/list_views.js36
1 files changed, 31 insertions, 5 deletions
diff --git a/share/www/script/test/list_views.js b/share/www/script/test/list_views.js
index de593035..a25eed30 100644
--- a/share/www/script/test/list_views.js
+++ b/share/www/script/test/list_views.js
@@ -59,8 +59,8 @@ couchTests.list_views = function(debug) {
} else {
// tail
return {body : '</ul>'+
- '<p>FirstKey: '+row_info.first_key+
- ' LastKey: '+row_info.prev_key+'</p>'};
+ '<p>FirstKey: '+(row_info ? row_info.first_key : '')+
+ ' LastKey: '+(row_info ? row_info.prev_key : '')+'</p>'};
}
}),
acceptSwitch: stringFun(function(head, row, req, row_info) {
@@ -127,6 +127,9 @@ couchTests.list_views = function(debug) {
}
}
});
+ }),
+ emptyList: stringFun(function(head, row, req, row_info) {
+ return { body: "" };
})
}
};
@@ -175,6 +178,13 @@ couchTests.list_views = function(debug) {
T(xhr.status == 200);
T(/Total Rows/.test(xhr.responseText));
T(/Offset: null/.test(xhr.responseText));
+
+ // reduce with 0 rows
+ var xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/simpleForm/withReduce?startkey=30");
+ T(xhr.status == 200);
+ T(/Total Rows/.test(xhr.responseText));
+ T(/Offset: undefined/.test(xhr.responseText));
+
// when there is a reduce present, but not used
var xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/simpleForm/withReduce?reduce=false");
@@ -182,6 +192,11 @@ couchTests.list_views = function(debug) {
T(/Total Rows/.test(xhr.responseText));
T(/Key: 1/.test(xhr.responseText));
+ // when there is a reduce present, and used
+ var xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/simpleForm/withReduce?group=true");
+ T(xhr.status == 200);
+ T(/Key: 1/.test(xhr.responseText));
+
// with accept headers for HTML
xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/acceptSwitch/basicView", {
headers: {
@@ -203,14 +218,25 @@ couchTests.list_views = function(debug) {
T(xhr.responseText.match(/entry/));
// now with extra qs params
- xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/qsParams/basicView?foo=blam");
+ var xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/qsParams/basicView?foo=blam");
T(xhr.responseText.match(/blam/));
-
// aborting iteration
- xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/stopIter/basicView");
+ var xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/stopIter/basicView");
T(xhr.responseText.match(/^head 0 1 2 tail$/));
xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/stopIter2/basicView");
T(xhr.responseText.match(/^head 0 1 2 tail$/));
+ // aborting iteration with reduce
+ var xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/stopIter/withReduce?group=true");
+ T(xhr.responseText.match(/^head 0 1 2 tail$/));
+ xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/stopIter2/withReduce?group=true");
+ T(xhr.responseText.match(/^head 0 1 2 tail$/));
+
+ // empty list
+ var xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/emptyList/basicView");
+ T(xhr.responseText.match(/^$/));
+ xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/emptyList/withReduce?group=true");
+ T(xhr.responseText.match(/^$/));
+
};