From 15d10793a32a5fa57c80e9eab8803dc7d284ca6d Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Fri, 5 Feb 2010 01:13:28 +0000 Subject: 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 --- share/www/script/test/show_documents.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'share/www/script/test') 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"); }; -- cgit v1.2.3