diff options
author | Jan Lehnardt <jan@apache.org> | 2010-02-05 01:13:28 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2010-02-05 01:13:28 +0000 |
commit | 15d10793a32a5fa57c80e9eab8803dc7d284ca6d (patch) | |
tree | af84bff66183ba71fda98cb1c53b97b720690fe2 /share/www/script | |
parent | ff1618779bc85d8f16d6aeebec461fad51b008c5 (diff) |
add list()-API cmompatible API to _show. Symmetry FTW.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@906755 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script')
-rw-r--r-- | share/www/script/test/show_documents.js | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/share/www/script/test/show_documents.js b/share/www/script/test/show_documents.js index 2e895838..f49c1f1f 100644 --- a/share/www/script/test/show_documents.js +++ b/share/www/script/test/show_documents.js @@ -22,7 +22,6 @@ couchTests.show_documents = function(debug) { shows: { "hello" : stringFun(function(doc, req) { log("hello fun"); - log(req); if (doc) { return "Hello World"; } else { @@ -80,6 +79,25 @@ couchTests.show_documents = function(debug) { "body" : "something" } }), + "list-api" : stringFun(function(doc, req) { + start({"X-Couch-Test-Header": "Yeah"}); + send("Hey"); + }), + "list-api-mix" : stringFun(function(doc, req) { + start({"X-Couch-Test-Header": "Yeah"}); + send("Hey "); + return "Dude"; + }), + "list-api-mix-with-header" : stringFun(function(doc, req) { + start({"X-Couch-Test-Header": "Yeah"}); + send("Hey "); + return { + headers: { + "X-Couch-Test-Header-Awesome": "Oh Yeah!" + }, + body: "Dude" + }; + }), "accept-switch" : stringFun(function(doc, req) { if (req.headers["Accept"].match(/image/)) { return { @@ -362,5 +380,18 @@ couchTests.show_documents = function(debug) { xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/hello/nonExistingDoc"); T(xhr.responseText == "New World"); + // test list() compatible API + xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/list-api/foo"); + T(xhr.responseText == "Hey"); + TEquals("Yeah", xhr.getResponseHeader("X-Couch-Test-Header"), "header should be cool"); + + xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/list-api-mix/foo"); + T(xhr.responseText == "Hey Dude"); + TEquals("Yeah", xhr.getResponseHeader("X-Couch-Test-Header"), "header should be cool"); + + xhr = CouchDB.request("GET", "/test_suite_db/_design/template/_show/list-api-mix-with-header/foo"); + T(xhr.responseText == "Hey Dude"); + TEquals("Yeah", xhr.getResponseHeader("X-Couch-Test-Header"), "header should be cool"); + TEquals("Oh Yeah!", xhr.getResponseHeader("X-Couch-Test-Header-Awesome"), "header should be cool"); }; |