diff options
author | John Christopher Anderson <jchris@apache.org> | 2009-02-02 20:27:03 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2009-02-02 20:27:03 +0000 |
commit | 941933ed3d1ae7247e4a27c54efb92bdcbd188a8 (patch) | |
tree | 0dfa837f02c72d8471332fc8465955b253052333 /share/www | |
parent | 49c9d17d8e407f54226b4fc4d55c0049ed58d628 (diff) |
add iteration numbers to list row functions. closes COUCHDB-233. thanks Benoit Chesneau.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@740094 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www')
-rw-r--r-- | share/www/script/couch_tests.js | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index e7f8abdb..db1bccf0 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -2677,10 +2677,14 @@ var tests = { } }, lists: { - simpleForm: stringFun(function(head, row, req) { + simpleForm: stringFun(function(head, row, req, row_number) { if (row) { // we ignore headers on rows and tail - return {body : '\n<li>Key: '+row.key+' Value: '+row.value+'</li>'}; + return { + body : '\n<li>Key: '+row.key + +' Value: '+row.value + +' LineNo: '+row_number+'</li>' + }; } else if (head) { // we return an object (like those used by external and show) // so that we can specify headers @@ -2695,7 +2699,7 @@ var tests = { return {body : '</ul>'}; } }), - acceptSwitch: stringFun(function(head, row, req) { + acceptSwitch: stringFun(function(head, row, req, row_number) { return respondWith(req, { html : function() { // If you're outputting text and you're not setting @@ -2704,7 +2708,8 @@ var tests = { return "HTML <ul>"; } else if (row) { return '\n<li>Key: ' - +row.key+' Value: '+row.value+'</li>'; + +row.key+' Value: '+row.value + +' LineNo: '+row_number+'</li>'; } else { // tail return "</ul>"; } @@ -2747,7 +2752,12 @@ var tests = { T(xhr.status == 200); T(/Total Rows/.test(xhr.responseText)); T(/Key: 1/.test(xhr.responseText)); - + T(/LineNo: 0/.test(xhr.responseText)); + T(/LineNo: 5/.test(xhr.responseText)); + + var lines = xhr.responseText.split('\n'); + T(/LineNo: 5/.test(lines[6])); + // get with query params var xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/simpleForm/basicView?startkey=3"); T(xhr.status == 200); |