You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2018/07/24 15:30:37 UTC
[couchdb-nano] 02/03: feat: lint for standard
This is an automated email from the ASF dual-hosted git repository.
jan pushed a commit to branch deps/linters
in repository https://gitbox.apache.org/repos/asf/couchdb-nano.git
commit 0c0a4fccef1fd75132e49bad293b123842949993
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Tue Jul 24 17:29:41 2018 +0200
feat: lint for standard
---
examples/bulk_transform.js | 56 +-
examples/express.js | 29 +-
examples/lazy_creation_of_views.js | 164 +++---
examples/lazy_db_creation_and_replication.js | 80 +--
examples/pipe.js | 16 +-
lib/logger.js | 24 +-
lib/nano.js | 689 +++++++++++------------
package.json | 8 +-
tests/helpers/index.js | 43 +-
tests/helpers/integration.js | 271 +++++----
tests/helpers/unit.js | 190 +++----
tests/integration/attachment/destroy.js | 79 +--
tests/integration/attachment/get.js | 92 +--
tests/integration/attachment/insert.js | 42 +-
tests/integration/attachment/pipe.js | 86 +--
tests/integration/attachment/update.js | 80 +--
tests/integration/database/changes.js | 74 +--
tests/integration/database/compact.js | 92 +--
tests/integration/database/create-and-destroy.js | 52 +-
tests/integration/database/follow.js | 50 +-
tests/integration/database/get.js | 58 +-
tests/integration/database/list.js | 60 +-
tests/integration/database/replicate.js | 126 ++---
tests/integration/database/replicator.js | 212 +++----
tests/integration/design/atomic.js | 104 ++--
tests/integration/design/compact.js | 36 +-
tests/integration/design/list.js | 40 +-
tests/integration/design/multiple.js | 98 ++--
tests/integration/design/query.js | 46 +-
tests/integration/design/search.js | 50 +-
tests/integration/design/show.js | 132 ++---
tests/integration/document/bulk.js | 50 +-
tests/integration/document/copy.js | 114 ++--
tests/integration/document/create_index.js | 42 +-
tests/integration/document/destroy.js | 84 +--
tests/integration/document/fetch.js | 108 ++--
tests/integration/document/fetch_revs.js | 124 ++--
tests/integration/document/find.js | 58 +-
tests/integration/document/get.js | 48 +-
tests/integration/document/head.js | 40 +-
tests/integration/document/insert.js | 138 ++---
tests/integration/document/list.js | 252 ++++-----
tests/integration/document/update.js | 74 +--
tests/integration/multipart/get.js | 84 +--
tests/integration/multipart/insert.js | 114 ++--
tests/integration/shared/config.js | 124 ++--
tests/integration/shared/cookie.js | 91 ++-
tests/integration/shared/error.js | 74 +--
tests/integration/shared/headers.js | 54 +-
tests/integration/shared/log.js | 26 +-
tests/integration/util/uuid.js | 82 +--
tests/intercept/design/search.js | 570 +++++++++----------
tests/unit/attachment/destroy.js | 6 +-
tests/unit/attachment/get.js | 8 +-
tests/unit/attachment/insert.js | 14 +-
tests/unit/database/changes.js | 8 +-
tests/unit/database/compact.js | 6 +-
tests/unit/database/create.js | 8 +-
tests/unit/database/destroy.js | 6 +-
tests/unit/database/follow.js | 6 +-
tests/unit/database/get.js | 6 +-
tests/unit/database/list.js | 6 +-
tests/unit/database/replicate.js | 8 +-
tests/unit/database/replicator.js | 8 +-
tests/unit/database/updates.js | 8 +-
tests/unit/design/atomic.js | 12 +-
tests/unit/design/compact.js | 6 +-
tests/unit/design/find.js | 6 +-
tests/unit/design/list.js | 16 +-
tests/unit/design/search.js | 6 +-
tests/unit/design/show.js | 6 +-
tests/unit/design/spatial.js | 6 +-
tests/unit/design/view.js | 6 +-
tests/unit/document/bulk.js | 8 +-
tests/unit/document/copy.js | 10 +-
tests/unit/document/get.js | 48 +-
tests/unit/multipart/get.js | 6 +-
tests/unit/multipart/insert.js | 14 +-
tests/unit/shared/error.js | 76 +--
tests/unit/shared/follow-updates.js | 8 +-
tests/unit/shared/jar.js | 30 +-
81 files changed, 2940 insertions(+), 2952 deletions(-)
diff --git a/examples/bulk_transform.js b/examples/bulk_transform.js
index ba61348..dc13b26 100644
--- a/examples/bulk_transform.js
+++ b/examples/bulk_transform.js
@@ -10,39 +10,37 @@
// License for the specific language governing permissions and limitations under
// the License.
-var db = require('nano')('http://localhost:5984/emails')
- , async = require('async')
- ;
+var db = require('nano')('http://localhost:5984/emails')
+var async = require('async')
-function update_row(row,cb) {
- var doc = row.doc;
- delete doc.subject;
+function updateRow (row, cb) {
+ var doc = row.doc
+ delete doc.subject
db.insert(doc, doc._id, function (err, data) {
- if(err) { console.log('err at ' + doc._id); cb(err); }
- else { console.log('updated ' + doc._id); cb(); }
- });
+ if (err) { console.log('err at ' + doc._id); cb(err) } else { console.log('updated ' + doc._id); cb() }
+ })
}
-function list(offset) {
- var ended = false;
- offset = offset || 0;
- db.list({include_docs: true, limit: 10, skip: offset},
- function(err, data) {
- var total, offset, rows;
- if(err) { console.log('fuuuu: ' + err.message); rows = []; return; }
- total = data.total_rows;
- offset = data.offset;
- rows = data.rows;
- if(offset === total) {
- ended = true;
- return;
+function list (offset) {
+ var ended = false
+ offset = offset || 0
+ db.list({include_docs: true, limit: 10, skip: offset},
+ function (err, data) {
+ var total, offset, rows
+ if (err) { console.log('fuuuu: ' + err.message); rows = []; return }
+ total = data.total_rows
+ offset = data.offset
+ rows = data.rows
+ if (offset === total) {
+ ended = true
+ return
}
- async.forEach(rows, update_row, function (err) {
- if(err) { console.log('something failed, check logs'); }
- if(ended) { return; }
- list(offset+10);
- });
- });
+ async.forEach(rows, updateRow, function (err) {
+ if (err) { console.log('something failed, check logs') }
+ if (ended) { return }
+ list(offset + 10)
+ })
+ })
}
-list();
\ No newline at end of file
+list()
diff --git a/examples/express.js b/examples/express.js
index b49ba1d..fe08ac7 100644
--- a/examples/express.js
+++ b/examples/express.js
@@ -11,20 +11,19 @@
// the License.
var express = require('express')
- , db = require('nano')('http://localhost:5984/my_couch')
- , app = module.exports = express()
- ;
+var db = require('nano')('http://localhost:5984/my_couch')
+var app = module.exports = express()
-app.get('/', function(req, res) {
- db.get('foo', function (error, body, headers) {
- if(error) {
- res.status(error.statusCode);
- return res.send(error.message);
- }
- res.status(200);
- res.send(body);
- });
-});
+app.get('/', function (req, res) {
+ db.get('foo', function (error, body, headers) {
+ if (error) {
+ res.status(error.statusCode)
+ return res.send(error.message)
+ }
+ res.status(200)
+ res.send(body)
+ })
+})
-app.listen(3333);
-console.log('server is running. check expressjs.com for more cool tricks');
+app.listen(3333)
+console.log('server is running. check expressjs.com for more cool tricks')
diff --git a/examples/lazy_creation_of_views.js b/examples/lazy_creation_of_views.js
index 75df363..5a63869 100644
--- a/examples/lazy_creation_of_views.js
+++ b/examples/lazy_creation_of_views.js
@@ -10,105 +10,103 @@
// License for the specific language governing permissions and limitations under
// the License.
-module.exports = function() {
-var nano = require('nano')('http://localhost:5984')
- , users = nano.use('users')
- , VIEWS = { by_twitter_id:
- { "map": "function(doc) { emit(doc.twitter.screen_name, doc); }" } }
- ;
+module.exports = function () {
+ var nano = require('nano')('http://localhost:5984')
+ var users = nano.use('users')
+ var VIEWS = { by_twitter_id:
+ { 'map': 'function(doc) { emit(doc.twitter.screen_name, doc); }' } }
-/*****************************************************************************
+ /*****************************************************************************
* user.get()
****************************************************************************/
-function user_get(id, callback){
- return users.get(id, callback);
-}
+ function userGet (id, callback) {
+ return users.get(id, callback)
+ }
-/*****************************************************************************
+ /*****************************************************************************
* user.new()
****************************************************************************/
-function user_new(id, body, callback) {
- return users.insert(body, id, callback);
-}
+ function userNew (id, body, callback) {
+ return users.insert(body, id, callback)
+ }
-/*****************************************************************************
+ /*****************************************************************************
* user.create()
****************************************************************************/
-function create_users_database(email_address,secret,name,retries) {
- nano.db.create('users', function (e,b,h) {
- user_create(email_address,secret,name,retries+1);
- });
-}
+ function createUsersDatabase (emailAddress, secret, name, retries) {
+ nano.db.create('users', function (e, b, h) {
+ userCreate(emailAddress, secret, name, retries + 1)
+ })
+ }
-function user_create(email_address,secret,name,retries) {
- if (!retries) {
- retries = 0;
+ function userCreate (emailAddress, secret, name, retries) {
+ if (!retries) {
+ retries = 0
+ }
+ users.insert({emailAddress: emailAddress, secret: secret, name: name}, secret,
+ function (e, b, h) {
+ if (e && e.message === 'no_db_file' && retries < 1) {
+ return createUsersDatabase(emailAddress, secret, name, retries)
+ }
+ (function () { })(e, b, h)
+ })
}
- users.insert( {email_address: email_address, secret: secret, name: name}, secret,
- function (e,b,h) {
- if(e && e.message === 'no_db_file' && retries < 1) {
- return create_users_database(email_address,secret,name,retries);
- }
- (function() { return ; })(e,b,h);
- });
-}
-/*****************************************************************************
+ /*****************************************************************************
* user.find()
****************************************************************************/
- //
- // some more logic needed
- // what if design document exists but view doesnt, we cant just overwrite it
- //
- // we need a way to fectch and build on
- // and thats the reason why im not doing this at 5am
+ //
+ // some more logic needed
+ // what if design document exists but view doesnt, we cant just overwrite it
+ //
+ // we need a way to fectch and build on
+ // and thats the reason why im not doing this at 5am
-function user_find(view, id, opts, tried, callback) {
- if(typeof tried === 'function') {
- callback = tried;
- tried = {tried:0, max_retries:2};
- }
- users.view('users', view, opts, function (e,b,h) {
- if(e) {
- var current_view = VIEWS[view];
- if(!current_view) {
- e.message = 'View is not available';
- return callback(e,b,h);
- }
- if(tried.tried < tried.max_retries) {
- if(e.message === 'missing' || e.message === 'deleted') { // create design document
- var design_doc = {views: {}};
- design_doc.views[view] = current_view;
- return users.insert(design_doc, '_design/users', function () {
- tried.tried += 1;
- user_find(view,id,opts,tried,callback);
- });
- }
- if(e.message === 'missing_named_view') {
- users.get('_design/users', function (e,b,h) { // create view
- tried.tried += 1;
- if(e) { return user_find(view,id,opts,tried,callback); }
- b.views[view] = current_view;
- users.insert(b, '_design/users', function (e,b,h) {
- return user_find(view,id,opts,tried,callback);
- });
- });
- return;
+ function userFind (view, id, opts, tried, callback) {
+ if (typeof tried === 'function') {
+ callback = tried
+ tried = {tried: 0, max_retries: 2}
+ }
+ users.view('users', view, opts, function (e, b, h) {
+ if (e) {
+ var currentView = VIEWS[view]
+ if (!currentView) {
+ e.message = 'View is not available'
+ return callback(e, b, h)
}
+ if (tried.tried < tried.max_retries) {
+ if (e.message === 'missing' || e.message === 'deleted') { // create design document
+ var designDoc = {views: {}}
+ designDoc.views[view] = currentView
+ return users.insert(designDoc, '_design/users', function () {
+ tried.tried += 1
+ userFind(view, id, opts, tried, callback)
+ })
+ }
+ if (e.message === 'missing_named_view') {
+ users.get('_design/users', function (e, b, h) { // create view
+ tried.tried += 1
+ if (e) { return userFind(view, id, opts, tried, callback) }
+ b.views[view] = currentView
+ users.insert(b, '_design/users', function (e, b, h) {
+ return userFind(view, id, opts, tried, callback)
+ })
+ })
+ return
+ }
+ } else { return callback(e, b, h) }
}
- else { return callback(e,b,h); }
- }
- return callback(null,b,h);
- });
-}
+ return callback(null, b, h)
+ })
+ }
-function user_first(view, id, callback) {
- return user_find(view, id, {startkey: ('"' + id + '"'), limit: 1}, callback);
-}
+ function userFirst (view, id, callback) {
+ return userFind(view, id, {startkey: ('"' + id + '"'), limit: 1}, callback)
+ }
-return { new: user_new
- , get: user_get
- , create: user_create
- , first: user_first
- };
-};
\ No newline at end of file
+ return { new: userNew,
+ get: userGet,
+ create: userCreate,
+ first: userFirst
+ }
+}
diff --git a/examples/lazy_db_creation_and_replication.js b/examples/lazy_db_creation_and_replication.js
index b54eb08..cbd2ed2 100644
--- a/examples/lazy_db_creation_and_replication.js
+++ b/examples/lazy_db_creation_and_replication.js
@@ -10,56 +10,56 @@
// License for the specific language governing permissions and limitations under
// the License.
-var nano = require('nano')
- , couch =
- { "master" : "http://localhost:5984/landing_m"
- , "replica" : "http://localhost:5984/landing_r"
+var nano = require('nano')
+var couch =
+ {
+ 'master': 'http://localhost:5984/landing_m',
+ 'replica': 'http://localhost:5984/landing_r'
}
- ;
-function insert_with_retry(db, email, retries, callback) {
+function insertWithRetry (db, email, retries, callback) {
if (typeof retries === 'function') {
- callback = retries;
- retries = 0;
+ callback = retries
+ retries = 0
}
- callback = callback || function(){};
- db.insert(email, function(err, resp, head) {
- if(err) {
- if(err.message === 'no_db_file' && retries < 1) {
- var db_name = db.config.db
- , server = nano(db.config.url)
- ;
- server.db.create(db_name, function (err2,resp2,head2) {
- if(err2) { return callback(err2,resp2,head2); }
- insert_with_retry(db,email,retries+1,callback);
- });
- } else { return callback(err,resp,head); }
+ callback = callback || function () {}
+ db.insert(email, function (err, resp, head) {
+ if (err) {
+ if (err.message === 'no_db_file' && retries < 1) {
+ var dbName = db.config.db
+ var server = nano(db.config.url)
+
+ server.db.create(dbName, function (err2, resp2, head2) {
+ if (err2) { return callback(err2, resp2, head2) }
+ insertWithRetry(db, email, retries + 1, callback)
+ })
+ } else { return callback(err, resp, head) }
}
- callback(err, resp, head);
- });
+ callback(err, resp, head)
+ })
}
-function replicate_with_retry(master_uri, replica_uri, retries, callback) {
+function replicateWithRetry (primaryUri, replicaUri, retries, callback) {
if (typeof retries === 'function') {
- callback = retries;
- retries = 0;
+ callback = retries
+ retries = 0
}
- callback = callback || function(){};
- retries = retries || 0;
- var master = nano(couch.master);
- master.replicate(couch.replica, function(err, resp, head) {
- if(err && err['error'] === 'db_not_found' && retries < 1) {
+ callback = callback || function () {}
+ retries = retries || 0
+ var master = nano(couch.master)
+ master.replicate(couch.replica, function (err, resp, head) {
+ if (err && err['error'] === 'db_not_found' && retries < 1) {
var replica = nano(couch.replica)
- , db_name = replica.config.db
- , server = nano(replica.config.url)
- ;
- server.db.create(db_name, function (err2, resp2, head2) {
- if(err2) { return callback(err2,resp2,head2); }
- replicate_with_retry(master_uri, replica_uri, retries+1, callback);
- });
+ var dbName = replica.config.db
+ var server = nano(replica.config.url)
+
+ server.db.create(dbName, function (err2, resp2, head2) {
+ if (err2) { return callback(err2, resp2, head2) }
+ replicateWithRetry(primaryUri, replicaUri, retries + 1, callback)
+ })
}
- callback(err, resp, head);
- });
+ callback(err, resp, head)
+ })
}
-module.exports = {insert: insert_with_retry, replicate: replicate_with_retry};
\ No newline at end of file
+module.exports = {insert: insertWithRetry, replicate: replicateWithRetry}
diff --git a/examples/pipe.js b/examples/pipe.js
index 04d23ec..bb69e12 100644
--- a/examples/pipe.js
+++ b/examples/pipe.js
@@ -11,13 +11,13 @@
// the License.
var express = require('express')
- , nano = require('nano')('http://localhost:5984')
- , app = module.exports = express.createServer()
- , db_name = "test"
- , db = nano.use(db_name);
+var nano = require('nano')('http://localhost:5984')
+var app = module.exports = express.createServer()
+var dbName = 'test'
+var db = nano.use(dbName)
-app.get("/", function(request,response) {
- db.attachment.get("new", "logo.png").pipe(response);
-});
+app.get('/', function (request, response) {
+ db.attachment.get('new', 'logo.png').pipe(response)
+})
-app.listen(3333);
\ No newline at end of file
+app.listen(3333)
diff --git a/lib/logger.js b/lib/logger.js
index 8d74bb0..9f73271 100644
--- a/lib/logger.js
+++ b/lib/logger.js
@@ -10,19 +10,19 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const debug = require('debug')('nano/logger');
+const debug = require('debug')('nano/logger')
-module.exports = function logging(cfg) {
- const log = cfg && cfg.log;
- const logStrategy = typeof log === 'function' ? log : debug;
+module.exports = function logging (cfg) {
+ const log = cfg && cfg.log
+ const logStrategy = typeof log === 'function' ? log : debug
- return function logEvent(prefix) {
+ return function logEvent (prefix) {
const eventId = (prefix ? prefix + '-' : '') +
- (~~(Math.random() * 1e9)).toString(36);
- return function log() {
- logStrategy.call(this, eventId, [].slice.call(arguments, 0));
- };
- };
-};
+ (~~(Math.random() * 1e9)).toString(36)
+ return function log () {
+ logStrategy.call(this, eventId, [].slice.call(arguments, 0))
+ }
+ }
+}
diff --git a/lib/nano.js b/lib/nano.js
index 6db083d..6dd6aa1 100644
--- a/lib/nano.js
+++ b/lib/nano.js
@@ -10,137 +10,134 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const u = require('url');
-const assert = require('assert');
-const querystring = require('querystring');
-const request = require('request');
-const errs = require('errs');
-const isEmpty = require('lodash.isempty');
-const follow = require('cloudant-follow');
-const logger = require('./logger');
-
-let nano;
+const u = require('url')
+const assert = require('assert')
+const querystring = require('querystring')
+const request = require('request')
+const errs = require('errs')
+const isEmpty = require('lodash.isempty')
+const follow = require('cloudant-follow')
+const logger = require('./logger')
function getCallback (opts, callback) {
if (typeof opts === 'function') {
- callback = opts;
- opts = {};
+ callback = opts
+ opts = {}
}
return {
opts,
callback
- };
+ }
}
-module.exports = exports = nano = function dbScope(cfg) {
- let serverScope = {};
+module.exports = exports = function dbScope (cfg) {
+ let serverScope = {}
if (typeof cfg === 'string') {
- cfg = {url: cfg};
+ cfg = {url: cfg}
}
assert.equal(typeof cfg, 'object',
- 'You must specify the endpoint url when invoking this module');
- assert.ok(/^https?:/.test(cfg.url), 'url is not valid');
+ 'You must specify the endpoint url when invoking this module')
+ assert.ok(/^https?:/.test(cfg.url), 'url is not valid')
- cfg = Object.assign({}, cfg);
+ cfg = Object.assign({}, cfg)
- serverScope.config = cfg;
- cfg.requestDefaults = cfg.requestDefaults || {jar: false};
+ serverScope.config = cfg
+ cfg.requestDefaults = cfg.requestDefaults || {jar: false}
- const httpAgent = (typeof cfg.request === 'function') ? cfg.request :
- request.defaults(cfg.requestDefaults);
- const followAgent = (typeof cfg.follow === 'function') ? cfg.follow : follow;
- const log = typeof cfg.log === 'function' ? cfg.log : logger(cfg);
- const parseUrl = 'parseUrl' in cfg ? cfg.parseUrl : true;
+ const httpAgent = (typeof cfg.request === 'function') ? cfg.request
+ : request.defaults(cfg.requestDefaults)
+ const followAgent = (typeof cfg.follow === 'function') ? cfg.follow : follow
+ const log = typeof cfg.log === 'function' ? cfg.log : logger(cfg)
+ const parseUrl = 'parseUrl' in cfg ? cfg.parseUrl : true
- function maybeExtractDatabaseComponent() {
+ function maybeExtractDatabaseComponent () {
if (!parseUrl) {
- return;
+ return
}
- const path = u.parse(cfg.url);
- let pathArray = path.pathname.split('/').filter(function(e) { return e; });
- const db = pathArray.pop();
- const rootPath = path.pathname.replace(/\/?$/, '/..');
+ const path = u.parse(cfg.url)
+ let pathArray = path.pathname.split('/').filter(function (e) { return e })
+ const db = pathArray.pop()
+ const rootPath = path.pathname.replace(/\/?$/, '/..')
if (db) {
- cfg.url = urlResolveFix(cfg.url, rootPath).replace(/\/?$/, '');
- return db;
+ cfg.url = urlResolveFix(cfg.url, rootPath).replace(/\/?$/, '')
+ return db
}
}
- function scrub(str) {
+ function scrub (str) {
if (str) {
- str = str.replace(/\/\/(.*)@/,"//XXXXXX:XXXXXX@");
+ str = str.replace(/\/\/(.*)@/, '//XXXXXX:XXXXXX@')
}
- return str;
+ return str
}
- const responseHandler = function(req, opts, resolve, reject, callback) {
-
- return function(err, response = { statusCode: 500 }, body = '') {
- let parsed;
+ const responseHandler = function (req, opts, resolve, reject, callback) {
+ return function (err, response = { statusCode: 500 }, body = '') {
+ let parsed
const responseHeaders = Object.assign({
uri: req.uri,
statusCode: response.statusCode
- }, response.headers);
+ }, response.headers)
if (err) {
- log({err: 'socket', body: body, headers: responseHeaders});
+ log({err: 'socket', body: body, headers: responseHeaders})
const returnError = errs.merge(err, {
message: 'error happened in your connection',
scope: 'socket',
errid: 'request'
- });
+ })
if (reject) {
- reject(returnError);
- }
+ reject(returnError)
+ }
if (callback) {
- callback(returnError);
+ callback(returnError)
}
- return ;
+ return
}
- delete responseHeaders.server;
- delete responseHeaders['content-length'];
+ delete responseHeaders.server
+ delete responseHeaders['content-length']
if (opts.dontParse) {
- parsed = body;
+ parsed = body
} else {
- try { parsed = JSON.parse(body); } catch (err) { parsed = body; }
+ try { parsed = JSON.parse(body) } catch (err) { parsed = body }
}
if (responseHeaders.statusCode >= 200 && responseHeaders.statusCode < 400) {
- log({err: null, body: parsed, headers: responseHeaders});
+ log({err: null, body: parsed, headers: responseHeaders})
if (resolve) {
- resolve(parsed);
- }
+ resolve(parsed)
+ }
if (callback) {
- callback(null, parsed, responseHeaders);
+ callback(null, parsed, responseHeaders)
}
- return;
+ return
}
- log({err: 'couch', body: parsed, headers: responseHeaders});
+ log({err: 'couch', body: parsed, headers: responseHeaders})
// cloudant stacktrace
if (typeof parsed === 'string') {
- parsed = {message: parsed};
+ parsed = {message: parsed}
}
if (!parsed.message && (parsed.reason || parsed.error)) {
- parsed.message = (parsed.reason || parsed.error);
+ parsed.message = (parsed.reason || parsed.error)
}
// fix cloudant issues where they give an erlang stacktrace as js
- delete parsed.stack;
+ delete parsed.stack
// scrub credentials
- req.uri = scrub(req.uri);
- responseHeaders.uri = scrub(responseHeaders.uri);
+ req.uri = scrub(req.uri)
+ responseHeaders.uri = scrub(responseHeaders.uri)
if (req.headers.cookie) {
- req.headers.cookie = "XXXXXXX";
+ req.headers.cookie = 'XXXXXXX'
}
let errors = errs.merge({
@@ -150,148 +147,146 @@ module.exports = exports = nano = function dbScope(cfg) {
request: req,
headers: responseHeaders,
errid: 'non_200'
- }, errs.create(parsed));
-
+ }, errs.create(parsed))
if (reject) {
- reject(errors);
- }
+ reject(errors)
+ }
if (callback) {
- callback(errors);
+ callback(errors)
}
- };
-
- };
+ }
+ }
- function relax(opts, callback) {
+ function relax (opts, callback) {
if (typeof opts === 'function') {
- callback = opts;
- opts = {path: ''};
+ callback = opts
+ opts = {path: ''}
}
if (typeof opts === 'string') {
- opts = {path: opts};
+ opts = {path: opts}
}
if (!opts) {
- opts = {path: ''};
- callback = null;
+ opts = {path: ''}
+ callback = null
}
- const qs = Object.assign({}, opts.qs);
+ const qs = Object.assign({}, opts.qs)
const headers = {
'content-type': 'application/json',
accept: 'application/json'
- };
+ }
const req = {
method: (opts.method || 'GET'),
headers: headers,
uri: cfg.url
- };
+ }
// https://github.com/mikeal/request#requestjar
- const isJar = opts.jar || cfg.jar;
+ const isJar = opts.jar || cfg.jar
if (isJar) {
- req.jar = isJar;
+ req.jar = isJar
}
// http://wiki.apache.org/couchdb/HTTP_database_API#Naming_and_Addressing
if (opts.db) {
- req.uri = urlResolveFix(req.uri, encodeURIComponent(opts.db));
+ req.uri = urlResolveFix(req.uri, encodeURIComponent(opts.db))
}
if (opts.multipart) {
- req.multipart = opts.multipart;
+ req.multipart = opts.multipart
}
- req.headers = Object.assign(req.headers, opts.headers, cfg.defaultHeaders);
+ req.headers = Object.assign(req.headers, opts.headers, cfg.defaultHeaders)
if (opts.path) {
- req.uri += '/' + opts.path;
+ req.uri += '/' + opts.path
} else if (opts.doc) {
if (!/^_design/.test(opts.doc)) {
// http://wiki.apache.org/couchdb/HTTP_Document_API#Naming.2FAddressing
- req.uri += '/' + encodeURIComponent(opts.doc);
+ req.uri += '/' + encodeURIComponent(opts.doc)
} else {
// http://wiki.apache.org/couchdb/HTTP_Document_API#Document_IDs
- req.uri += '/' + opts.doc;
+ req.uri += '/' + opts.doc
}
// http://wiki.apache.org/couchdb/HTTP_Document_API#Attachments
if (opts.att) {
- req.uri += '/' + opts.att;
+ req.uri += '/' + opts.att
}
}
// prevent bugs where people set encoding when piping
if (opts.encoding !== undefined && callback) {
- req.encoding = opts.encoding;
- delete req.headers['content-type'];
- delete req.headers.accept;
+ req.encoding = opts.encoding
+ delete req.headers['content-type']
+ delete req.headers.accept
}
if (opts.contentType) {
- req.headers['content-type'] = opts.contentType;
- delete req.headers.accept;
+ req.headers['content-type'] = opts.contentType
+ delete req.headers.accept
}
- if(opts.accept) {
- req.headers['accept'] = opts.accept;
+ if (opts.accept) {
+ req.headers['accept'] = opts.accept
}
// http://guide.couchdb.org/draft/security.html#cookies
if (cfg.cookie) {
- req.headers['X-CouchDB-WWW-Authenticate'] = 'Cookie';
- req.headers.cookie = cfg.cookie;
+ req.headers['X-CouchDB-WWW-Authenticate'] = 'Cookie'
+ req.headers.cookie = cfg.cookie
}
// http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
if (typeof opts.qs === 'object' && !isEmpty(opts.qs)) {
- ['startkey', 'endkey', 'key', 'keys', 'start_key', 'end_key'].forEach(function(key) {
+ ['startkey', 'endkey', 'key', 'keys', 'start_key', 'end_key'].forEach(function (key) {
if (key in opts.qs) {
- qs[key] = JSON.stringify(opts.qs[key]);
+ qs[key] = JSON.stringify(opts.qs[key])
}
- });
- req.qs = qs;
+ })
+ req.qs = qs
}
if (opts.body) {
if (Buffer.isBuffer(opts.body) || opts.dontStringify) {
- req.body = opts.body;
+ req.body = opts.body
} else {
- req.body = JSON.stringify(opts.body, function(key, value) {
+ req.body = JSON.stringify(opts.body, function (key, value) {
// don't encode functions
- if (typeof(value) === 'function') {
- return value.toString();
+ if (typeof (value) === 'function') {
+ return value.toString()
} else {
- return value;
+ return value
}
- });
+ })
}
}
if (opts.form) {
req.headers['content-type'] =
- 'application/x-www-form-urlencoded; charset=utf-8';
- req.body = querystring.stringify(opts.form).toString('utf8');
+ 'application/x-www-form-urlencoded; charset=utf-8'
+ req.body = querystring.stringify(opts.form).toString('utf8')
}
- log(req);
+ log(req)
if (opts.stream) {
- return httpAgent(req, responseHandler(req, opts, null, null, callback));
+ return httpAgent(req, responseHandler(req, opts, null, null, callback))
} else {
- return new Promise( function(resolve, reject) {
- httpAgent(req, responseHandler(req, opts, resolve, reject, callback));
- });
+ return new Promise(function (resolve, reject) {
+ httpAgent(req, responseHandler(req, opts, resolve, reject, callback))
+ })
}
}
// http://docs.couchdb.org/en/latest/api/server/authn.html#cookie-authentication
- function auth(username, password, callback) {
+ function auth (username, password, callback) {
return relax({
method: 'POST',
db: '_session',
@@ -299,271 +294,268 @@ module.exports = exports = nano = function dbScope(cfg) {
name: username,
password: password
}
- }, callback);
+ }, callback)
}
// http://docs.couchdb.org/en/latest/api/server/authn.html#post--_session
- function session(callback) {
- return relax({db: '_session'}, callback);
+ function session (callback) {
+ return relax({db: '_session'}, callback)
}
// http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates
- function updates(qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
+ function updates (qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
return relax({
db: '_db_updates',
qs: opts
- }, callback);
+ }, callback)
}
- function followUpdates(qs, callback) {
- return followDb('_db_updates', qs, callback);
+ function followUpdates (qs, callback) {
+ return followDb('_db_updates', qs, callback)
}
// http://docs.couchdb.org/en/latest/api/database/common.html#put--db
- function createDb(dbName, callback) {
- return relax({db: dbName, method: 'PUT'}, callback);
+ function createDb (dbName, callback) {
+ return relax({db: dbName, method: 'PUT'}, callback)
}
// http://docs.couchdb.org/en/latest/api/database/common.html#delete--db
- function destroyDb(dbName, callback) {
- return relax({db: dbName, method: 'DELETE'}, callback);
+ function destroyDb (dbName, callback) {
+ return relax({db: dbName, method: 'DELETE'}, callback)
}
// http://docs.couchdb.org/en/latest/api/database/common.html#get--db
- function getDb(dbName, callback) {
- return relax({db: dbName}, callback);
+ function getDb (dbName, callback) {
+ return relax({db: dbName}, callback)
}
// http://docs.couchdb.org/en/latest/api/server/common.html#get--_all_dbs
- function listDbs(callback) {
- return relax({db: '_all_dbs'}, callback);
+ function listDbs (callback) {
+ return relax({db: '_all_dbs'}, callback)
}
// http://docs.couchdb.org/en/latest/api/server/common.html#get--_all_dbs
- function listDbsAsStream(callback) {
- return relax({db: '_all_dbs', stream: true}, callback);
+ function listDbsAsStream (callback) {
+ return relax({db: '_all_dbs', stream: true}, callback)
}
// http://docs.couchdb.org/en/latest/api/database/compact.html#post--db-_compact
- function compactDb(dbName, ddoc, callback) {
+ function compactDb (dbName, ddoc, callback) {
if (typeof ddoc === 'function') {
- callback = ddoc;
- ddoc = null;
+ callback = ddoc
+ ddoc = null
}
return relax({
db: dbName,
doc: '_compact',
att: ddoc,
method: 'POST'
- }, callback);
+ }, callback)
}
// http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes
- function changesDb(dbName, qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
- return relax({db: dbName, path: '_changes', qs: opts}, callback);
+ function changesDb (dbName, qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
+ return relax({db: dbName, path: '_changes', qs: opts}, callback)
}
- function changesDbAsStream(dbName, qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
- return relax({db: dbName, path: '_changes', stream: true, qs: opts}, callback);
+ function changesDbAsStream (dbName, qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
+ return relax({db: dbName, path: '_changes', stream: true, qs: opts}, callback)
}
- function followDb(dbName, qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
- opts.db = urlResolveFix(cfg.url, encodeURIComponent(dbName));
+ function followDb (dbName, qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
+ opts.db = urlResolveFix(cfg.url, encodeURIComponent(dbName))
if (typeof callback === 'function') {
- return followAgent(opts, callback);
+ return followAgent(opts, callback)
} else {
- return new followAgent.Feed(opts);
+ return new followAgent.Feed(opts)
}
}
- function _serializeAsUrl(db) {
+ function _serializeAsUrl (db) {
if (typeof db === 'object' && db.config && db.config.url && db.config.db) {
- return urlResolveFix(db.config.url, encodeURIComponent(db.config.db));
+ return urlResolveFix(db.config.url, encodeURIComponent(db.config.db))
} else {
- return db;
+ return db
}
}
// http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate
- function replicateDb(source, target, opts0, callback0) {
- const {opts, callback} = getCallback(opts0, callback0);
+ function replicateDb (source, target, opts0, callback0) {
+ const {opts, callback} = getCallback(opts0, callback0)
// _replicate
- opts.source = _serializeAsUrl(source);
- opts.target = _serializeAsUrl(target);
+ opts.source = _serializeAsUrl(source)
+ opts.target = _serializeAsUrl(target)
- return relax({db: '_replicate', body: opts, method: 'POST'}, callback);
+ return relax({db: '_replicate', body: opts, method: 'POST'}, callback)
}
// http://docs.couchdb.org/en/latest/api/server/common.html#uuids
- function uuids(count, callback) {
+ function uuids (count, callback) {
if (typeof count === 'function') {
- callback = count;
- count = 1;
+ callback = count
+ count = 1
}
- return relax({ method: 'GET', path: '_uuids', qs: {count: count}}, callback);
+ return relax({ method: 'GET', path: '_uuids', qs: { count: count } }, callback)
}
// http://guide.couchdb.org/draft/replication.html
- function enableReplication(source, target, opts0, callback0) {
- const {opts, callback} = getCallback(opts0, callback0);
+ function enableReplication (source, target, opts0, callback0) {
+ const {opts, callback} = getCallback(opts0, callback0)
// _replicator
- opts.source = _serializeAsUrl(source);
- opts.target = _serializeAsUrl(target);
+ opts.source = _serializeAsUrl(source)
+ opts.target = _serializeAsUrl(target)
- return relax({db: '_replicator', body: opts, method: 'POST'}, callback);
+ return relax({db: '_replicator', body: opts, method: 'POST'}, callback)
}
// http://guide.couchdb.org/draft/replication.html
- function queryReplication(id, opts0, callback0) {
- const {opts, callback} = getCallback(opts0, callback0);
- return relax({db: '_replicator', method: 'GET', path: id, qs: opts}, callback);
+ function queryReplication (id, opts0, callback0) {
+ const {opts, callback} = getCallback(opts0, callback0)
+ return relax({db: '_replicator', method: 'GET', path: id, qs: opts}, callback)
}
// http://guide.couchdb.org/draft/replication.html
- function disableReplication(id, rev, opts0, callback0) {
- const {opts, callback} = getCallback(opts0, callback0);
+ function disableReplication (id, rev, opts0, callback0) {
+ const {opts, callback} = getCallback(opts0, callback0)
const req = {
- db: '_replicator',
- method: 'DELETE',
- path: id,
+ db: '_replicator',
+ method: 'DELETE',
+ path: id,
qs: Object.assign(opts, {rev: rev})
- };
- return relax(req, callback);
+ }
+ return relax(req, callback)
}
- function docModule(dbName) {
- let docScope = {};
- dbName = decodeURIComponent(dbName);
+ function docModule (dbName) {
+ let docScope = {}
+ dbName = decodeURIComponent(dbName)
// http://docs.couchdb.org/en/latest/api/document/common.html#put--db-docid
// http://docs.couchdb.org/en/latest/api/database/common.html#post--db
- function insertDoc(doc, qs0, callback0) {
- const req = {db: dbName, body: doc, method: 'POST'};
+ function insertDoc (doc, qs0, callback0) {
+ const req = {db: dbName, body: doc, method: 'POST'}
- let {opts, callback} = getCallback(qs0, callback0);
+ let {opts, callback} = getCallback(qs0, callback0)
if (typeof opts === 'string') {
- opts = {docName: opts};
+ opts = {docName: opts}
}
if (opts) {
if (opts.docName) {
- req.doc = opts.docName;
- req.method = 'PUT';
- delete opts.docName;
+ req.doc = opts.docName
+ req.method = 'PUT'
+ delete opts.docName
}
- req.qs = opts;
+ req.qs = opts
}
- return relax(req, callback);
+ return relax(req, callback)
}
// http://docs.couchdb.org/en/latest/api/document/common.html#delete--db-docid
- function destroyDoc(docName, rev, callback) {
- if(!docName) {
- if(callback) {
- const msg = 'Invalid doc id';
- callback(msg, null);
- return new Promise(function(resolve, reject) {
- reject(msg);
- });
+ function destroyDoc (docName, rev, callback) {
+ if (!docName) {
+ if (callback) {
+ const msg = 'Invalid doc id'
+ callback(msg, null)
+ return new Promise(function (resolve, reject) {
+ reject(msg)
+ })
}
- }
- else {
+ } else {
return relax({
db: dbName,
doc: docName,
method: 'DELETE',
qs: {rev: rev}
- }, callback);
+ }, callback)
}
}
// http://docs.couchdb.org/en/latest/api/document/common.html#get--db-docid
- function getDoc(docName, qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
+ function getDoc (docName, qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
- if(!docName) {
- if(callback)
- callback("Invalid doc id", null);
- }
- else {
- return relax({db: dbName, doc: docName, qs: opts}, callback);
+ if (!docName) {
+ if (callback) { callback('Invalid doc id', null) } // eslint-disable-line
+ } else {
+ return relax({db: dbName, doc: docName, qs: opts}, callback)
}
}
// http://docs.couchdb.org/en/latest/api/document/common.html#head--db-docid
- function headDoc(docName, callback) {
+ function headDoc (docName, callback) {
// this function doesn't pass on the Promise from relax because it needs
// to return the headers when resolving the Promise
- return new Promise(function(resolve, reject) {
+ return new Promise(function (resolve, reject) {
relax({
db: dbName,
doc: docName,
method: 'HEAD',
qs: {}
- }, function(err, body, headers) {
+ }, function (err, body, headers) {
if (callback) {
- callback(err, body, headers);
- }
+ callback(err, body, headers)
+ }
if (err) {
- reject(err);
+ reject(err)
} else {
- resolve(headers);
+ resolve(headers)
}
- });
- });
+ })
+ })
}
// http://docs.couchdb.org/en/latest/api/document/common.html#copy--db-docid
- function copyDoc(docSrc, docDest, opts0, callback0) {
- const {opts, callback} = getCallback(opts0, callback0);
+ function copyDoc (docSrc, docDest, opts0, callback0) {
+ const {opts, callback} = getCallback(opts0, callback0)
const qs = {
db: dbName,
doc: docSrc,
method: 'COPY',
headers: {'Destination': docDest}
- };
+ }
if (opts.overwrite) {
- return headDoc(docDest, function(e, b, h) {
+ return headDoc(docDest, function (e, b, h) {
if (e && e.statusCode !== 404) {
- return callback(e);
+ return callback(e)
}
if (h.etag) {
qs.headers.Destination += '?rev=' +
- h.etag.substring(1, h.etag.length - 1);
+ h.etag.substring(1, h.etag.length - 1)
}
- return relax(qs, callback);
- });
+ return relax(qs, callback)
+ })
} else {
- return relax(qs, callback);
+ return relax(qs, callback)
}
}
// http://docs.couchdb.org/en/latest/api/database/bulk-api.html#get--db-_all_docs
- function listDoc(qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
- return relax({db: dbName, path: '_all_docs', qs: opts}, callback);
+ function listDoc (qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
+ return relax({db: dbName, path: '_all_docs', qs: opts}, callback)
}
// http://docs.couchdb.org/en/latest/api/database/bulk-api.html#get--db-_all_docs
- function listDocAsStream(qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
- return relax({db: dbName, path: '_all_docs', qs: opts, stream: true}, callback);
+ function listDocAsStream (qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
+ return relax({db: dbName, path: '_all_docs', qs: opts, stream: true}, callback)
}
// http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs
- function fetchDocs(docNames, qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
- opts['include_docs'] = true;
+ function fetchDocs (docNames, qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
+ opts['include_docs'] = true
return relax({
db: dbName,
@@ -571,55 +563,53 @@ module.exports = exports = nano = function dbScope(cfg) {
method: 'POST',
qs: opts,
body: docNames
- }, callback);
+ }, callback)
}
- function fetchRevs(docNames, qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
+ function fetchRevs (docNames, qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
return relax({
db: dbName,
path: '_all_docs',
method: 'POST',
qs: opts,
body: docNames
- }, callback);
+ }, callback)
}
- function view(ddoc, viewName, meta, qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
+ function view (ddoc, viewName, meta, qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
if (typeof meta.stream !== 'boolean') {
- meta.stream = false;
+ meta.stream = false
}
// prevent mutation of the client qs object by using a clone
- const qs1 = Object.assign({}, opts);
+ const qs1 = Object.assign({}, opts)
- const viewPath = '_design/' + ddoc + '/_' + meta.type + '/' + viewName;
+ const viewPath = '_design/' + ddoc + '/_' + meta.type + '/' + viewName
// Several search parameters must be JSON-encoded; but since this is an
// object API, several parameters need JSON endoding.
- const paramsToEncode = ['counts', 'drilldown', 'group_sort', 'ranges', 'sort'];
- paramsToEncode.forEach(function(param) {
+ const paramsToEncode = ['counts', 'drilldown', 'group_sort', 'ranges', 'sort']
+ paramsToEncode.forEach(function (param) {
if (param in qs1) {
if (typeof qs1[param] !== 'string') {
- qs1[param] = JSON.stringify(qs1[param]);
+ qs1[param] = JSON.stringify(qs1[param])
} else {
// if the parameter is not already encoded, encode it
try {
- JSON.parse(qs1[param]);
- } catch(e) {
- qs1[param] = JSON.stringify(qs1[param]);
+ JSON.parse(qs1[param])
+ } catch (e) {
+ qs1[param] = JSON.stringify(qs1[param])
}
}
}
- });
-
-
+ })
if (qs1 && qs1.keys) {
- const body = {keys: qs1.keys};
- delete qs1.keys;
+ const body = {keys: qs1.keys}
+ delete qs1.keys
return relax({
db: dbName,
path: viewPath,
@@ -627,7 +617,7 @@ module.exports = exports = nano = function dbScope(cfg) {
qs: qs1,
body: body,
stream: meta.stream
- }, callback);
+ }, callback)
} else {
const req = {
db: dbName,
@@ -635,107 +625,106 @@ module.exports = exports = nano = function dbScope(cfg) {
path: viewPath,
qs: qs1,
stream: meta.stream
- };
+ }
if (meta.body) {
- req.body = meta.body;
+ req.body = meta.body
}
- return relax(req, callback);
+ return relax(req, callback)
}
}
// http://docs.couchdb.org/en/latest/api/ddoc/views.html#post--db-_design-ddoc-_view-view
- function viewDocs(ddoc, viewName, qs, callback) {
- return view(ddoc, viewName, {type: 'view'}, qs, callback);
+ function viewDocs (ddoc, viewName, qs, callback) {
+ return view(ddoc, viewName, {type: 'view'}, qs, callback)
}
// http://docs.couchdb.org/en/latest/api/ddoc/views.html#post--db-_design-ddoc-_view-view
- function viewDocsAsStream(ddoc, viewName, qs, callback) {
- return view(ddoc, viewName, {type: 'view', stream: true}, qs, callback);
+ function viewDocsAsStream (ddoc, viewName, qs, callback) {
+ return view(ddoc, viewName, {type: 'view', stream: true}, qs, callback)
}
-
// geocouch
- function viewSpatial(ddoc, viewName, qs, callback) {
- return view(ddoc, viewName, {type: 'spatial'}, qs, callback);
+ function viewSpatial (ddoc, viewName, qs, callback) {
+ return view(ddoc, viewName, {type: 'spatial'}, qs, callback)
}
// cloudant
- function viewSearch(ddoc, viewName, qs, callback) {
- return view(ddoc, viewName, {type: 'search'}, qs, callback);
+ function viewSearch (ddoc, viewName, qs, callback) {
+ return view(ddoc, viewName, {type: 'search'}, qs, callback)
}
// cloudant
- function viewSearchAsStream(ddoc, viewName, qs, callback) {
- return view(ddoc, viewName, {type: 'search', stream: true}, qs, callback);
+ function viewSearchAsStream (ddoc, viewName, qs, callback) {
+ return view(ddoc, viewName, {type: 'search', stream: true}, qs, callback)
}
// http://docs.couchdb.org/en/latest/api/ddoc/render.html#get--db-_design-ddoc-_show-func
- function showDoc(ddoc, viewName, docName, qs, callback) {
- return view(ddoc, viewName + '/' + docName, {type: 'show'}, qs, callback);
+ function showDoc (ddoc, viewName, docName, qs, callback) {
+ return view(ddoc, viewName + '/' + docName, {type: 'show'}, qs, callback)
}
// http://docs.couchdb.org/en/latest/api/ddoc/render.html#put--db-_design-ddoc-_update-func-docid
- function updateWithHandler(ddoc, viewName, docName, body, callback) {
+ function updateWithHandler (ddoc, viewName, docName, body, callback) {
if (typeof body === 'function') {
- callback = body;
- body = undefined;
+ callback = body
+ body = undefined
}
return view(ddoc, viewName + '/' + encodeURIComponent(docName), {
type: 'update',
method: 'PUT',
body: body
- }, callback);
+ }, callback)
}
- function viewWithList(ddoc, viewName, listName, qs, callback) {
+ function viewWithList (ddoc, viewName, listName, qs, callback) {
return view(ddoc, listName + '/' + viewName, {
type: 'list'
- }, qs, callback);
+ }, qs, callback)
}
// http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_bulksDoc
- function bulksDoc(docs, qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
+ function bulksDoc (docs, qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
return relax({
db: dbName,
path: '_bulk_docs',
body: docs,
method: 'POST',
qs: opts
- }, callback);
+ }, callback)
}
// http://docs.couchdb.org/en/latest/api/document/common.html#creating-multiple-attachments
- function insertMultipart(doc, attachments, qs, callback) {
+ function insertMultipart (doc, attachments, qs, callback) {
if (typeof qs === 'string') {
- qs = {docName: qs};
+ qs = {docName: qs}
}
- qs = qs || {};
+ qs = qs || {}
- const docName = qs.docName;
- delete qs.docName;
+ const docName = qs.docName
+ delete qs.docName
- doc = Object.assign({_attachments: {}}, doc);
+ doc = Object.assign({_attachments: {}}, doc)
- const multipart = [];
+ const multipart = []
- attachments.forEach(function(att) {
+ attachments.forEach(function (att) {
doc._attachments[att.name] = {
follows: true,
- length: Buffer.isBuffer(att.data) ?
- att.data.length : Buffer.byteLength(att.data),
+ length: Buffer.isBuffer(att.data)
+ ? att.data.length : Buffer.byteLength(att.data),
/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
'content_type': att.content_type
- };
- multipart.push({body: att.data});
- });
+ }
+ multipart.push({body: att.data})
+ })
multipart.unshift({
'content-type': 'application/json',
body: JSON.stringify(doc)
- });
+ })
return relax({
db: dbName,
@@ -744,12 +733,12 @@ module.exports = exports = nano = function dbScope(cfg) {
doc: docName,
qs: qs,
multipart: multipart
- }, callback);
+ }, callback)
}
- function getMultipart(docName, qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
- opts.attachments = true;
+ function getMultipart (docName, qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
+ opts.attachments = true
return relax({
db: dbName,
@@ -757,11 +746,11 @@ module.exports = exports = nano = function dbScope(cfg) {
encoding: null,
accept: 'multipart/related',
qs: opts
- }, callback);
+ }, callback)
}
- function insertAtt(docName, attName, att, contentType, qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
+ function insertAtt (docName, attName, att, contentType, qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
return relax({
db: dbName,
att: attName,
@@ -771,11 +760,11 @@ module.exports = exports = nano = function dbScope(cfg) {
qs: opts,
body: att,
dontStringify: true
- }, callback);
+ }, callback)
}
- function insertAttAsStream(docName, attName, att, contentType, qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
+ function insertAttAsStream (docName, attName, att, contentType, qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
return relax({
db: dbName,
att: attName,
@@ -786,11 +775,11 @@ module.exports = exports = nano = function dbScope(cfg) {
body: att,
stream: true,
dontStringify: true
- }, callback);
+ }, callback)
}
- function getAtt(docName, attName, qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
+ function getAtt (docName, attName, qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
return relax({
db: dbName,
att: attName,
@@ -798,11 +787,11 @@ module.exports = exports = nano = function dbScope(cfg) {
qs: opts,
encoding: null,
dontParse: true
- }, callback);
+ }, callback)
}
- function getAttAsStream(docName, attName, qs0, callback0) {
- const {opts, callback} = getCallback(qs0, callback0);
+ function getAttAsStream (docName, attName, qs0, callback0) {
+ const {opts, callback} = getCallback(qs0, callback0)
return relax({
db: dbName,
att: attName,
@@ -811,17 +800,17 @@ module.exports = exports = nano = function dbScope(cfg) {
stream: true,
encoding: null,
dontParse: true
- }, callback);
+ }, callback)
}
- function destroyAtt(docName, attName, qs, callback) {
+ function destroyAtt (docName, attName, qs, callback) {
return relax({
db: dbName,
att: attName,
method: 'DELETE',
doc: docName,
qs: qs
- }, callback);
+ }, callback)
}
function find (selector, callback) {
@@ -830,7 +819,7 @@ module.exports = exports = nano = function dbScope(cfg) {
path: '_find',
method: 'POST',
body: selector
- }, callback);
+ }, callback)
}
function findAsStream (selector, callback) {
@@ -840,37 +829,37 @@ module.exports = exports = nano = function dbScope(cfg) {
method: 'POST',
body: selector,
stream: true
- }, callback);
+ }, callback)
}
- function createIndex(indexDef, callback) {
+ function createIndex (indexDef, callback) {
return relax({
db: dbName,
path: '_index',
method: 'POST',
body: indexDef
- }, callback);
+ }, callback)
}
// db level exports
docScope = {
- info: function(cb) {
- return getDb(dbName, cb);
+ info: function (cb) {
+ return getDb(dbName, cb)
},
- replicate: function(target, opts, cb) {
- return replicateDb(dbName, target, opts, cb);
+ replicate: function (target, opts, cb) {
+ return replicateDb(dbName, target, opts, cb)
},
- compact: function(cb) {
- return compactDb(dbName, cb);
+ compact: function (cb) {
+ return compactDb(dbName, cb)
},
- changes: function(qs, cb) {
- return changesDb(dbName, qs, cb);
+ changes: function (qs, cb) {
+ return changesDb(dbName, qs, cb)
},
- changesAsStream: function(qs, cb) {
- return changesDbAsStream(dbName, qs, cb);
+ changesAsStream: function (qs, cb) {
+ return changesDbAsStream(dbName, qs, cb)
},
- follow: function(qs, cb) {
- return followDb(dbName, qs, cb);
+ follow: function (qs, cb) {
+ return followDb(dbName, qs, cb)
},
auth: auth,
session: session,
@@ -910,23 +899,23 @@ module.exports = exports = nano = function dbScope(cfg) {
viewWithList: viewWithList,
server: serverScope,
replication: {
- enable: function(target, opts, cb) {
- return enableReplication(dbName, target, opts, cb);
+ enable: function (target, opts, cb) {
+ return enableReplication(dbName, target, opts, cb)
},
- disable: function(id, revision, opts, cb) {
- return disableReplication(id, revision, opts, cb);
+ disable: function (id, revision, opts, cb) {
+ return disableReplication(id, revision, opts, cb)
},
- query: function(id, opts, cb) {
- return queryReplication(id, opts, cb);
+ query: function (id, opts, cb) {
+ return queryReplication(id, opts, cb)
}
}
- };
+ }
- docScope.view.compact = function(ddoc, cb) {
- return compactDb(dbName, ddoc, cb);
- };
+ docScope.view.compact = function (ddoc, cb) {
+ return compactDb(dbName, ddoc, cb)
+ }
- return docScope;
+ return docScope
}
// server level exports
@@ -961,12 +950,12 @@ module.exports = exports = nano = function dbScope(cfg) {
updates: updates,
followUpdates: followUpdates,
uuids: uuids
- });
+ })
- const db = maybeExtractDatabaseComponent();
+ const db = maybeExtractDatabaseComponent()
- return db ? docModule(db) : serverScope;
-};
+ return db ? docModule(db) : serverScope
+}
/*
* and now an ascii dinosaur
@@ -979,9 +968,9 @@ module.exports = exports = nano = function dbScope(cfg) {
* thanks for visiting! come again!
*/
-function urlResolveFix(couchUrl, dbName) {
- if (/[^\/]$/.test(couchUrl)) {
- couchUrl += '/';
+function urlResolveFix (couchUrl, dbName) {
+ if (/[^/]$/.test(couchUrl)) {
+ couchUrl += '/'
}
- return u.resolve(couchUrl, dbName);
+ return u.resolve(couchUrl, dbName)
}
diff --git a/package.json b/package.json
index fd9fc64..79e7124 100644
--- a/package.json
+++ b/package.json
@@ -26,19 +26,19 @@
},
"devDependencies": {
"async": "^2.1.2",
- "tape": "^4.6.2",
+ "endswith": "^0.0.0",
"istanbul": "^0.4.5",
"jshint": "^2.9.4",
"nock": "^9.0.0",
- "endswith": "^0.0.0",
+ "standard": "^11.0.1",
+ "tape": "^4.6.2",
"tape-it": "^0.3.1"
},
"scripts": {
- "test": "bash scripts/run_couchdb_on_travis.sh; npm run mocha; bash scripts/stop_couchdb_on_travis.sh",
+ "test": "standard; bash scripts/run_couchdb_on_travis.sh; npm run mocha; bash scripts/stop_couchdb_on_travis.sh",
"mocha": "DEBUG=* NOCK_OFF=true istanbul cover tape tests/*/*/*.js",
"unmocked": "NOCK_OFF=true tape tests/*/*/*.js",
"mocked": "tape tests/*/*/*.js",
- "jshint": "jshint tests/*/*/*.js lib/*.js",
"coverage": "open coverage/lcov-report/index.html",
"checkcoverage": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100"
},
diff --git a/tests/helpers/index.js b/tests/helpers/index.js
index 8cbebdc..0072502 100644
--- a/tests/helpers/index.js
+++ b/tests/helpers/index.js
@@ -10,32 +10,31 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const path = require('path');
-const fs = require('fs');
-const url = require('url');
-const nano = require('../../lib/nano');
+const path = require('path')
+const fs = require('fs')
+const url = require('url')
+const nano = require('../../lib/nano')
-const helpers = exports;
-const cfg = helpers.cfg = require('../fixtures/cfg');
-const auth = url.parse(cfg.admin).auth.split(':');
+const helpers = exports
+const cfg = helpers.cfg = require('../fixtures/cfg')
+const auth = url.parse(cfg.admin).auth.split(':')
-helpers.noopTest = function(t){ t.end(); };
-helpers.timeout = cfg.timeout;
-helpers.nano = nano(cfg.couch);
-helpers.Nano = nano;
-helpers.couch = cfg.couch;
-helpers.admin = cfg.admin;
+helpers.noopTest = function (t) { t.end() }
+helpers.timeout = cfg.timeout
+helpers.nano = nano(cfg.couch)
+helpers.Nano = nano
+helpers.couch = cfg.couch
+helpers.admin = cfg.admin
helpers.pixel = 'Qk06AAAAAAAAADYAAAAoAAAAAQAAAP////8BABgAAAAA' +
- 'AAAAAAATCwAAEwsAAAAAAAAAAAAAWm2CAA==';
+ 'AAAAAAATCwAAEwsAAAAAAAAAAAAAWm2CAA=='
-helpers.username = auth[0];
-helpers.password = auth[1];
+helpers.username = auth[0]
+helpers.password = auth[1]
-helpers.loadFixture = function helpersLoadFixture(filename, json) {
+helpers.loadFixture = function helpersLoadFixture (filename, json) {
const contents = fs.readFileSync(
- path.join(__dirname, '..', 'fixtures', filename), (json ? 'ascii' : null));
- return json ? JSON.parse(contents) : contents;
-};
-
+ path.join(__dirname, '..', 'fixtures', filename), (json ? 'ascii' : null))
+ return json ? JSON.parse(contents) : contents
+}
diff --git a/tests/helpers/integration.js b/tests/helpers/integration.js
index 340c72f..7fc4999 100644
--- a/tests/helpers/integration.js
+++ b/tests/helpers/integration.js
@@ -10,111 +10,111 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
-
-const async = require('async');
-const debug = require('debug');
-const path = require('path');
-const harness = require('tape-it');
-const endsWith = require('endswith');
-const cfg = require('../fixtures/cfg');
-const nano = require('../../lib/nano');
-const helpers = require('./');
-
-helpers.setup = function() {
- const self = this;
- const args = Array.prototype.slice.call(arguments);
-
- return function(assert) {
- args.push(function(err) {
- assert.equal(err, null, 'create database');
- assert.end();
- });
-
- self.nano.db.create.apply(this, args);
- };
-};
-
-helpers.teardown = function() {
- const self = this;
- const args = Array.prototype.slice.call(arguments);
-
- return function(assert) {
- args.push(function(err) {
- assert.equal(err, null, 'destroy database');
- assert.ok(self.mock.isDone(), 'mocks didn\'t run');
- assert.end();
- });
-
- self.nano.db.destroy.apply(this, args);
- };
-};
-
-helpers.harness = function(name, setup, teardown) {
- const parent = name || module.parent.filename;
- const fileName = path.basename(parent).split('.')[0];
+'use strict'
+
+const async = require('async')
+const debug = require('debug')
+const path = require('path')
+const harness = require('tape-it')
+const endsWith = require('endswith')
+const cfg = require('../fixtures/cfg')
+const nano = require('../../lib/nano')
+const helpers = require('./')
+
+helpers.setup = function () {
+ const self = this
+ const args = Array.prototype.slice.call(arguments)
+
+ return function (assert) {
+ args.push(function (err) {
+ assert.equal(err, null, 'create database')
+ assert.end()
+ })
+
+ self.nano.db.create.apply(this, args)
+ }
+}
+
+helpers.teardown = function () {
+ const self = this
+ const args = Array.prototype.slice.call(arguments)
+
+ return function (assert) {
+ args.push(function (err) {
+ assert.equal(err, null, 'destroy database')
+ assert.ok(self.mock.isDone(), 'mocks didn\'t run')
+ assert.end()
+ })
+
+ self.nano.db.destroy.apply(this, args)
+ }
+}
+
+helpers.harness = function (name, setup, teardown) {
+ const parent = name || module.parent.filename
+ const fileName = path.basename(parent).split('.')[0]
const parentDir = path.dirname(parent)
- .split(path.sep).reverse()[0];
- const shortPath = path.join(parentDir, fileName);
- const log = debug(path.join('nano', 'tests', 'integration', shortPath));
- const dbName = shortPath.replace('/', '_');
+ .split(path.sep).reverse()[0]
+ const shortPath = path.join(parentDir, fileName)
+ const log = debug(path.join('nano', 'tests', 'integration', shortPath))
+ const dbName = shortPath.replace('/', '_')
const nanoLog = nano({
url: cfg.couch,
log: log
- });
+ })
- const mock = helpers.nock(helpers.couch, shortPath, log);
- const db = nanoLog.use(dbName);
+ const mock = helpers.nock(helpers.couch, shortPath, log)
+ const db = nanoLog.use(dbName)
const locals = {
mock: mock,
db: db,
nano: nanoLog
- };
+ }
return harness({
id: shortPath,
timeout: helpers.timeout,
checkLeaks: !!process.env.LEAKS,
locals: locals,
- setup: setup ? setup : helpers.setup.call(locals, dbName),
- teardown: teardown ? teardown : helpers.teardown.call(locals, dbName)
- });
-};
-
-helpers.nock = function helpersNock(url, fixture, log) {
- const nock = require('nock');
- const nockDefs = require('../fixtures/' + fixture + '.json');
-
- nockDefs.forEach(function(n) {
- let headers = n.headers || {};
- const response = n.buffer ? endsWith(n.buffer, '.png') ?
- helpers.loadFixture(n.buffer) : new Buffer(n.buffer, 'base64') :
- n.response || '';
- const body = n.base64 ? new Buffer(n.base64, 'base64').toString() :
- n.body || '';
+ setup: setup || helpers.setup.call(locals, dbName),
+ teardown: teardown || helpers.teardown.call(locals, dbName)
+ })
+}
+
+helpers.nock = function helpersNock (url, fixture, log) {
+ const nock = require('nock')
+ const nockDefs = require('../fixtures/' + fixture + '.json')
+
+ nockDefs.forEach(function (n) {
+ let headers = n.headers || {}
+ const response = n.buffer ? endsWith(n.buffer, '.png')
+ ? helpers.loadFixture(n.buffer) : Buffer.from(n.buffer, 'base64')
+ : n.response || ''
+ const body = n.base64 ? Buffer.from(n.base64, 'base64').toString()
+ : n.body || ''
if (typeof headers === 'string' && endsWith(headers, '.json')) {
- headers = require(path.join(fixture, headers));
+ headers = require(path.join(fixture, headers))
}
- n.method = n.method || 'get';
- n.options = {log: log};
- n.scope = url;
- n.headers = headers;
- n.response = response;
- n.body = body;
+ n.method = n.method || 'get'
+ n.options = {log: log}
+ n.scope = url
+ n.headers = headers
+ n.response = response
+ n.body = body
- return n;
- });
+ return n
+ })
- nock.define(nockDefs);
+ nock.define(nockDefs)
- return nock(url);
-};
+ return nock(url)
+}
-helpers.prepareAView = function(assert, search, db) {
- search = search || '';
- db = db || this.db;
+helpers.prepareAView = function (assert, search, db) {
+ search = search || ''
+ db = db || this.db
db.insert({
views: {
@@ -125,72 +125,71 @@ helpers.prepareAView = function(assert, search, db) {
lists: {
'my_list': 'function(head, req) { send(\'Hello\'); }'
}
- }, '_design/people' + search, function(error, response) {
- assert.equal(error, null, 'should create view');
- assert.equal(response.ok, true, 'response is good');
+ }, '_design/people' + search, function (error, response) {
+ assert.equal(error, null, 'should create view')
+ assert.equal(response.ok, true, 'response is good')
async.parallel([
- function(cb) {
+ function (cb) {
db.insert({
name: 'Derek',
city: 'San Francisco'
- }, 'p_derek', cb);
- }, function(cb) {
+ }, 'p_derek', cb)
+ }, function (cb) {
db.insert({
name: 'Randall',
city: 'San Francisco'
- }, 'p_randall', cb);
- }, function(cb) {
+ }, 'p_randall', cb)
+ }, function (cb) {
db.insert({
name: 'Nuno',
city: 'London'
- }, 'p_nuno', cb);
+ }, 'p_nuno', cb)
}
- ], function(error) {
- assert.equal(error, null, 'store the peeps');
- assert.end();
- });
- });
-};
-
-helpers.viewDerek = function viewDerek(db, assert, opts, next, method) {
- method = method || 'view';
- db[method]('people','by_name_and_city', opts, function(error, view) {
- assert.equal(error, null, 'no errors');
- assert.equal(view.rows.length,1);
- assert.equal(view.rows.length,1);
- assert.equal(view.rows[0].id,'p_derek');
- assert.equal(view.rows[0].key[0],'Derek');
- assert.equal(view.rows[0].key[1],'San Francisco');
- next(error);
- });
-};
-
-helpers.insertOne = function insertThree(assert) {
- const db = this.db;
- db.insert({'foo': 'baz'}, 'foobaz', function(err) {
- assert.equal(err, null, 'should store docs');
- assert.end();
- });
-};
-
-helpers.insertThree = function insertThree(assert) {
- const db = this.db;
+ ], function (error) {
+ assert.equal(error, null, 'store the peeps')
+ assert.end()
+ })
+ })
+}
+
+helpers.viewDerek = function viewDerek (db, assert, opts, next, method) {
+ method = method || 'view'
+ db[method]('people', 'by_name_and_city', opts, function (error, view) {
+ assert.equal(error, null, 'no errors')
+ assert.equal(view.rows.length, 1)
+ assert.equal(view.rows.length, 1)
+ assert.equal(view.rows[0].id, 'p_derek')
+ assert.equal(view.rows[0].key[0], 'Derek')
+ assert.equal(view.rows[0].key[1], 'San Francisco')
+ next(error)
+ })
+}
+
+helpers.insertOne = function insertThree (assert) {
+ const db = this.db
+ db.insert({'foo': 'baz'}, 'foobaz', function (err) {
+ assert.equal(err, null, 'should store docs')
+ assert.end()
+ })
+}
+
+helpers.insertThree = function insertThree (assert) {
+ const db = this.db
async.parallel([
- function(cb) { db.insert({'foo': 'bar'}, 'foobar', cb); },
- function(cb) { db.insert({'bar': 'foo'}, 'barfoo', cb); },
- function(cb) { db.insert({'foo': 'baz'}, 'foobaz', cb); }
- ], function(error) {
- assert.equal(error, null, 'should store docs');
- assert.end();
- });
-};
-
-helpers.unmocked = (process.env.NOCK_OFF === 'true');
-helpers.mocked = !helpers.unmocked;
-
-helpers.isPromise = function(p) {
- return (p && typeof p === 'object' && typeof p.then === 'function')
+ function (cb) { db.insert({'foo': 'bar'}, 'foobar', cb) },
+ function (cb) { db.insert({'bar': 'foo'}, 'barfoo', cb) },
+ function (cb) { db.insert({'foo': 'baz'}, 'foobaz', cb) }
+ ], function (error) {
+ assert.equal(error, null, 'should store docs')
+ assert.end()
+ })
}
-module.exports = helpers;
+helpers.unmocked = (process.env.NOCK_OFF === 'true')
+helpers.mocked = !helpers.unmocked
+
+helpers.isPromise = function (p) {
+ return (p && typeof p === 'object' && typeof p.then === 'function')
+}
+module.exports = helpers
diff --git a/tests/helpers/unit.js b/tests/helpers/unit.js
index a15dfc6..4ce7591 100644
--- a/tests/helpers/unit.js
+++ b/tests/helpers/unit.js
@@ -10,52 +10,52 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('./');
-const Client = require('../../lib/nano');
-const test = require('tape');
-const _ = require('underscore');
+const helpers = require('./')
+const Client = require('../../lib/nano')
+const test = require('tape')
+const _ = require('underscore')
-helpers.unit = function(method, error) {
- const unitName = 'nano/tests/unit/' + method.join('/');
- const debug = require('debug')(unitName);
+helpers.unit = function (method, error) {
+ const unitName = 'nano/tests/unit/' + method.join('/')
+ const debug = require('debug')(unitName)
- function log(data) {
- debug({ got: data.body });
+ function log (data) {
+ debug({ got: data.body })
}
- let cli = helpers.mockClientOk(log, error);
+ let cli = helpers.mockClientOk(log, error)
//
// allow database creation and other server stuff
//
- if(method[1].match(/follow/)) {
- if(method[0] === 'database') {
- cli.server = helpers.mockClientFollow(log, error);
+ if (method[1].match(/follow/)) {
+ if (method[0] === 'database') {
+ cli.server = helpers.mockClientFollow(log, error)
} else {
- cli = helpers.mockClientFollow(log, error);
+ cli = helpers.mockClientFollow(log, error)
}
} else {
- cli.server = helpers.mockClientDb(log, error);
+ cli.server = helpers.mockClientDb(log, error)
}
- let testNr = 1;
+ let testNr = 1
- return function() {
- const args = Array.prototype.slice.call(arguments);
- const stub = args.pop();
+ return function () {
+ const args = Array.prototype.slice.call(arguments)
+ const stub = args.pop()
test(unitName + ':' + testNr++,
- function(assert) {
- let f;
- assert.ok(typeof stub, 'object');
-
- //
- // document functions and database functions
- // are at the top level in nano
- //
- if(method[0] === 'database') {
+ function (assert) {
+ let f
+ assert.ok(typeof stub, 'object')
+
+ //
+ // document functions and database functions
+ // are at the top level in nano
+ //
+ if (method[0] === 'database') {
//
// Due to the way this harness is designed we cannot differentiate between different methods
// when those methods are embedded on an object.
@@ -63,98 +63,98 @@ helpers.unit = function(method, error) {
// can differentiate between methods embedded on an object.
// I go the hardcoded route for now.
//
- if (method[1] === 'replicator') {
- f = cli.server.db.replication.enable;
- } else {
- f = cli.server.db[method[1]];
- }
- } else if(method[0] === 'view' && method[1] === 'compact') {
- f = cli.view.compact;
- } else if(!~['multipart', 'attachment'].indexOf(method[0])) {
- f = cli[method[1]];
- } else {
- f = cli[method[0]][method[1]];
- }
- assert.ok(typeof f, 'function');
-
- args.push(function(err, req, response) {
- if (error) {
- assert.ok(err);
- return assert.end();
- }
-
- assert.equal(response.statusCode, 200);
- if(stub.uri) {
- stub.uri = helpers.couch + stub.uri;
+ if (method[1] === 'replicator') {
+ f = cli.server.db.replication.enable
+ } else {
+ f = cli.server.db[method[1]]
+ }
+ } else if (method[0] === 'view' && method[1] === 'compact') {
+ f = cli.view.compact
+ } else if (!~['multipart', 'attachment'].indexOf(method[0])) {
+ f = cli[method[1]]
} else {
- stub.db = helpers.couch + stub.db;
+ f = cli[method[0]][method[1]]
}
+ assert.ok(typeof f, 'function')
+
+ args.push(function (err, req, response) {
+ if (error) {
+ assert.ok(err)
+ return assert.end()
+ }
+
+ assert.equal(response.statusCode, 200)
+ if (stub.uri) {
+ stub.uri = helpers.couch + stub.uri
+ } else {
+ stub.db = helpers.couch + stub.db
+ }
+
+ assert.deepEqual(req, stub)
+ assert.end()
+ })
+ f.apply(null, args)
+ })
+ }
+}
- assert.deepEqual(req, stub);
- assert.end();
- });
- f.apply(null, args);
- });
- };
-};
-
-function mockClient(code, path, extra) {
- return function(debug, error) {
- extra = extra || {};
+function mockClient (code, path, extra) {
+ return function (debug, error) {
+ extra = extra || {}
const opts = _.extend(extra, {
url: helpers.couch + path,
log: debug,
- request: function(req, cb) {
- if(error) {
- return cb(error);
+ request: function (req, cb) {
+ if (error) {
+ return cb(error)
}
- if(code === 500) {
- cb(new Error('omg connection failed'));
+ if (code === 500) {
+ cb(new Error('omg connection failed'))
} else {
cb(null, {
statusCode: code,
headers: {}
- }, req); }
+ }, req)
}
- });
+ }
+ })
- return Client(opts);
- };
+ return Client(opts)
+ }
}
-function mockClientUnparsedError() {
- return function(debug, body) {
+function mockClientUnparsedError () {
+ return function (debug, body) {
return Client({
url: helpers.couch,
log: debug,
- request: function(_, cb) {
- return cb(null, {statusCode: 500}, body || '<b> Error happened </b>');
+ request: function (_, cb) {
+ return cb(null, {statusCode: 500}, body || '<b> Error happened </b>')
}
- });
- };
+ })
+ }
}
-function mockClientFollow() {
- return function(debug, error) {
+function mockClientFollow () {
+ return function (debug, error) {
return Client({
url: helpers.couch,
log: debug,
- follow: function(qs, cb) {
- if(error) {
- return cb(error);
+ follow: function (qs, cb) {
+ if (error) {
+ return cb(error)
}
- return cb(null, qs, {statusCode: 200});
+ return cb(null, qs, {statusCode: 200})
}
- });
- };
+ })
+ }
}
-
-helpers.mockClientFollow = mockClientFollow();
-helpers.mockClientUnparsedError = mockClientUnparsedError();
-helpers.mockClientDb = mockClient(200, '');
-helpers.mockClientOk = mockClient(200, '/mock');
-helpers.mockClientFail = mockClient(500, '');
-helpers.mockClientJar = mockClient(300, '', {jar: 'is set'});
-module.exports = helpers;
+helpers.mockClientFollow = mockClientFollow()
+helpers.mockClientUnparsedError = mockClientUnparsedError()
+helpers.mockClientDb = mockClient(200, '')
+helpers.mockClientOk = mockClient(200, '/mock')
+helpers.mockClientFail = mockClient(500, '')
+helpers.mockClientJar = mockClient(300, '', {jar: 'is set'})
+module.exports = helpers
diff --git a/tests/integration/attachment/destroy.js b/tests/integration/attachment/destroy.js
index cae9552..3953ca5 100644
--- a/tests/integration/attachment/destroy.js
+++ b/tests/integration/attachment/destroy.js
@@ -10,46 +10,47 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
-it('should be able to insert a new plain text attachment', function(assert) {
+it('should be able to insert a new plain text attachment', function (assert) {
const p = db.attachment.insert('new',
- 'att', 'Hello World!', 'text/plain', function(error, att) {
- assert.equal(error, null, 'store the attachment');
- assert.equal(att.ok, true, 'response ok');
- assert.ok(att.rev, 'have a revision number');
- db.attachment.destroy('new', 'att', {rev: att.rev},
- function(error, response) {
- assert.equal(error, null, 'delete the attachment');
- assert.equal(response.ok, true, 'response ok');
- assert.equal(response.id, 'new', '`id` should be `new`');
- });
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(response) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(response.ok, true, 'response ok');
- assert.equal(response.id, 'new', '`id` should be `new`');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ 'att', 'Hello World!', 'text/plain', function (error, att) {
+ assert.equal(error, null, 'store the attachment')
+ assert.equal(att.ok, true, 'response ok')
+ assert.ok(att.rev, 'have a revision number')
+ db.attachment.destroy('new', 'att', {rev: att.rev},
+ function (error, response) {
+ assert.equal(error, null, 'delete the attachment')
+ assert.equal(response.ok, true, 'response ok')
+ assert.equal(response.id, 'new', '`id` should be `new`')
+ })
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (response) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(response.ok, true, 'response ok')
+ assert.equal(response.id, 'new', '`id` should be `new`')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should fail destroying with a bad filename', function(assert) {
- const p = db.attachment.destroy('new', false, true, function(error, response) {
- assert.equal(response, undefined, 'no response should be given');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function() {
- assert.ok(false, 'Promise is resolved');
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- assert.end();
- });
-});
+it('should fail destroying with a bad filename', function (assert) {
+ const p = db.attachment.destroy('new', false, true, function (error, response) {
+ if (error) throw (error) // eslint
+ assert.equal(response, undefined, 'no response should be given')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function () {
+ assert.ok(false, 'Promise is resolved')
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ assert.end()
+ })
+})
diff --git a/tests/integration/attachment/get.js b/tests/integration/attachment/get.js
index 12c20ba..2a0481e 100644
--- a/tests/integration/attachment/get.js
+++ b/tests/integration/attachment/get.js
@@ -10,53 +10,53 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
-it('should be able to fetch an attachment', function(assert) {
+it('should be able to fetch an attachment', function (assert) {
db.attachment.insert('new_string', 'att', 'Hello', 'text/plain',
- function(error, hello) {
- assert.equal(error, null, 'should store `hello`');
- assert.equal(hello.ok, true, 'response ok');
- assert.ok(hello.rev, 'should have a revision number');
- const p = db.attachment.get('new_string', 'att',
- function(error, helloWorld) {
- assert.equal(error, null, 'should get `hello`');
- assert.equal('Hello', helloWorld.toString(), 'string is reflexive');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(s) {
- assert.ok(true, 'Promise is resolved');
- assert.equal('Hello', s.toString(), 'string is reflexive');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
- });
-});
+ function (error, hello) {
+ assert.equal(error, null, 'should store `hello`')
+ assert.equal(hello.ok, true, 'response ok')
+ assert.ok(hello.rev, 'should have a revision number')
+ const p = db.attachment.get('new_string', 'att',
+ function (error, helloWorld) {
+ assert.equal(error, null, 'should get `hello`')
+ assert.equal('Hello', helloWorld.toString(), 'string is reflexive')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (s) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal('Hello', s.toString(), 'string is reflexive')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+ })
+})
-it('should insert and fetch a binary file', function(assert) {
- db.attachment.insert('new_binary', 'att', new Buffer('123'),
- 'text/plain', function(error, hello) {
- assert.equal(error, null, 'should store `123`');
- assert.equal(hello.ok, true, 'response ok');
- assert.ok(hello.rev, 'should have a revision number');
- const p = db.attachment.get('new_binary', 'att',
- function(error, binaryData) {
- assert.equal(error, null, 'should get the binary data');
- assert.equal('123', binaryData.toString(), 'binary data is reflexive');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(binaryData) {
- assert.ok(true, 'Promise is resolved');
- assert.equal('123', binaryData.toString(), 'binary data is reflexive');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
- });
-});
+it('should insert and fetch a binary file', function (assert) {
+ db.attachment.insert('new_binary', 'att', Buffer.from('123'),
+ 'text/plain', function (error, hello) {
+ assert.equal(error, null, 'should store `123`')
+ assert.equal(hello.ok, true, 'response ok')
+ assert.ok(hello.rev, 'should have a revision number')
+ const p = db.attachment.get('new_binary', 'att',
+ function (error, binaryData) {
+ assert.equal(error, null, 'should get the binary data')
+ assert.equal('123', binaryData.toString(), 'binary data is reflexive')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (binaryData) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal('123', binaryData.toString(), 'binary data is reflexive')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+ })
+})
diff --git a/tests/integration/attachment/insert.js b/tests/integration/attachment/insert.js
index 6389592..5e2415a 100644
--- a/tests/integration/attachment/insert.js
+++ b/tests/integration/attachment/insert.js
@@ -10,27 +10,27 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
-it('should be able to insert a simple attachment', function(assert) {
+it('should be able to insert a simple attachment', function (assert) {
const p = db.attachment.insert('new', 'att', 'Hello World!', 'text/plain',
- function(error, att) {
- assert.equal(error, null, 'should store the attachment');
- assert.equal(att.ok, true, 'response ok');
- assert.ok(att.rev, 'should have a revision');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(att) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(att.ok, true, 'response ok');
- assert.ok(att.rev, 'should have a revision');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ function (error, att) {
+ assert.equal(error, null, 'should store the attachment')
+ assert.equal(att.ok, true, 'response ok')
+ assert.ok(att.rev, 'should have a revision')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (att) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(att.ok, true, 'response ok')
+ assert.ok(att.rev, 'should have a revision')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/attachment/pipe.js b/tests/integration/attachment/pipe.js
index e81ff08..5a19f1f 100644
--- a/tests/integration/attachment/pipe.js
+++ b/tests/integration/attachment/pipe.js
@@ -10,58 +10,58 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const fs = require('fs');
-const path = require('path');
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const it = harness.it;
-const pixel = helpers.pixel;
+const fs = require('fs')
+const path = require('path')
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const it = harness.it
+const pixel = helpers.pixel
-it('should be able to pipe to a writeStream', function(assert) {
- const buffer = new Buffer(pixel, 'base64');
- const filename = path.join(__dirname, '.temp.bmp');
- const ws = fs.createWriteStream(filename);
+it('should be able to pipe to a writeStream', function (assert) {
+ const buffer = Buffer.from(pixel, 'base64')
+ const filename = path.join(__dirname, '.temp.bmp')
+ const ws = fs.createWriteStream(filename)
- ws.on('close', function() {
- assert.equal(fs.readFileSync(filename).toString('base64'), pixel);
- fs.unlinkSync(filename);
- assert.end();
- });
+ ws.on('close', function () {
+ assert.equal(fs.readFileSync(filename).toString('base64'), pixel)
+ fs.unlinkSync(filename)
+ assert.end()
+ })
db.attachment.insert('new', 'att', buffer, 'image/bmp',
- function(error, bmp) {
- assert.equal(error, null, 'Should store the pixel');
- db.attachment.getAsStream('new', 'att', {rev: bmp.rev}).pipe(ws);
- });
-});
+ function (error, bmp) {
+ assert.equal(error, null, 'Should store the pixel')
+ db.attachment.getAsStream('new', 'att', {rev: bmp.rev}).pipe(ws)
+ })
+})
-it('should be able to pipe to a writeStream', function(assert) {
- const ws = fs.createWriteStream('/dev/null');
- db.attachment.getAsStream('new', 'att', function() {})
+it('should be able to pipe to a writeStream', function (assert) {
+ const ws = fs.createWriteStream('/dev/null')
+ db.attachment.getAsStream('new', 'att', function () {})
.pipe(ws)
- .on('end', function() {
- assert.end();
- });
-});
+ .on('end', function () {
+ assert.end()
+ })
+})
-it('should be able to pipe from a readStream', function(assert) {
- const logo = path.join(__dirname, '..', '..', 'fixtures', 'logo.png');
- const rs = fs.createReadStream(logo);
- const is = db.attachment.insertAsStream('nodejs', 'logo.png', null, 'image/png', function() {
- });
+it('should be able to pipe from a readStream', function (assert) {
+ const logo = path.join(__dirname, '..', '..', 'fixtures', 'logo.png')
+ const rs = fs.createReadStream(logo)
+ const is = db.attachment.insertAsStream('nodejs', 'logo.png', null, 'image/png', function () {
+ })
- is.on('end', function() {
- db.attachment.get('nodejs', 'logo.png', function(err, buffer) {
- assert.equal(err, null, 'should get the logo');
+ is.on('end', function () {
+ db.attachment.get('nodejs', 'logo.png', function (err, buffer) {
+ assert.equal(err, null, 'should get the logo')
assert.equal(
fs.readFileSync(logo).toString('base64'), buffer.toString('base64'),
- 'logo should remain unchanged');
- assert.end();
- });
- });
+ 'logo should remain unchanged')
+ assert.end()
+ })
+ })
- rs.pipe(is);
-});
+ rs.pipe(is)
+})
diff --git a/tests/integration/attachment/update.js b/tests/integration/attachment/update.js
index 7d3bae8..3eaa8fe 100644
--- a/tests/integration/attachment/update.js
+++ b/tests/integration/attachment/update.js
@@ -10,48 +10,48 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const pixel = helpers.pixel;
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const pixel = helpers.pixel
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const it = harness.it
-let rev;
+let rev // eslint-disable-line
-it('should be able to insert and update attachments', function(assert) {
- const buffer = new Buffer(pixel, 'base64');
+it('should be able to insert and update attachments', function (assert) {
+ const buffer = Buffer.from(pixel, 'base64')
db.attachment.insert('new', 'att', 'Hello', 'text/plain',
- function(error, hello) {
- assert.equal(error, null, 'should store hello');
- assert.equal(hello.ok, true, 'response ok');
- assert.ok(hello.rev, 'should have a revision');
- const p = db.attachment.insert('new', 'att', buffer, 'image/bmp',
- {rev: hello.rev}, function(error, bmp) {
- assert.equal(error, null, 'should store the pixel');
- assert.ok(bmp.rev, 'should store a revision');
- rev = bmp.rev;
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(s) {
- assert.ok(true, 'Promise is resolved');
- assert.ok(s.rev, 'should store a revision');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
- });
-});
+ function (error, hello) {
+ assert.equal(error, null, 'should store hello')
+ assert.equal(hello.ok, true, 'response ok')
+ assert.ok(hello.rev, 'should have a revision')
+ const p = db.attachment.insert('new', 'att', buffer, 'image/bmp',
+ {rev: hello.rev}, function (error, bmp) {
+ assert.equal(error, null, 'should store the pixel')
+ assert.ok(bmp.rev, 'should store a revision')
+ rev = bmp.rev
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (s) {
+ assert.ok(true, 'Promise is resolved')
+ assert.ok(s.rev, 'should store a revision')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+ })
+})
-it('should be able to fetch the updated pixel', function(assert) {
- db.get('new', function(error, newDoc) {
- assert.equal(error, null, 'should get new');
- newDoc.works = true;
- db.insert(newDoc, 'new', function(error, response) {
- assert.equal(error, null, 'should update doc');
- assert.equal(response.ok, true, 'response ok');
- assert.end();
- });
- });
-});
+it('should be able to fetch the updated pixel', function (assert) {
+ db.get('new', function (error, newDoc) {
+ assert.equal(error, null, 'should get new')
+ newDoc.works = true
+ db.insert(newDoc, 'new', function (error, response) {
+ assert.equal(error, null, 'should update doc')
+ assert.equal(response.ok, true, 'response ok')
+ assert.end()
+ })
+ })
+})
diff --git a/tests/integration/database/changes.js b/tests/integration/database/changes.js
index b223f9b..8ff6463 100644
--- a/tests/integration/database/changes.js
+++ b/tests/integration/database/changes.js
@@ -10,45 +10,45 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const it = harness.it
-it('should be able to insert three documents', helpers.insertThree);
+it('should be able to insert three documents', helpers.insertThree)
-it('should be able to receive changes since seq:0', function(assert) {
- const p = db.changes({since:0}, function(error, response) {
- assert.equal(error, null, 'gets response from changes');
- assert.equal(response.results.length, 3, 'gets three results');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(response) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(response.results.length, 3, 'gets three results');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be able to receive changes since seq:0', function (assert) {
+ const p = db.changes({since: 0}, function (error, response) {
+ assert.equal(error, null, 'gets response from changes')
+ assert.equal(response.results.length, 3, 'gets three results')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (response) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(response.results.length, 3, 'gets three results')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be able to receive changes since seq:0 as stream', function(assert) {
- const p = db.changesAsStream({since:0}, function(error, response) {
- assert.equal(error, null, 'gets response from changes');
- assert.equal(response.results.length, 3, 'gets three results');
- assert.end();
- });
- assert.ok(!helpers.isPromise(p), 'returns Promise');
- assert.equal(p.constructor.name, 'Request', 'returns a Request');
-});
+it('should be able to receive changes since seq:0 as stream', function (assert) {
+ const p = db.changesAsStream({since: 0}, function (error, response) {
+ assert.equal(error, null, 'gets response from changes')
+ assert.equal(response.results.length, 3, 'gets three results')
+ assert.end()
+ })
+ assert.ok(!helpers.isPromise(p), 'returns Promise')
+ assert.equal(p.constructor.name, 'Request', 'returns a Request')
+})
-it('should be able to receive changes - no params - stream', function(assert) {
- const p = db.changesAsStream(function(error) {
- assert.equal(error, null, 'gets response from changes');
- assert.end();
- });
- assert.ok(!helpers.isPromise(p), 'returns Promise');
- assert.equal(p.constructor.name, 'Request', 'returns a Request');
-});
+it('should be able to receive changes - no params - stream', function (assert) {
+ const p = db.changesAsStream(function (error) {
+ assert.equal(error, null, 'gets response from changes')
+ assert.end()
+ })
+ assert.ok(!helpers.isPromise(p), 'returns Promise')
+ assert.equal(p.constructor.name, 'Request', 'returns a Request')
+})
diff --git a/tests/integration/database/compact.js b/tests/integration/database/compact.js
index ef6137f..f13dae4 100644
--- a/tests/integration/database/compact.js
+++ b/tests/integration/database/compact.js
@@ -10,59 +10,59 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
-it('should store and delete `goofy`', function(assert) {
- db.insert({'foo': 'baz'}, 'goofy', function(error, foo) {
- assert.equal(error, null, 'should have stored foo');
- assert.equal(foo.ok, true, 'response should be ok');
- db.destroy('goofy', foo.rev, function(error, response) {
- assert.equal(error, null, 'should have deleted foo');
- assert.equal(response.ok, true, 'response ok');
- assert.end();
- });
- });
-});
+it('should store and delete `goofy`', function (assert) {
+ db.insert({'foo': 'baz'}, 'goofy', function (error, foo) {
+ assert.equal(error, null, 'should have stored foo')
+ assert.equal(foo.ok, true, 'response should be ok')
+ db.destroy('goofy', foo.rev, function (error, response) {
+ assert.equal(error, null, 'should have deleted foo')
+ assert.equal(response.ok, true, 'response ok')
+ assert.end()
+ })
+ })
+})
-it('should have run the compaction', function(assert) {
- const p = db.compact(function(error) {
- assert.equal(error, null, 'compact should respond');
- db.info(function(error, info) {
- assert.equal(error, null, 'info should respond');
- assert.equal(info['doc_count'], 0, 'document count is not 3');
- assert.equal(info['doc_del_count'], 1, 'document should be deleted');
- });
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(info) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(info['doc_count'], 0, 'document count is not 3');
- assert.equal(info['doc_del_count'], 1, 'document should be deleted');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should have run the compaction', function (assert) {
+ const p = db.compact(function (error) {
+ assert.equal(error, null, 'compact should respond')
+ db.info(function (error, info) {
+ assert.equal(error, null, 'info should respond')
+ assert.equal(info['doc_count'], 0, 'document count is not 3')
+ assert.equal(info['doc_del_count'], 1, 'document should be deleted')
+ })
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (info) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(info['doc_count'], 0, 'document count is not 3')
+ assert.equal(info['doc_del_count'], 1, 'document should be deleted')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should finish compaction before ending', function(assert) {
- function nextWhenFinished() {
- db.info(function(err, info) {
+it('should finish compaction before ending', function (assert) {
+ function nextWhenFinished () {
+ db.info(function (err, info) {
if (err) {
- return;
+ return
}
if (info['compact_running']) {
- return;
+ return
}
- clearTimeout(task);
- assert.pass('compaction is complete');
- assert.end();
- });
+ clearTimeout(task)
+ assert.pass('compaction is complete')
+ assert.end()
+ })
}
- const task = setInterval(nextWhenFinished, 100);
-});
+ const task = setInterval(nextWhenFinished, 100)
+})
diff --git a/tests/integration/database/create-and-destroy.js b/tests/integration/database/create-and-destroy.js
index af8259c..fd9e99b 100644
--- a/tests/integration/database/create-and-destroy.js
+++ b/tests/integration/database/create-and-destroy.js
@@ -10,34 +10,34 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const async = require('async');
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const nano = harness.locals.nano;
+const async = require('async')
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const nano = harness.locals.nano
-it('should be able to create `az09_$()+-/` database', function(assert) {
- nano.db.create('az09_$()+-/', function(err) {
- assert.equal(err, null, 'should create database');
- assert.end();
- });
-});
+it('should be able to create `az09_$()+-/` database', function (assert) {
+ nano.db.create('az09_$()+-/', function (err) {
+ assert.equal(err, null, 'should create database')
+ assert.end()
+ })
+})
it('should be able to use config from a nano object to create a db',
-function(assert) {
- const config = helpers.Nano(
- helpers.couch + '/' + encodeURIComponent('with/slash')).config;
- helpers.Nano(config.url).db.create(config.db, function(err) {
- assert.equal(err, null, 'should create database');
- assert.end();
- });
-});
+ function (assert) {
+ const config = helpers.Nano(
+ helpers.couch + '/' + encodeURIComponent('with/slash')).config
+ helpers.Nano(config.url).db.create(config.db, function (err) {
+ assert.equal(err, null, 'should create database')
+ assert.end()
+ })
+ })
-it('must destroy the databases we created', function(assert) {
- async.forEach(['az09_$()+-/', 'with/slash'], nano.db.destroy, function(err) {
- assert.equal(err, null, 'should destroy all dbs');
- assert.end();
- });
-});
+it('must destroy the databases we created', function (assert) {
+ async.forEach(['az09_$()+-/', 'with/slash'], nano.db.destroy, function (err) {
+ assert.equal(err, null, 'should destroy all dbs')
+ assert.end()
+ })
+})
diff --git a/tests/integration/database/follow.js b/tests/integration/database/follow.js
index 42ce686..79bde16 100644
--- a/tests/integration/database/follow.js
+++ b/tests/integration/database/follow.js
@@ -10,41 +10,41 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
if (helpers.unmocked) {
- it('should insert a bunch of items', helpers.insertThree);
+ it('should insert a bunch of items', helpers.insertThree)
- let feed1;
+ let feed1
- it('should be able to get the changes feed', function(assert) {
- let i = 3;
+ it('should be able to get the changes feed', function (assert) {
+ let i = 3
- feed1 = db.follow({since: '0'});
+ feed1 = db.follow({since: '0'})
- feed1.on('change', function(change) {
- assert.ok(change, 'change existed');
- //assert.equal(change.seq, i + 1, 'seq is set correctly');
- ++i;
+ feed1.on('change', function (change) {
+ assert.ok(change, 'change existed')
+ // assert.equal(change.seq, i + 1, 'seq is set correctly');
+ ++i
if (i === 4) {
- assert.end();
+ assert.end()
}
- });
+ })
- feed1.follow();
+ feed1.follow()
- setTimeout(function() {
- db.insert({'bar': 'baz'}, 'barbaz');
- }, 100);
- });
+ setTimeout(function () {
+ db.insert({'bar': 'baz'}, 'barbaz')
+ }, 100)
+ })
- it('should clear changes feed', function(assert) {
- feed1.die();
- assert.end();
- });
+ it('should clear changes feed', function (assert) {
+ feed1.die()
+ assert.end()
+ })
}
diff --git a/tests/integration/database/get.js b/tests/integration/database/get.js
index a01ece8..25a8199 100644
--- a/tests/integration/database/get.js
+++ b/tests/integration/database/get.js
@@ -10,44 +10,44 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const nano = harness.locals.nano;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const nano = harness.locals.nano
-it('should be able to fetch the database', function(assert) {
- const p = nano.db.get('database_get', function(error, response) {
- assert.equal(error, null, 'should get the db');
- assert.equal(response['doc_count'], 0, 'should be empty');
- assert.equal(response['db_name'], 'database_get', 'name');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(response) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(response['doc_count'], 0, 'should be empty');
- assert.equal(response['db_name'], 'database_get', 'name');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be able to fetch the database', function (assert) {
+ const p = nano.db.get('database_get', function (error, response) {
+ assert.equal(error, null, 'should get the db')
+ assert.equal(response['doc_count'], 0, 'should be empty')
+ assert.equal(response['db_name'], 'database_get', 'name')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (response) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(response['doc_count'], 0, 'should be empty')
+ assert.equal(response['db_name'], 'database_get', 'name')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('resolves db URL correctly for http://app.com/_couchdb', function(assert) {
- const nano = require('../../../lib/nano');
+it('resolves db URL correctly for http://app.com/_couchdb', function (assert) {
+ const nano = require('../../../lib/nano')
const couch = nano({
url: 'http://app.com/_couchdb/',
parseUrl: false,
- request: function(options) {
+ request: function (options) {
assert.equal(
options.uri,
'http://app.com/_couchdb/mydb/mydoc',
'should get doc at prefixed path'
- );
- assert.end();
+ )
+ assert.end()
}
- });
- couch.use('mydb').get('mydoc');
-});
+ })
+ couch.use('mydb').get('mydoc')
+})
diff --git a/tests/integration/database/list.js b/tests/integration/database/list.js
index aa35a47..07994b1 100644
--- a/tests/integration/database/list.js
+++ b/tests/integration/database/list.js
@@ -10,36 +10,36 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const nano = harness.locals.nano;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const nano = harness.locals.nano
-it('should ensure _replicator and _users are created', function(assert) {
- nano.db.create('_replicator', function() {
- nano.db.destroy('_users', function() {
- nano.db.create('_users', function() {
- assert.end();
- });
- });
- });
-});
+it('should ensure _replicator and _users are created', function (assert) {
+ nano.db.create('_replicator', function () {
+ nano.db.destroy('_users', function () {
+ nano.db.create('_users', function () {
+ assert.end()
+ })
+ })
+ })
+})
-it('should list the correct databases', function(assert) {
- const p = nano.db.list(function(error, list) {
- assert.equal(error, null, 'should list databases');
- const filtered = list.filter(function(e) {
- return e === 'database_list' || e === '_replicator' || e === '_users';
- });
- assert.equal(filtered.length, 3, 'should have exactly 3 dbs');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function() {
- assert.ok(true, 'Promise is resolved');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should list the correct databases', function (assert) {
+ const p = nano.db.list(function (error, list) {
+ assert.equal(error, null, 'should list databases')
+ const filtered = list.filter(function (e) {
+ return e === 'database_list' || e === '_replicator' || e === '_users'
+ })
+ assert.equal(filtered.length, 3, 'should have exactly 3 dbs')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function () {
+ assert.ok(true, 'Promise is resolved')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/database/replicate.js b/tests/integration/database/replicate.js
index 5ca95aa..724ba20 100644
--- a/tests/integration/database/replicate.js
+++ b/tests/integration/database/replicate.js
@@ -10,78 +10,78 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const async = require('async');
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
-const nano = harness.locals.nano;
+const async = require('async')
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
+const nano = harness.locals.nano
-let replica;
-let replica2;
+let replica
+let replica2
-it('should insert a bunch of items', helpers.insertThree);
+it('should insert a bunch of items', helpers.insertThree)
-it('creates a bunch of database replicas', function(assert) {
+it('creates a bunch of database replicas', function (assert) {
async.forEach(['database_replica', 'database_replica2'],
- nano.db.create, function(error) {
- assert.equal(error, null, 'created database(s)');
- assert.end();
- });
-});
+ nano.db.create, function (error) {
+ assert.equal(error, null, 'created database(s)')
+ assert.end()
+ })
+})
-it('should be able to replicate three docs', function(assert) {
- replica = nano.use('database_replica');
+it('should be able to replicate three docs', function (assert) {
+ replica = nano.use('database_replica')
- const p = db.replicate('database_replica', function(error) {
- assert.equal(error, null, 'replication should work');
- replica.list(function(error, list) {
- assert.equal(error, null, 'should be able to invoke list');
- assert.equal(list['total_rows'], 3, 'and have three documents');
- });
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(list) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(list['total_rows'], 3, 'and have three documents');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ const p = db.replicate('database_replica', function (error) {
+ assert.equal(error, null, 'replication should work')
+ replica.list(function (error, list) {
+ assert.equal(error, null, 'should be able to invoke list')
+ assert.equal(list['total_rows'], 3, 'and have three documents')
+ })
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (list) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(list['total_rows'], 3, 'and have three documents')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be able to replicate to a `nano` object', function(assert) {
- replica2 = nano.use('database_replica2');
+it('should be able to replicate to a `nano` object', function (assert) {
+ replica2 = nano.use('database_replica2')
- nano.db.replicate(db, replica2, function(error) {
- assert.equal(error, null, 'should replicate');
- replica2.list(function(error, list) {
- assert.equal(error, null, 'should list');
- assert.equal(list['total_rows'], 3, 'and have three documents');
- assert.end();
- });
- });
-});
+ nano.db.replicate(db, replica2, function (error) {
+ assert.equal(error, null, 'should replicate')
+ replica2.list(function (error, list) {
+ assert.equal(error, null, 'should list')
+ assert.equal(list['total_rows'], 3, 'and have three documents')
+ assert.end()
+ })
+ })
+})
-it('should be able to replicate with params', function(assert) {
- const p = db.replicate('database_replica', {}, function(error) {
- assert.equal(error, null, 'replication should work');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function() {
- assert.ok(true, 'Promise is resolved');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be able to replicate with params', function (assert) {
+ const p = db.replicate('database_replica', {}, function (error) {
+ assert.equal(error, null, 'replication should work')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function () {
+ assert.ok(true, 'Promise is resolved')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should destroy the extra databases', function(assert) {
+it('should destroy the extra databases', function (assert) {
async.forEach(['database_replica', 'database_replica2'],
- nano.db.destroy, function(error) {
- assert.equal(error, null, 'deleted databases');
- assert.end();
- });
-});
+ nano.db.destroy, function (error) {
+ assert.equal(error, null, 'deleted databases')
+ assert.end()
+ })
+})
diff --git a/tests/integration/database/replicator.js b/tests/integration/database/replicator.js
index 0585292..f48506d 100644
--- a/tests/integration/database/replicator.js
+++ b/tests/integration/database/replicator.js
@@ -10,120 +10,126 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const async = require('async');
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
-const nano = harness.locals.nano;
+const async = require('async')
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
+const nano = harness.locals.nano
-let replica;
-let replica2;
-let replica3;
+let replica
+let replica2
+let replica3
-it('should insert a bunch of items', helpers.insertThree);
+it('should insert a bunch of items', helpers.insertThree)
-it('creates a bunch of database replicas', function(assert) {
- async.forEach(['database_replica', 'database_replica2', 'database_replica3'],
- nano.db.create, function(error) {
- assert.equal(error, null, 'created database(s)');
- assert.end();
- });
-});
+it('creates a bunch of database replicas', function (assert) {
+ async.forEach(['database_replica', 'database_replica2', 'database_replica3'],
+ nano.db.create, function (error) {
+ assert.equal(error, null, 'created database(s)')
+ assert.end()
+ })
+})
-it('should be able to replicate (replicator) three docs', function(assert) {
- replica = nano.use('database_replica');
- db.replication.enable('database_replica', function(error, data) {
- assert.equal(error, null, 'replication should not fail');
- assert.true(data, 'replication should be scheduled');
- assert.true(data.ok, 'replication should be scheduled');
- assert.true(data.id, 'replication should return the id to query back');
- function waitForReplication() {
- setTimeout(function() {
- db.replication.query(data.id, function(error, reply) {
- assert.equal(reply.target, 'database_replica', 'target db should match');
- assert.equal(reply._replication_state, 'triggered', 'replication should have triggered');
- replica.list(function(error, list) {
- assert.equal(error, null, 'should be able to invoke list');
- assert.equal(list['total_rows'], 3, 'and have three documents');
- db.replication.disable(reply._id, reply._rev, function(error, disabled) {
- assert.true(disabled, 'should not be null');
- assert.true(disabled.ok, 'should have stopped the replication');
- assert.end();
- });
- });
- });
+it('should be able to replicate (replicator) three docs', function (assert) {
+ replica = nano.use('database_replica')
+ db.replication.enable('database_replica', function (error, data) {
+ assert.equal(error, null, 'replication should not fail')
+ assert.true(data, 'replication should be scheduled')
+ assert.true(data.ok, 'replication should be scheduled')
+ assert.true(data.id, 'replication should return the id to query back')
+ function waitForReplication () {
+ setTimeout(function () {
+ db.replication.query(data.id, function (error, reply) {
+ assert.equal(error, null, 'replication query should not fail')
+ assert.equal(reply.target, 'database_replica', 'target db should match')
+ assert.equal(reply._replication_state, 'triggered', 'replication should have triggered')
+ replica.list(function (error, list) {
+ assert.equal(error, null, 'should be able to invoke list')
+ assert.equal(list['total_rows'], 3, 'and have three documents')
+ db.replication.disable(reply._id, reply._rev, function (error, disabled) {
+ assert.equal(error, null, 'replication disable should not fail')
+ assert.true(disabled, 'should not be null')
+ assert.true(disabled.ok, 'should have stopped the replication')
+ assert.end()
+ })
+ })
+ })
},
- 3000);
+ 3000)
}
- waitForReplication();
- });
-});
+ waitForReplication()
+ })
+})
-it('should be able to replicate (replicator) to a `nano` object', function(assert) {
- replica2 = nano.use('database_replica2');
- nano.db.replication.enable(db, 'database_replica2', function(error, data) {
- assert.equal(error, null, 'replication should not fail');
- assert.true(data, 'replication should be scheduled');
- assert.true(data.ok, 'replication should be scheduled');
- assert.true(data.id, 'replication should return the id to query back');
- function waitForReplication() {
- setTimeout(function() {
- nano.db.replication.query(data.id, function(error, reply) {
- assert.equal(reply.target, 'database_replica2', 'target db should match');
- assert.equal(reply._replication_state, 'triggered', 'replication should have triggered');
- replica2.list(function(error, list) {
- assert.equal(error, null, 'should be able to invoke list');
- assert.equal(list['total_rows'], 3, 'and have three documents');
- nano.db.replication.disable(reply._id, reply._rev, function(error, disabled) {
- assert.true(disabled, 'should not be null');
- assert.true(disabled.ok, 'should have stopped the replication');
- assert.end();
- });
- });
- });
+it('should be able to replicate (replicator) to a `nano` object', function (assert) {
+ replica2 = nano.use('database_replica2')
+ nano.db.replication.enable(db, 'database_replica2', function (error, data) {
+ assert.equal(error, null, 'replication should not fail')
+ assert.true(data, 'replication should be scheduled')
+ assert.true(data.ok, 'replication should be scheduled')
+ assert.true(data.id, 'replication should return the id to query back')
+ function waitForReplication () {
+ setTimeout(function () {
+ nano.db.replication.query(data.id, function (error, reply) {
+ assert.equal(error, null, 'replication query should not fail')
+ assert.equal(reply.target, 'database_replica2', 'target db should match')
+ assert.equal(reply._replication_state, 'triggered', 'replication should have triggered')
+ replica2.list(function (error, list) {
+ assert.equal(error, null, 'should be able to invoke list')
+ assert.equal(list['total_rows'], 3, 'and have three documents')
+ nano.db.replication.disable(reply._id, reply._rev, function (error, disabled) {
+ assert.equal(error, null, 'replication disable should not fail')
+ assert.true(disabled, 'should not be null')
+ assert.true(disabled.ok, 'should have stopped the replication')
+ assert.end()
+ })
+ })
+ })
},
- 3000);
+ 3000)
}
- waitForReplication();
- });
-});
+ waitForReplication()
+ })
+})
-it('should be able to replicate (replicator) with params', function(assert) {
- replica3 = nano.use('database_replica3');
- db.replication.enable('database_replica3', {}, function(error, data) {
- assert.equal(error, null, 'replication should not fail');
- assert.true(data, 'replication should be scheduled');
- assert.true(data.ok, 'replication should be scheduled');
- assert.true(data.id, 'replication should return the id to query back');
- function waitForReplication() {
- setTimeout(function() {
- db.replication.query(data.id, function(error, reply) {
- assert.equal(reply.target, 'database_replica3', 'target db should match');
- assert.equal(reply._replication_state, 'triggered', 'replication should have triggered');
- replica3.list(function(error, list) {
- assert.equal(error, null, 'should be able to invoke list');
- assert.equal(list['total_rows'], 3, 'and have three documents');
- db.replication.disable(reply._id, reply._rev, function(error, disabled) {
- assert.true(disabled, 'should not be null');
- assert.true(disabled.ok, 'should have stopped the replication');
- assert.end();
- });
- });
- });
+it('should be able to replicate (replicator) with params', function (assert) {
+ replica3 = nano.use('database_replica3')
+ db.replication.enable('database_replica3', {}, function (error, data) {
+ assert.equal(error, null, 'replication should not fail')
+ assert.true(data, 'replication should be scheduled')
+ assert.true(data.ok, 'replication should be scheduled')
+ assert.true(data.id, 'replication should return the id to query back')
+ function waitForReplication () {
+ setTimeout(function () {
+ db.replication.query(data.id, function (error, reply) {
+ assert.equal(error, null, 'replication query should not fail')
+ assert.equal(reply.target, 'database_replica3', 'target db should match')
+ assert.equal(reply._replication_state, 'triggered', 'replication should have triggered')
+ replica3.list(function (error, list) {
+ assert.equal(error, null, 'should be able to invoke list')
+ assert.equal(list['total_rows'], 3, 'and have three documents')
+ db.replication.disable(reply._id, reply._rev, function (error, disabled) {
+ assert.equal(error, null, 'replication disable should not fail')
+ assert.true(disabled, 'should not be null')
+ assert.true(disabled.ok, 'should have stopped the replication')
+ assert.end()
+ })
+ })
+ })
},
- 3000);
+ 3000)
}
- waitForReplication();
- });
-});
+ waitForReplication()
+ })
+})
-it('should destroy the extra databases', function(assert) {
- async.forEach(['database_replica', 'database_replica2', 'database_replica3'],
- nano.db.destroy, function(error) {
- assert.equal(error, null, 'deleted databases');
- assert.end();
- });
-});
+it('should destroy the extra databases', function (assert) {
+ async.forEach(['database_replica', 'database_replica2', 'database_replica3'],
+ nano.db.destroy, function (error) {
+ assert.equal(error, null, 'deleted databases')
+ assert.end()
+ })
+})
diff --git a/tests/integration/design/atomic.js b/tests/integration/design/atomic.js
index 2c18848..c3d4a0d 100644
--- a/tests/integration/design/atomic.js
+++ b/tests/integration/design/atomic.js
@@ -10,76 +10,76 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
-let rev;
+let rev // eslint-disable-line
-it('should be able to insert an atomic design doc', function(assert) {
+it('should be able to insert an atomic design doc', function (assert) {
const p = db.insert({
updates: {
- inplace: function(doc, req) {
- const body = JSON.parse(req.body);
- doc[body.field] = body.value;
- return [doc, JSON.stringify(doc)];
+ inplace: function (doc, req) {
+ const body = JSON.parse(req.body)
+ doc[body.field] = body.value
+ return [doc, JSON.stringify(doc)]
},
addbaz: function (doc) {
- doc.baz = "biz";
- return [doc, JSON.stringify(doc)];
+ doc.baz = 'biz'
+ return [doc, JSON.stringify(doc)]
}
}
- }, '_design/update', function(err) {
- assert.equal(err, null, 'should be no problems officer');
- db.insert({'foo': 'baz'}, 'foobar', function(error, foo) {
- assert.equal(error, null, 'stores teh foo');
- assert.equal(foo.ok, true, 'does not have an attitude');
- assert.ok(foo.rev, 'got the revisions');
- rev = foo.rev;
- assert.end();
- });
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
-});
+ }, '_design/update', function (err) {
+ assert.equal(err, null, 'should be no problems officer')
+ db.insert({'foo': 'baz'}, 'foobar', function (error, foo) {
+ assert.equal(error, null, 'stores teh foo')
+ assert.equal(foo.ok, true, 'does not have an attitude')
+ assert.ok(foo.rev, 'got the revisions')
+ rev = foo.rev
+ assert.end()
+ })
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+})
-it('should be able to insert atomically', function(assert) {
+it('should be able to insert atomically', function (assert) {
const p = db.atomic('update', 'inplace', 'foobar', {
field: 'foo',
value: 'bar'
- }, function(error, response) {
- assert.equal(error, null, 'should be able to update');
- assert.equal(response.foo, 'bar', 'and the right value was set');
- assert.end();
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
-});
+ }, function (error, response) {
+ assert.equal(error, null, 'should be able to update')
+ assert.equal(response.foo, 'bar', 'and the right value was set')
+ assert.end()
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+})
it('should be able to update atomically without a body', function (assert) {
const p = db.insert({}, 'baz', function () {
db.atomic('update', 'addbaz', 'baz', function (error, response) {
- assert.equal(error, null, 'should be able to update');
- assert.equal(response.baz, 'biz', 'and the new field is present');
- assert.end();
- });
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
-});
+ assert.equal(error, null, 'should be able to update')
+ assert.equal(response.baz, 'biz', 'and the new field is present')
+ assert.end()
+ })
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+})
-it('should be able to update with slashes on the id', function(assert) {
- const p = db.insert({'wat': 'wat'}, 'wat/wat', function(error, foo) {
- assert.equal(error, null, 'stores `wat`');
- assert.equal(foo.ok, true, 'response ok');
+it('should be able to update with slashes on the id', function (assert) {
+ const p = db.insert({'wat': 'wat'}, 'wat/wat', function (error, foo) {
+ assert.equal(error, null, 'stores `wat`')
+ assert.equal(foo.ok, true, 'response ok')
db.atomic('update', 'inplace', 'wat/wat', {
field: 'wat',
value: 'dawg'
- }, function(error, response) {
- assert.equal(error, null, 'should update');
- assert.equal(response.wat, 'dawg', 'with the right copy');
- assert.end();
- });
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
-});
+ }, function (error, response) {
+ assert.equal(error, null, 'should update')
+ assert.equal(response.wat, 'dawg', 'with the right copy')
+ assert.end()
+ })
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+})
diff --git a/tests/integration/design/compact.js b/tests/integration/design/compact.js
index fbcdfe4..9f5415d 100644
--- a/tests/integration/design/compact.js
+++ b/tests/integration/design/compact.js
@@ -10,33 +10,33 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const async = require('async');
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
+const async = require('async')
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
-it('should insert `alice` the design doc', function(assert) {
+it('should insert `alice` the design doc', function (assert) {
async.waterfall([
- function(next) {
+ function (next) {
db.insert({
views: {
'by_id': {
map: 'function(doc) { emit(doc._id, doc); }'
}
}
- }, '_design/alice', next);
+ }, '_design/alice', next)
},
- function(data, _, next) {
- db.insert({'foo': 'baz'}, 'foobaz', next);
+ function (data, _, next) {
+ db.insert({'foo': 'baz'}, 'foobaz', next)
},
- function(foo, _, next) {
- db.destroy('foobaz', foo.rev, next);
+ function (foo, _, next) {
+ db.destroy('foobaz', foo.rev, next)
}
- ], function(err) {
- assert.equal(err, null, 'it should destroy the foo');
- assert.end();
- });
-});
+ ], function (err) {
+ assert.equal(err, null, 'it should destroy the foo')
+ assert.end()
+ })
+})
diff --git a/tests/integration/design/list.js b/tests/integration/design/list.js
index 514638c..ec52919 100644
--- a/tests/integration/design/list.js
+++ b/tests/integration/design/list.js
@@ -10,31 +10,31 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
-it('should create a ddoc and insert some docs', helpers.prepareAView);
+it('should create a ddoc and insert some docs', helpers.prepareAView)
-it('should get the people by running the ddoc', function(assert) {
+it('should get the people by running the ddoc', function (assert) {
const p = db.viewWithList('people', 'by_name_and_city', 'my_list', {
key: [
'Derek',
'San Francisco'
]
- }, function(error, list) {
- assert.equal(error, null, 'should response');
- assert.equal(list, 'Hello', 'and list should be `hello`');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(list) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(list, 'Hello', 'and list should be `hello`');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ }, function (error, list) {
+ assert.equal(error, null, 'should response')
+ assert.equal(list, 'Hello', 'and list should be `hello`')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (list) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(list, 'Hello', 'and list should be `hello`')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/design/multiple.js b/tests/integration/design/multiple.js
index 6205638..78c670c 100644
--- a/tests/integration/design/multiple.js
+++ b/tests/integration/design/multiple.js
@@ -10,69 +10,69 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
-it('should be able to insert docs and design doc', function(assert) {
+it('should be able to insert docs and design doc', function (assert) {
const p = db.insert({
views: {
'by_id': {
map: 'function(doc) { emit(doc._id, doc); }'
}
}
- }, '_design/alice', function(error, response) {
- assert.equal(error, null, 'should create views');
- assert.equal(response.ok, true, 'response ok');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(response) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(response.ok, true, 'response ok');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ }, '_design/alice', function (error, response) {
+ assert.equal(error, null, 'should create views')
+ assert.equal(response.ok, true, 'response ok')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (response) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(response.ok, true, 'response ok')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should insert a bunch of items', helpers.insertThree);
+it('should insert a bunch of items', helpers.insertThree)
-it('get multiple docs with a composed key', function(assert) {
+it('get multiple docs with a composed key', function (assert) {
const p = db.view('alice', 'by_id', {
keys: ['foobar', 'barfoo'],
'include_docs': true
- }, function(err, view) {
- assert.equal(err, null, 'should response');
- assert.equal(view.rows.length, 2, 'has more or less than two rows');
- assert.equal(view.rows[0].id, 'foobar', 'foo is not the first id');
- assert.equal(view.rows[1].id, 'barfoo', 'bar is not the second id');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(view) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(view.rows.length, 2, 'has more or less than two rows');
- assert.equal(view.rows[0].id, 'foobar', 'foo is not the first id');
- assert.equal(view.rows[1].id, 'barfoo', 'bar is not the second id');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ }, function (err, view) {
+ assert.equal(err, null, 'should response')
+ assert.equal(view.rows.length, 2, 'has more or less than two rows')
+ assert.equal(view.rows[0].id, 'foobar', 'foo is not the first id')
+ assert.equal(view.rows[1].id, 'barfoo', 'bar is not the second id')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (view) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(view.rows.length, 2, 'has more or less than two rows')
+ assert.equal(view.rows[0].id, 'foobar', 'foo is not the first id')
+ assert.equal(view.rows[1].id, 'barfoo', 'bar is not the second id')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('get multiple docs with a composed key as a stream', function(assert) {
+it('get multiple docs with a composed key as a stream', function (assert) {
const p = db.viewAsStream('alice', 'by_id', {
keys: ['foobar', 'barfoo'],
'include_docs': true
- }, function(err, view) {
- assert.equal(err, null, 'should response');
- assert.equal(view.rows.length, 2, 'has more or less than two rows');
- assert.equal(view.rows[0].id, 'foobar', 'foo is not the first id');
- assert.equal(view.rows[1].id, 'barfoo', 'bar is not the second id');
- assert.end();
- });
- assert.ok(!helpers.isPromise(p), 'does not returns Promise');
- assert.equal(p.constructor.name, 'Request', 'returns a Request');
-});
+ }, function (err, view) {
+ assert.equal(err, null, 'should response')
+ assert.equal(view.rows.length, 2, 'has more or less than two rows')
+ assert.equal(view.rows[0].id, 'foobar', 'foo is not the first id')
+ assert.equal(view.rows[1].id, 'barfoo', 'bar is not the second id')
+ assert.end()
+ })
+ assert.ok(!helpers.isPromise(p), 'does not returns Promise')
+ assert.equal(p.constructor.name, 'Request', 'returns a Request')
+})
diff --git a/tests/integration/design/query.js b/tests/integration/design/query.js
index 0d49a65..1029af0 100644
--- a/tests/integration/design/query.js
+++ b/tests/integration/design/query.js
@@ -10,32 +10,32 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const async = require('async');
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
-const viewDerek = helpers.viewDerek;
+const async = require('async')
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
+const viewDerek = helpers.viewDerek
-const opts = {key: ['Derek', 'San Francisco']};
+const opts = {key: ['Derek', 'San Francisco']}
-it('should create a ddoc and insert some docs', helpers.prepareAView);
+it('should create a ddoc and insert some docs', helpers.prepareAView)
-it('should respond with derek when asked for derek', function(assert) {
- viewDerek(db, assert, opts, assert.end);
-});
+it('should respond with derek when asked for derek', function (assert) {
+ viewDerek(db, assert, opts, assert.end)
+})
-it('should have no cloning issues when doing queries', function(assert) {
+it('should have no cloning issues when doing queries', function (assert) {
async.waterfall([
- function(next) { viewDerek(db, assert, opts, next); },
- function(next) { viewDerek(db, assert, opts, next); }
- ], function(err) {
- assert.equal(err, null, 'no errors');
- assert.ok(Array.isArray(opts.key));
- assert.equal(opts.key[0], 'Derek');
- assert.equal(opts.key[1], 'San Francisco');
- assert.end();
- });
-});
+ function (next) { viewDerek(db, assert, opts, next) },
+ function (next) { viewDerek(db, assert, opts, next) }
+ ], function (err) {
+ assert.equal(err, null, 'no errors')
+ assert.ok(Array.isArray(opts.key))
+ assert.equal(opts.key[0], 'Derek')
+ assert.equal(opts.key[1], 'San Francisco')
+ assert.end()
+ })
+})
diff --git a/tests/integration/design/search.js b/tests/integration/design/search.js
index 94c37a5..f6b1114 100644
--- a/tests/integration/design/search.js
+++ b/tests/integration/design/search.js
@@ -10,40 +10,40 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const async = require('async');
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
-const viewDerek = helpers.viewDerek;
+const async = require('async')
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
+const viewDerek = helpers.viewDerek
//
// these are cloudant only
// tests do no run without mocks
//
if (helpers.mocked) {
- const opts = {key: ['Derek', 'San Francisco']};
+ const opts = {key: ['Derek', 'San Francisco']}
- it('should create a ddoc and insert some docs', function(assert) {
- helpers.prepareAView(assert, '/_search', db);
- });
+ it('should create a ddoc and insert some docs', function (assert) {
+ helpers.prepareAView(assert, '/_search', db)
+ })
- it('should respond with derek when asked for derek', function(assert) {
- viewDerek(db, assert, opts, assert.end, 'search');
- });
+ it('should respond with derek when asked for derek', function (assert) {
+ viewDerek(db, assert, opts, assert.end, 'search')
+ })
- it('should have no cloning issues when doing queries', function(assert) {
+ it('should have no cloning issues when doing queries', function (assert) {
async.waterfall([
- function(next) { viewDerek(db, assert, opts, next, 'search'); },
- function(next) { viewDerek(db, assert, opts, next, 'search'); }
- ], function(err) {
- assert.equal(err, null, 'no errors');
- assert.ok(Array.isArray(opts.key));
- assert.equal(opts.key[0], 'Derek');
- assert.equal(opts.key[1], 'San Francisco');
- assert.end();
- });
- });
+ function (next) { viewDerek(db, assert, opts, next, 'search') },
+ function (next) { viewDerek(db, assert, opts, next, 'search') }
+ ], function (err) {
+ assert.equal(err, null, 'no errors')
+ assert.ok(Array.isArray(opts.key))
+ assert.equal(opts.key[0], 'Derek')
+ assert.equal(opts.key[1], 'San Francisco')
+ assert.end()
+ })
+ })
}
diff --git a/tests/integration/design/show.js b/tests/integration/design/show.js
index 174339f..07d7336 100644
--- a/tests/integration/design/show.js
+++ b/tests/integration/design/show.js
@@ -10,18 +10,18 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const async = require('async');
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
+const async = require('async')
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
-it('should insert a show ddoc', function(assert) {
+it('should insert a show ddoc', function (assert) {
db.insert({
shows: {
- singleDoc: function(doc, req) {
+ singleDoc: function (doc, req) {
if (req.query.format === 'json' || !req.query.format) {
return {
body: JSON.stringify({
@@ -32,7 +32,7 @@ it('should insert a show ddoc', function(assert) {
headers: {
'Content-Type': 'application/json'
}
- };
+ }
}
if (req.query.format === 'html') {
return {
@@ -40,66 +40,66 @@ it('should insert a show ddoc', function(assert) {
headers: {
'Content-Type': 'text/html'
}
- };
+ }
}
}
}
- }, '_design/people', function(error, response) {
- assert.equal(error, null, 'should start the show');
- assert.equal(response.ok, true, 'response ok');
- async.parallel([
- function(cb) {
- db.insert({
- name: 'Clemens',
- city: 'Dresden'
- }, 'p_clemens', cb);
- },
- function(cb) {
- db.insert({
- name: 'Randall',
- city: 'San Francisco'
- }, 'p_randall', cb);
- }, function(cb) {
- db.insert({
- name: 'Nuno',
- city: 'New York'
- }, 'p_nuno', cb);
- }
- ], function(error) {
- assert.equal(error, null, 'stores docs');
- assert.end();
- });
- });
-});
+ }, '_design/people', function (error, response) {
+ assert.equal(error, null, 'should start the show')
+ assert.equal(response.ok, true, 'response ok')
+ async.parallel([
+ function (cb) {
+ db.insert({
+ name: 'Clemens',
+ city: 'Dresden'
+ }, 'p_clemens', cb)
+ },
+ function (cb) {
+ db.insert({
+ name: 'Randall',
+ city: 'San Francisco'
+ }, 'p_randall', cb)
+ }, function (cb) {
+ db.insert({
+ name: 'Nuno',
+ city: 'New York'
+ }, 'p_nuno', cb)
+ }
+ ], function (error) {
+ assert.equal(error, null, 'stores docs')
+ assert.end()
+ })
+ })
+})
-it('should show the amazing clemens in json', function(assert) {
- const p = db.show('people', 'singleDoc', 'p_clemens', function(error, doc, rh) {
- assert.equal(error, null, 'its alive');
- assert.equal(rh['content-type'], 'application/json');
- assert.equal(doc.name, 'Clemens');
- assert.equal(doc.city, 'Dresden');
- assert.equal(doc.format, 'json');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(doc) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(doc.name, 'Clemens');
- assert.equal(doc.city, 'Dresden');
- assert.equal(doc.format, 'json');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should show the amazing clemens in json', function (assert) {
+ const p = db.show('people', 'singleDoc', 'p_clemens', function (error, doc, rh) {
+ assert.equal(error, null, 'its alive')
+ assert.equal(rh['content-type'], 'application/json')
+ assert.equal(doc.name, 'Clemens')
+ assert.equal(doc.city, 'Dresden')
+ assert.equal(doc.format, 'json')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (doc) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(doc.name, 'Clemens')
+ assert.equal(doc.city, 'Dresden')
+ assert.equal(doc.format, 'json')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should show the amazing clemens in html', function(assert) {
+it('should show the amazing clemens in html', function (assert) {
db.show('people', 'singleDoc', 'p_clemens', {format: 'html'},
- function(error, doc, rh) {
- assert.equal(error, null, 'should work');
- if (helpers.unmocked) {
- assert.equal(rh['content-type'], 'text/html');
- }
- assert.equal(doc, 'Hello Clemens!');
- assert.end();
- });
-});
+ function (error, doc, rh) {
+ assert.equal(error, null, 'should work')
+ if (helpers.unmocked) {
+ assert.equal(rh['content-type'], 'text/html')
+ }
+ assert.equal(doc, 'Hello Clemens!')
+ assert.end()
+ })
+})
diff --git a/tests/integration/document/bulk.js b/tests/integration/document/bulk.js
index 65dac59..01a2773 100644
--- a/tests/integration/document/bulk.js
+++ b/tests/integration/document/bulk.js
@@ -10,34 +10,34 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
-it('should be able to bulk insert two docs', function(assert) {
+it('should be able to bulk insert two docs', function (assert) {
const p = db.bulk({
'docs': [
- {'key':'baz', 'name':'bazzel'},
- {'key':'bar', 'name':'barry'}
+ {'key': 'baz', 'name': 'bazzel'},
+ {'key': 'bar', 'name': 'barry'}
]
},
- function(error, response) {
- assert.equal(error, null, 'no error');
- assert.equal(response.length, 2, 'has two docs');
- assert.ok(response[0].id, 'first got id');
- assert.ok(response[1].id, 'other also got id');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(response) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(response.length, 2, 'has two docs');
- assert.ok(response[0].id, 'first got id');
- assert.ok(response[1].id, 'other also got id');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ function (error, response) {
+ assert.equal(error, null, 'no error')
+ assert.equal(response.length, 2, 'has two docs')
+ assert.ok(response[0].id, 'first got id')
+ assert.ok(response[1].id, 'other also got id')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (response) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(response.length, 2, 'has two docs')
+ assert.ok(response[0].id, 'first got id')
+ assert.ok(response[1].id, 'other also got id')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/document/copy.js b/tests/integration/document/copy.js
index 3353b42..048b8be 100644
--- a/tests/integration/document/copy.js
+++ b/tests/integration/document/copy.js
@@ -10,67 +10,67 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
-it('must insert two docs before the tests start', function(assert) {
- db.insert({'foo': 'baz'}, 'foo_src', function(error, src) {
- assert.equal(error, null, 'stores src');
- assert.equal(src.ok, true, 'response ok');
- assert.ok(src.rev, 'haz rev');
- db.insert({'bar': 'qux'}, 'foo_dest', function(error, dest) {
- assert.equal(error, null, 'stores dest');
- assert.equal(dest.ok, true, 'oki doki');
- assert.ok(dest.rev, 'response has rev');
- assert.end();
- });
- });
-});
+it('must insert two docs before the tests start', function (assert) {
+ db.insert({'foo': 'baz'}, 'foo_src', function (error, src) {
+ assert.equal(error, null, 'stores src')
+ assert.equal(src.ok, true, 'response ok')
+ assert.ok(src.rev, 'haz rev')
+ db.insert({'bar': 'qux'}, 'foo_dest', function (error, dest) {
+ assert.equal(error, null, 'stores dest')
+ assert.equal(dest.ok, true, 'oki doki')
+ assert.ok(dest.rev, 'response has rev')
+ assert.end()
+ })
+ })
+})
-it('should be able to copy and overwrite a document', function(assert) {
+it('should be able to copy and overwrite a document', function (assert) {
const p = db.copy('foo_src', 'foo_dest', {overwrite: true},
- function(error, response, headers) {
- assert.equal(error, null,
- 'should have copied and overwritten foo_src to foo_dest');
- assert.equal(headers['statusCode'], 201, 'status code should be 201');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function() {
- assert.ok(true, 'Promise is resolved');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ function (error, response, headers) {
+ assert.equal(error, null,
+ 'should have copied and overwritten foo_src to foo_dest')
+ assert.equal(headers['statusCode'], 201, 'status code should be 201')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function () {
+ assert.ok(true, 'Promise is resolved')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
it('copy without overwrite should return conflict for exists docs',
-function(assert) {
- const p = db.copy('foo_src', 'foo_dest', function(error) {
- assert.equal(error.error, 'conflict', 'should be a conflict');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function() {
- assert.ok(false, 'Promise is resolved');
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- assert.end();
- });
-});
+ function (assert) {
+ const p = db.copy('foo_src', 'foo_dest', function (error) {
+ assert.equal(error.error, 'conflict', 'should be a conflict')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function () {
+ assert.ok(false, 'Promise is resolved')
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ assert.end()
+ })
+ })
-it('copy to a new destination should work', function(assert) {
- const p = db.copy('foo_src', 'baz_dest', function(error, response, headers) {
- assert.equal(error, null, 'copies into new document');
- assert.equal(headers['statusCode'], 201, 'Status code should be 201');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function() {
- assert.ok(true, 'Promise is resolved');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('copy to a new destination should work', function (assert) {
+ const p = db.copy('foo_src', 'baz_dest', function (error, response, headers) {
+ assert.equal(error, null, 'copies into new document')
+ assert.equal(headers['statusCode'], 201, 'Status code should be 201')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function () {
+ assert.ok(true, 'Promise is resolved')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/document/create_index.js b/tests/integration/document/create_index.js
index 6f8ce3f..6851f76 100644
--- a/tests/integration/document/create_index.js
+++ b/tests/integration/document/create_index.js
@@ -10,30 +10,30 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const it = harness.it
-it('should insert a one item', helpers.insertOne);
+it('should insert a one item', helpers.insertOne)
-it ('Should create one simple index', function(assert) {
+it('Should create one simple index', function (assert) {
const p = db.createIndex({
name: 'fooindex',
index: { fields: ['foo'] }
- }, function(error, foo) {
- assert.equal(error, null, 'should have indexed fields');
- assert.equal(foo.result, 'created', 'index should be created');
- assert.equal(foo.name, 'fooindex', 'index should have correct name');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(foo) {
- assert.equal(foo.result, 'created', 'index should be created');
- assert.equal(foo.name, 'fooindex', 'index should have correct name');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ }, function (error, foo) {
+ assert.equal(error, null, 'should have indexed fields')
+ assert.equal(foo.result, 'created', 'index should be created')
+ assert.equal(foo.name, 'fooindex', 'index should have correct name')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (foo) {
+ assert.equal(foo.result, 'created', 'index should be created')
+ assert.equal(foo.name, 'fooindex', 'index should have correct name')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/document/destroy.js b/tests/integration/document/destroy.js
index b8e3f28..d217b25 100644
--- a/tests/integration/document/destroy.js
+++ b/tests/integration/document/destroy.js
@@ -10,50 +10,50 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
-const db = harness.locals.db;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
+const db = harness.locals.db
-let rev;
+let rev
-it('should insert a document', function(assert) {
- db.insert({'foo': 'baz'}, 'foobaz', function(error, foo) {
- assert.equal(error, null, 'stores foo');
- assert.equal(foo.ok, true, 'ok response');
- assert.ok(foo.rev, 'response with rev');
- rev = foo.rev;
- assert.end();
- });
-});
+it('should insert a document', function (assert) {
+ db.insert({'foo': 'baz'}, 'foobaz', function (error, foo) {
+ assert.equal(error, null, 'stores foo')
+ assert.equal(foo.ok, true, 'ok response')
+ assert.ok(foo.rev, 'response with rev')
+ rev = foo.rev
+ assert.end()
+ })
+})
-it('should not delete a db', function(assert) {
- const p = db.destroy(undefined, undefined, function(error, response) {
- assert.equal(error, 'Invalid doc id', 'validated delete parameters');
- assert.equal(response, null, 'ok!');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function() {
- assert.ok(false, 'Promise is resolved');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should not delete a db', function (assert) {
+ const p = db.destroy(undefined, undefined, function (error, response) {
+ assert.equal(error, 'Invalid doc id', 'validated delete parameters')
+ assert.equal(response, null, 'ok!')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function () {
+ assert.ok(false, 'Promise is resolved')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should delete a document', function(assert) {
- const p = db.destroy('foobaz', rev, function(error, response) {
- assert.equal(error, null, 'deleted foo');
- assert.equal(response.ok, true, 'ok!');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(response) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(response.ok, true, 'ok!');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should delete a document', function (assert) {
+ const p = db.destroy('foobaz', rev, function (error, response) {
+ assert.equal(error, null, 'deleted foo')
+ assert.equal(response.ok, true, 'ok!')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (response) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(response.ok, true, 'ok!')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/document/fetch.js b/tests/integration/document/fetch.js
index eaf68a8..a3d0269 100644
--- a/tests/integration/document/fetch.js
+++ b/tests/integration/document/fetch.js
@@ -10,62 +10,62 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const it = harness.it
-it('should insert a bunch of items', helpers.insertThree);
+it('should insert a bunch of items', helpers.insertThree)
-it('should be able to fetch with one key', function(assert) {
- const p = db.fetch({keys:['foobar']}, function(error, docs) {
- assert.equal(error, null, 'should work');
- assert.equal(docs.rows.length, 1, 'and get one row');
- assert.equal(docs['total_rows'], 3, 'out of 3');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(docs) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(docs.rows.length, 1, 'and get one row');
- assert.equal(docs['total_rows'], 3, 'out of 3');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be able to fetch with one key', function (assert) {
+ const p = db.fetch({keys: ['foobar']}, function (error, docs) {
+ assert.equal(error, null, 'should work')
+ assert.equal(docs.rows.length, 1, 'and get one row')
+ assert.equal(docs['total_rows'], 3, 'out of 3')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (docs) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(docs.rows.length, 1, 'and get one row')
+ assert.equal(docs['total_rows'], 3, 'out of 3')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be able to fetch with multiple keys', function(assert) {
- const p = db.fetch({keys:['foobar', 'barfoo']}, function(error, docs) {
- assert.equal(error, null, 'no errors');
- assert.equal(docs.rows.length, 2, 'two rows');
- assert.equal(docs['total_rows'], 3, 'out of 3');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(docs) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(docs.rows.length, 2, 'two rows');
- assert.equal(docs['total_rows'], 3, 'out of 3');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be able to fetch with multiple keys', function (assert) {
+ const p = db.fetch({keys: ['foobar', 'barfoo']}, function (error, docs) {
+ assert.equal(error, null, 'no errors')
+ assert.equal(docs.rows.length, 2, 'two rows')
+ assert.equal(docs['total_rows'], 3, 'out of 3')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (docs) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(docs.rows.length, 2, 'two rows')
+ assert.equal(docs['total_rows'], 3, 'out of 3')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be able to fetch with params', function(assert) {
- const p = db.fetch({keys:['foobar']}, {not: 'important'}, function(error, docs) {
- assert.equal(error, null, 'should work');
- assert.equal(docs.rows.length, 1, 'and get one row');
- assert.equal(docs['total_rows'], 3, 'out of 3');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(docs) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(docs.rows.length, 1, 'and get one row');
- assert.equal(docs['total_rows'], 3, 'out of 3');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be able to fetch with params', function (assert) {
+ const p = db.fetch({keys: ['foobar']}, {not: 'important'}, function (error, docs) {
+ assert.equal(error, null, 'should work')
+ assert.equal(docs.rows.length, 1, 'and get one row')
+ assert.equal(docs['total_rows'], 3, 'out of 3')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (docs) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(docs.rows.length, 1, 'and get one row')
+ assert.equal(docs['total_rows'], 3, 'out of 3')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/document/fetch_revs.js b/tests/integration/document/fetch_revs.js
index f19ba0e..6bbbf7f 100644
--- a/tests/integration/document/fetch_revs.js
+++ b/tests/integration/document/fetch_revs.js
@@ -10,70 +10,70 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const it = harness.it
-it('should insert a bunch of items', helpers.insertThree);
+it('should insert a bunch of items', helpers.insertThree)
-it('should be able to fetch with one key', function(assert) {
- const p = db.fetchRevs({keys:['foobar']}, function(error, docs) {
- assert.equal(error, null, 'should work');
- assert.equal(docs.rows.length, 1, 'and get one row');
- assert.equal(docs['total_rows'], 3, 'out of 3');
- assert.equal(docs.rows[0].doc, undefined, 'rev should not return key');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(docs) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(docs.rows.length, 1, 'and get one row');
- assert.equal(docs['total_rows'], 3, 'out of 3');
- assert.equal(docs.rows[0].doc, undefined, 'rev should not return key');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be able to fetch with one key', function (assert) {
+ const p = db.fetchRevs({keys: ['foobar']}, function (error, docs) {
+ assert.equal(error, null, 'should work')
+ assert.equal(docs.rows.length, 1, 'and get one row')
+ assert.equal(docs['total_rows'], 3, 'out of 3')
+ assert.equal(docs.rows[0].doc, undefined, 'rev should not return key')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (docs) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(docs.rows.length, 1, 'and get one row')
+ assert.equal(docs['total_rows'], 3, 'out of 3')
+ assert.equal(docs.rows[0].doc, undefined, 'rev should not return key')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be able to fetch with multiple keys', function(assert) {
- const p = db.fetchRevs({keys:['foobar', 'barfoo']}, function(error, docs) {
- assert.equal(error, null, 'it works');
- assert.equal(docs.rows.length, 2, 'two rows');
- assert.equal(docs['total_rows'], 3, 'out of 3');
- assert.equal(docs.rows[0].doc, undefined, 'no doc in 1');
- assert.equal(docs.rows[1].doc, undefined, 'no doc in 2');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(docs) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(docs.rows.length, 2, 'two rows');
- assert.equal(docs['total_rows'], 3, 'out of 3');
- assert.equal(docs.rows[0].doc, undefined, 'no doc in 1');
- assert.equal(docs.rows[1].doc, undefined, 'no doc in 2');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be able to fetch with multiple keys', function (assert) {
+ const p = db.fetchRevs({keys: ['foobar', 'barfoo']}, function (error, docs) {
+ assert.equal(error, null, 'it works')
+ assert.equal(docs.rows.length, 2, 'two rows')
+ assert.equal(docs['total_rows'], 3, 'out of 3')
+ assert.equal(docs.rows[0].doc, undefined, 'no doc in 1')
+ assert.equal(docs.rows[1].doc, undefined, 'no doc in 2')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (docs) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(docs.rows.length, 2, 'two rows')
+ assert.equal(docs['total_rows'], 3, 'out of 3')
+ assert.equal(docs.rows[0].doc, undefined, 'no doc in 1')
+ assert.equal(docs.rows[1].doc, undefined, 'no doc in 2')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be able to fetch with params', function(assert) {
- const p = db.fetchRevs({keys:['foobar']}, {still: 'no'}, function(error, docs) {
- assert.equal(error, null, 'should work');
- assert.equal(docs.rows.length, 1, 'and get one row');
- assert.equal(docs['total_rows'], 3, 'out of 3');
- assert.equal(docs.rows[0].doc, undefined, 'rev should not return key');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(docs) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(docs.rows.length, 1, 'and get one row');
- assert.equal(docs['total_rows'], 3, 'out of 3');
- assert.equal(docs.rows[0].doc, undefined, 'rev should not return key');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be able to fetch with params', function (assert) {
+ const p = db.fetchRevs({keys: ['foobar']}, {still: 'no'}, function (error, docs) {
+ assert.equal(error, null, 'should work')
+ assert.equal(docs.rows.length, 1, 'and get one row')
+ assert.equal(docs['total_rows'], 3, 'out of 3')
+ assert.equal(docs.rows[0].doc, undefined, 'rev should not return key')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (docs) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(docs.rows.length, 1, 'and get one row')
+ assert.equal(docs['total_rows'], 3, 'out of 3')
+ assert.equal(docs.rows[0].doc, undefined, 'rev should not return key')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/document/find.js b/tests/integration/document/find.js
index 4959469..4c80c1b 100644
--- a/tests/integration/document/find.js
+++ b/tests/integration/document/find.js
@@ -10,36 +10,36 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const it = harness.it
-it('should insert a bunch of items', helpers.insertThree);
+it('should insert a bunch of items', helpers.insertThree)
-it('should be to do a mango query', function(assert) {
- const p = db.find({ selector: { foo: 'baz'}}, function(error, response) {
- assert.equal(error, null, 'should work');
- assert.equal(response.docs.length, 1, 'and get one row');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(response) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(response.docs.length, 1, 'and get one row');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be to do a mango query', function (assert) {
+ const p = db.find({ selector: { foo: 'baz' } }, function (error, response) {
+ assert.equal(error, null, 'should work')
+ assert.equal(response.docs.length, 1, 'and get one row')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (response) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(response.docs.length, 1, 'and get one row')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be to do a mango query with streams', function(assert) {
- const p = db.findAsStream({ selector: { foo: 'baz'}}, function(error, response) {
- assert.equal(error, null, 'should work');
- assert.equal(response.docs.length, 1, 'and get one row');
- assert.end();
- });
- assert.ok(!helpers.isPromise(p), 'does not return Promise');
- assert.equal(p.constructor.name, 'Request', 'returns a Request');
-});
+it('should be to do a mango query with streams', function (assert) {
+ const p = db.findAsStream({ selector: { foo: 'baz' } }, function (error, response) {
+ assert.equal(error, null, 'should work')
+ assert.equal(response.docs.length, 1, 'and get one row')
+ assert.end()
+ })
+ assert.ok(!helpers.isPromise(p), 'does not return Promise')
+ assert.equal(p.constructor.name, 'Request', 'returns a Request')
+})
diff --git a/tests/integration/document/get.js b/tests/integration/document/get.js
index b6223a4..13556cb 100644
--- a/tests/integration/document/get.js
+++ b/tests/integration/document/get.js
@@ -10,30 +10,30 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const it = harness.it
-it('should insert a one item', helpers.insertOne);
+it('should insert a one item', helpers.insertOne)
-it('should get the document', function(assert) {
- const p = db.get('foobaz', {'revs_info': true}, function(error, foobaz) {
- assert.equal(error, null, 'should get foobaz');
- assert.ok(foobaz['_revs_info'], 'got revs info');
- assert.equal(foobaz._id, 'foobaz', 'id is food');
- assert.equal(foobaz.foo, 'baz', 'baz is in foo');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(foobaz) {
- assert.ok(true, 'Promise is resolved');
- assert.ok(foobaz['_revs_info'], 'got revs info');
- assert.equal(foobaz._id, 'foobaz', 'id is food');
- assert.equal(foobaz.foo, 'baz', 'baz is in foo');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should get the document', function (assert) {
+ const p = db.get('foobaz', {'revs_info': true}, function (error, foobaz) {
+ assert.equal(error, null, 'should get foobaz')
+ assert.ok(foobaz['_revs_info'], 'got revs info')
+ assert.equal(foobaz._id, 'foobaz', 'id is food')
+ assert.equal(foobaz.foo, 'baz', 'baz is in foo')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (foobaz) {
+ assert.ok(true, 'Promise is resolved')
+ assert.ok(foobaz['_revs_info'], 'got revs info')
+ assert.equal(foobaz._id, 'foobaz', 'id is food')
+ assert.equal(foobaz.foo, 'baz', 'baz is in foo')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/document/head.js b/tests/integration/document/head.js
index 4ab2647..080cbd4 100644
--- a/tests/integration/document/head.js
+++ b/tests/integration/document/head.js
@@ -10,26 +10,26 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const it = harness.it
-it('should insert a one item', helpers.insertOne);
+it('should insert a one item', helpers.insertOne)
-it('should get a status code when you do head', function(assert) {
- const p = db.head('foobaz', function(error, body, headers) {
- assert.equal(error, null, 'should get the head of foobaz');
- assert.equal(headers['statusCode'], 200, 'and is ok');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(docs) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(docs['statusCode'], 200, 'and is ok');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should get a status code when you do head', function (assert) {
+ const p = db.head('foobaz', function (error, body, headers) {
+ assert.equal(error, null, 'should get the head of foobaz')
+ assert.equal(headers['statusCode'], 200, 'and is ok')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (docs) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(docs['statusCode'], 200, 'and is ok')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/document/insert.js b/tests/integration/document/insert.js
index d38ed12..3b4ab14 100644
--- a/tests/integration/document/insert.js
+++ b/tests/integration/document/insert.js
@@ -10,86 +10,86 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const it = harness.it
-let rev;
+let rev
-it('should insert one simple document', function(assert) {
- const p = db.insert({'foo': 'baz'}, 'foobaz', function(error, foo) {
- rev = foo.rev;
- assert.equal(error, null, 'should have stored foo');
- assert.equal(foo.ok, true, 'response should be ok');
- assert.ok(foo.rev, 'response should have rev');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(foo) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(foo.ok, true, 'response should be ok');
- assert.ok(foo.rev, 'response should have rev');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should insert one simple document', function (assert) {
+ const p = db.insert({'foo': 'baz'}, 'foobaz', function (error, foo) {
+ rev = foo.rev
+ assert.equal(error, null, 'should have stored foo')
+ assert.equal(foo.ok, true, 'response should be ok')
+ assert.ok(foo.rev, 'response should have rev')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (foo) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(foo.ok, true, 'response should be ok')
+ assert.ok(foo.rev, 'response should have rev')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should fail to insert again since it already exists', function(assert) {
- const p = db.insert({}, 'foobaz', function(error) {
- assert.equal(error['statusCode'], 409, 'should be conflict');
- assert.equal(error.scope, 'couch', 'scope is couch');
- assert.equal(error.error, 'conflict', 'type is conflict');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function() {
- assert.ok(false, 'Promise is resolved');
- }).catch(function(error) {
- assert.ok(true, 'Promise is rejected');
- assert.equal(error.scope, 'couch', 'scope is couch');
- assert.equal(error.error, 'conflict', 'type is conflict');
- assert.end();
- });
-});
+it('should fail to insert again since it already exists', function (assert) {
+ const p = db.insert({}, 'foobaz', function (error) {
+ assert.equal(error['statusCode'], 409, 'should be conflict')
+ assert.equal(error.scope, 'couch', 'scope is couch')
+ assert.equal(error.error, 'conflict', 'type is conflict')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function () {
+ assert.ok(false, 'Promise is resolved')
+ }).catch(function (error) {
+ assert.ok(true, 'Promise is rejected')
+ assert.equal(error.scope, 'couch', 'scope is couch')
+ assert.equal(error.error, 'conflict', 'type is conflict')
+ assert.end()
+ })
+})
-it('should be able to use custom params in insert', function(assert) {
+it('should be able to use custom params in insert', function (assert) {
const p = db.insert({
foo: 'baz',
_rev: rev
}, {
docName: 'foobaz',
'new_edits': false
- }, function(error, foo) {
- assert.equal(error, null, 'should have stored foo');
- assert.equal(foo.ok, true, 'response should be ok');
- assert.ok(foo.rev, 'response should have rev');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(foo) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(foo.ok, true, 'response should be ok');
- assert.ok(foo.rev, 'response should have rev');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ }, function (error, foo) {
+ assert.equal(error, null, 'should have stored foo')
+ assert.equal(foo.ok, true, 'response should be ok')
+ assert.ok(foo.rev, 'response should have rev')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (foo) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(foo.ok, true, 'response should be ok')
+ assert.ok(foo.rev, 'response should have rev')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be able to insert functions in docs', function(assert) {
+it('should be able to insert functions in docs', function (assert) {
const p = db.insert({
- fn: function() { return true; },
+ fn: function () { return true },
fn2: 'function () { return true; }'
- }, function(error, fns) {
- assert.equal(error, null, 'should have stored foo');
- assert.equal(fns.ok, true, 'response should be ok');
- assert.ok(fns.rev, 'response should have rev');
- db.get(fns.id, function(error, fns) {
- assert.equal(fns.fn, fns.fn2, 'fn matches fn2');
- assert.equal(error, null, 'should get foo');
- assert.end();
- });
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
-});
+ }, function (error, fns) {
+ assert.equal(error, null, 'should have stored foo')
+ assert.equal(fns.ok, true, 'response should be ok')
+ assert.ok(fns.rev, 'response should have rev')
+ db.get(fns.id, function (error, fns) {
+ assert.equal(fns.fn, fns.fn2, 'fn matches fn2')
+ assert.equal(error, null, 'should get foo')
+ assert.end()
+ })
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+})
diff --git a/tests/integration/document/list.js b/tests/integration/document/list.js
index 1bd580a..a1ed04c 100644
--- a/tests/integration/document/list.js
+++ b/tests/integration/document/list.js
@@ -10,144 +10,144 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const nano = harness.locals.nano;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const nano = harness.locals.nano
+const it = harness.it
-it('should insert a bunch of items', helpers.insertThree);
+it('should insert a bunch of items', helpers.insertThree)
-it('should list the three documents', function(assert) {
- const p = db.list(function(error, docs) {
- assert.equal(error, null, 'should get list');
- assert.equal(docs['total_rows'], 3, 'with total three rows');
- assert.ok(docs.rows, 'and the rows themselves');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(docs) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(docs['total_rows'], 3, 'with total three rows');
- assert.ok(docs.rows, 'and the rows themselves');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should list the three documents', function (assert) {
+ const p = db.list(function (error, docs) {
+ assert.equal(error, null, 'should get list')
+ assert.equal(docs['total_rows'], 3, 'with total three rows')
+ assert.ok(docs.rows, 'and the rows themselves')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (docs) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(docs['total_rows'], 3, 'with total three rows')
+ assert.ok(docs.rows, 'and the rows themselves')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be able to list using the `relax` function', function(assert) {
+it('should be able to list using the `relax` function', function (assert) {
nano.relax({
db: 'document_list',
doc: '_all_docs',
method: 'GET',
qs: {limit: 1}
- }, function(error, docs) {
- assert.equal(error, null, 'not relaxed');
- assert.ok(docs.rows, 'got meh rows');
- assert.equal(docs.rows.length, 1, 'but its only one #sadpanda');
- assert.equal(docs['total_rows'], 3, 'out of three');
- assert.end();
- });
-});
+ }, function (error, docs) {
+ assert.equal(error, null, 'not relaxed')
+ assert.ok(docs.rows, 'got meh rows')
+ assert.equal(docs.rows.length, 1, 'but its only one #sadpanda')
+ assert.equal(docs['total_rows'], 3, 'out of three')
+ assert.end()
+ })
+})
-it('should be able to list with a start_key', function(assert) {
- const p = db.list({start_key: 'c'}, function(error, docs) {
- assert.equal(error, null, 'should work');
- assert.ok(docs.rows, 'get the rows');
- assert.equal(docs.rows.length, 2, 'starts in row two');
- assert.equal(docs['total_rows'], 3, 'out of three rows');
- assert.equal(docs.offset, 1, 'offset is 1');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(docs) {
- assert.ok(true, 'Promise is resolved');
- assert.ok(docs.rows, 'get the rows');
- assert.equal(docs.rows.length, 2, 'starts in row two');
- assert.equal(docs['total_rows'], 3, 'out of three rows');
- assert.equal(docs.offset, 1, 'offset is 1');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be able to list with a start_key', function (assert) {
+ const p = db.list({start_key: 'c'}, function (error, docs) {
+ assert.equal(error, null, 'should work')
+ assert.ok(docs.rows, 'get the rows')
+ assert.equal(docs.rows.length, 2, 'starts in row two')
+ assert.equal(docs['total_rows'], 3, 'out of three rows')
+ assert.equal(docs.offset, 1, 'offset is 1')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (docs) {
+ assert.ok(true, 'Promise is resolved')
+ assert.ok(docs.rows, 'get the rows')
+ assert.equal(docs.rows.length, 2, 'starts in row two')
+ assert.equal(docs['total_rows'], 3, 'out of three rows')
+ assert.equal(docs.offset, 1, 'offset is 1')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be able to list with a startkey', function(assert) {
- const p = db.list({startkey: 'c'}, function(error, docs) {
- assert.equal(error, null, 'should work');
- assert.ok(docs.rows, 'get the rows');
- assert.equal(docs.rows.length, 2, 'starts in row two');
- assert.equal(docs['total_rows'], 3, 'out of three rows');
- assert.equal(docs.offset, 1, 'offset is 1');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(docs) {
- assert.ok(true, 'Promise is resolved');
- assert.ok(docs.rows, 'get the rows');
- assert.equal(docs.rows.length, 2, 'starts in row two');
- assert.equal(docs['total_rows'], 3, 'out of three rows');
- assert.equal(docs.offset, 1, 'offset is 1');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be able to list with a startkey', function (assert) {
+ const p = db.list({startkey: 'c'}, function (error, docs) {
+ assert.equal(error, null, 'should work')
+ assert.ok(docs.rows, 'get the rows')
+ assert.equal(docs.rows.length, 2, 'starts in row two')
+ assert.equal(docs['total_rows'], 3, 'out of three rows')
+ assert.equal(docs.offset, 1, 'offset is 1')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (docs) {
+ assert.ok(true, 'Promise is resolved')
+ assert.ok(docs.rows, 'get the rows')
+ assert.equal(docs.rows.length, 2, 'starts in row two')
+ assert.equal(docs['total_rows'], 3, 'out of three rows')
+ assert.equal(docs.offset, 1, 'offset is 1')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be able to list with a endkey', function(assert) {
- const p = db.list({endkey: 's'}, function(error, docs) {
- assert.equal(error, null, 'should work');
- assert.ok(docs.rows, 'get the rows');
- assert.equal(docs.rows.length, 2, 'starts in row two');
- assert.equal(docs['total_rows'], 3, 'out of three rows');
- assert.equal(docs.offset, 1, 'offset is 1');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(docs) {
- assert.ok(true, 'Promise is resolved');
- assert.ok(docs.rows, 'get the rows');
- assert.equal(docs.rows.length, 2, 'starts in row two');
- assert.equal(docs['total_rows'], 3, 'out of three rows');
- assert.equal(docs.offset, 1, 'offset is 1');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be able to list with a endkey', function (assert) {
+ const p = db.list({endkey: 's'}, function (error, docs) {
+ assert.equal(error, null, 'should work')
+ assert.ok(docs.rows, 'get the rows')
+ assert.equal(docs.rows.length, 2, 'starts in row two')
+ assert.equal(docs['total_rows'], 3, 'out of three rows')
+ assert.equal(docs.offset, 1, 'offset is 1')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (docs) {
+ assert.ok(true, 'Promise is resolved')
+ assert.ok(docs.rows, 'get the rows')
+ assert.equal(docs.rows.length, 2, 'starts in row two')
+ assert.equal(docs['total_rows'], 3, 'out of three rows')
+ assert.equal(docs.offset, 1, 'offset is 1')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be able to list with a end_key', function(assert) {
- const p = db.list({end_key: 's'}, function(error, docs) {
- assert.equal(error, null, 'should work');
- assert.ok(docs.rows, 'get the rows');
- assert.equal(docs.rows.length, 2, 'starts in row two');
- assert.equal(docs['total_rows'], 3, 'out of three rows');
- assert.equal(docs.offset, 1, 'offset is 1');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(docs) {
- assert.ok(true, 'Promise is resolved');
- assert.ok(docs.rows, 'get the rows');
- assert.equal(docs.rows.length, 2, 'starts in row two');
- assert.equal(docs['total_rows'], 3, 'out of three rows');
- assert.equal(docs.offset, 1, 'offset is 1');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should be able to list with a end_key', function (assert) {
+ const p = db.list({end_key: 's'}, function (error, docs) {
+ assert.equal(error, null, 'should work')
+ assert.ok(docs.rows, 'get the rows')
+ assert.equal(docs.rows.length, 2, 'starts in row two')
+ assert.equal(docs['total_rows'], 3, 'out of three rows')
+ assert.equal(docs.offset, 1, 'offset is 1')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (docs) {
+ assert.ok(true, 'Promise is resolved')
+ assert.ok(docs.rows, 'get the rows')
+ assert.equal(docs.rows.length, 2, 'starts in row two')
+ assert.equal(docs['total_rows'], 3, 'out of three rows')
+ assert.equal(docs.offset, 1, 'offset is 1')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be able to list as a stream', function(assert) {
- const p = db.listAsStream(function(error) {
- assert.equal(error, null, 'should work');
- });
- assert.ok(!helpers.isPromise(p), 'does not return Promise');
- assert.equal(p.constructor.name, 'Request', 'returns a Request');
-});
+it('should be able to list as a stream', function (assert) {
+ const p = db.listAsStream(function (error) {
+ assert.equal(error, null, 'should work')
+ })
+ assert.ok(!helpers.isPromise(p), 'does not return Promise')
+ assert.equal(p.constructor.name, 'Request', 'returns a Request')
+})
-it('should be able to list with params as a stream', function(assert) {
- const p = db.listAsStream({end_key: 's'}, function(error) {
- assert.equal(error, null, 'should work');
- });
- assert.ok(!helpers.isPromise(p), 'does not return Promise');
- assert.equal(p.constructor.name, 'Request', 'returns a Request');
-});
\ No newline at end of file
+it('should be able to list with params as a stream', function (assert) {
+ const p = db.listAsStream({end_key: 's'}, function (error) {
+ assert.equal(error, null, 'should work')
+ })
+ assert.ok(!helpers.isPromise(p), 'does not return Promise')
+ assert.equal(p.constructor.name, 'Request', 'returns a Request')
+})
diff --git a/tests/integration/document/update.js b/tests/integration/document/update.js
index 7853ca0..6420021 100644
--- a/tests/integration/document/update.js
+++ b/tests/integration/document/update.js
@@ -10,44 +10,44 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const it = harness.it
-let rev;
+let rev
-it('should insert one doc', function(assert) {
- const p = db.insert({'foo': 'baz'}, 'foobar', function(error, foo) {
- assert.equal(error, null, 'stored foo');
- assert.equal(foo.ok, true, 'response ok');
- assert.ok(foo.rev, 'withs rev');
- rev = foo.rev;
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(foo) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(foo.ok, true, 'response ok');
- assert.ok(foo.rev, 'withs rev');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should insert one doc', function (assert) {
+ const p = db.insert({'foo': 'baz'}, 'foobar', function (error, foo) {
+ assert.equal(error, null, 'stored foo')
+ assert.equal(foo.ok, true, 'response ok')
+ assert.ok(foo.rev, 'withs rev')
+ rev = foo.rev
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (foo) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(foo.ok, true, 'response ok')
+ assert.ok(foo.rev, 'withs rev')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should update the document', function(assert) {
- const p = db.insert({foo: 'bar', '_rev': rev}, 'foobar', function(error, response) {
- assert.equal(error, null, 'should have deleted foo');
- assert.equal(response.ok, true, 'response should be ok');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(response) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(response.ok, true, 'response should be ok');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+it('should update the document', function (assert) {
+ const p = db.insert({foo: 'bar', '_rev': rev}, 'foobar', function (error, response) {
+ assert.equal(error, null, 'should have deleted foo')
+ assert.equal(response.ok, true, 'response should be ok')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (response) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(response.ok, true, 'response should be ok')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/multipart/get.js b/tests/integration/multipart/get.js
index 3da281e..b40da32 100644
--- a/tests/integration/multipart/get.js
+++ b/tests/integration/multipart/get.js
@@ -10,56 +10,56 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const it = harness.it
-let rev;
+let rev // eslint-disable-line
-it('should be able to insert a doc with att', function(assert) {
+it('should be able to insert a doc with att', function (assert) {
const att = {
name: 'att',
data: 'Hello World!',
'content_type': 'text/plain'
- };
+ }
- const p = db.multipart.insert({'foo': 'baz'}, [att], 'foobaz', function(error, foo) {
- assert.equal(error, null, 'should have stored foobaz');
- assert.equal(foo.ok, true, 'response should be ok');
- assert.equal(foo.id, 'foobaz', 'id is foobaz');
- assert.ok(foo.rev, 'has rev');
- rev = foo.rev;
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(foo) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(foo.ok, true, 'response should be ok');
- assert.equal(foo.id, 'foobaz', 'id is foobaz');
- assert.ok(foo.rev, 'has rev');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ const p = db.multipart.insert({'foo': 'baz'}, [att], 'foobaz', function (error, foo) {
+ assert.equal(error, null, 'should have stored foobaz')
+ assert.equal(foo.ok, true, 'response should be ok')
+ assert.equal(foo.id, 'foobaz', 'id is foobaz')
+ assert.ok(foo.rev, 'has rev')
+ rev = foo.rev
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (foo) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(foo.ok, true, 'response should be ok')
+ assert.equal(foo.id, 'foobaz', 'id is foobaz')
+ assert.ok(foo.rev, 'has rev')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should be able to get the document with the attachment', function(assert) {
- const p = db.multipart.get('foobaz', function(error, foobaz, headers) {
- assert.equal(error, null, 'should get foobaz');
+it('should be able to get the document with the attachment', function (assert) {
+ const p = db.multipart.get('foobaz', function (error, foobaz, headers) {
+ assert.equal(error, null, 'should get foobaz')
if (helpers.unmocked) {
- assert.ok(headers['content-type'], 'should have content type');
- assert.equal(headers['content-type'].split(';')[0], 'multipart/related');
+ assert.ok(headers['content-type'], 'should have content type')
+ assert.equal(headers['content-type'].split(';')[0], 'multipart/related')
}
- assert.equal(typeof foobaz, 'object', 'foobaz should be a buffer');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(foobaz) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(typeof foobaz, 'object', 'foobaz should be a buffer');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ assert.equal(typeof foobaz, 'object', 'foobaz should be a buffer')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (foobaz) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(typeof foobaz, 'object', 'foobaz should be a buffer')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/multipart/insert.js b/tests/integration/multipart/insert.js
index f80d26c..5bf6a43 100644
--- a/tests/integration/multipart/insert.js
+++ b/tests/integration/multipart/insert.js
@@ -10,77 +10,77 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const db = harness.locals.db;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const db = harness.locals.db
+const it = harness.it
-it('should handle crazy encodings', function(assert) {
+it('should handle crazy encodings', function (assert) {
const att = {
name: 'att',
data: 'काचं शक्नोम्यत्तुम् । नोपहिनस्ति माम् ॥',
'content_type': 'text/plain'
- };
- const p = db.multipart.insert({'foo': 'bar'}, [att], 'foobar', function(error, foo) {
- assert.equal(error, null, 'should have stored foo and attachment');
- assert.equal(foo.ok, true, 'response should be ok');
- assert.ok(foo.rev, 'response should have rev');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(foo) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(foo.ok, true, 'response should be ok');
- assert.ok(foo.rev, 'response should have rev');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ }
+ const p = db.multipart.insert({'foo': 'bar'}, [att], 'foobar', function (error, foo) {
+ assert.equal(error, null, 'should have stored foo and attachment')
+ assert.equal(foo.ok, true, 'response should be ok')
+ assert.ok(foo.rev, 'response should have rev')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (foo) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(foo.ok, true, 'response should be ok')
+ assert.ok(foo.rev, 'response should have rev')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
-it('should test with presence of attachment', function(assert) {
+it('should test with presence of attachment', function (assert) {
const att = {
name: 'two',
data: 'Hello World!',
'content_type': 'text/plain'
- };
+ }
const p = db.attachment.insert('mydoc', 'one', 'Hello World!', 'text/plain',
- function(err) {
- assert.equal(err, null, 'should have stored the thingy');
- db.get('mydoc', function(_, doc) {
- db.multipart.insert(doc, [att], 'mydoc', function() {
- db.get('mydoc', function(error, two) {
- assert.equal(error, null, 'should get the doc');
- assert.equal(Object.keys(two._attachments).length, 2,
- 'both attachments should be present');
- assert.end();
- });
- });
- });
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
-});
+ function (err) {
+ assert.equal(err, null, 'should have stored the thingy')
+ db.get('mydoc', function (_, doc) {
+ db.multipart.insert(doc, [att], 'mydoc', function () {
+ db.get('mydoc', function (error, two) {
+ assert.equal(error, null, 'should get the doc')
+ assert.equal(Object.keys(two._attachments).length, 2,
+ 'both attachments should be present')
+ assert.end()
+ })
+ })
+ })
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+})
-it('should work with attachment as a buffer', function(assert) {
+it('should work with attachment as a buffer', function (assert) {
const att = {
name: 'att',
- data: new Buffer('foo'),
+ data: Buffer.from('foo'),
'content_type': 'text/plain'
- };
- const p = db.multipart.insert({'foo': 'bar'}, [att], 'otherdoc', function(error, foo) {
- assert.equal(error, null, 'Should have stored foo and attachment');
- assert.equal(foo.ok, true, 'Response should be ok');
- assert.ok(foo.rev, 'Response should have rev');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(foo) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(foo.ok, true, 'response should be ok');
- assert.ok(foo.rev, 'response should have rev');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
+ }
+ const p = db.multipart.insert({'foo': 'bar'}, [att], 'otherdoc', function (error, foo) {
+ assert.equal(error, null, 'Should have stored foo and attachment')
+ assert.equal(foo.ok, true, 'Response should be ok')
+ assert.ok(foo.rev, 'Response should have rev')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (foo) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(foo.ok, true, 'response should be ok')
+ assert.ok(foo.rev, 'response should have rev')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
diff --git a/tests/integration/shared/config.js b/tests/integration/shared/config.js
index e5d78d2..88931a3 100644
--- a/tests/integration/shared/config.js
+++ b/tests/integration/shared/config.js
@@ -10,86 +10,86 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
-
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const nano = harness.locals.nano;
-const Nano = helpers.Nano;
-
-const it = harness.it;
-
-it('should serve the root when no path is specified', function(assert) {
- const p = nano.dinosaur('', function(err, response) {
- assert.equal(err, null, 'failed to get root');
- assert.ok(response.version, 'version is defined');
- nano.relax(function(err, response) {
- assert.equal(err, null, 'relax');
- assert.ok(response.version, 'had version');
- });
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(response) {
- assert.ok(true, 'Promise is resolved');
- assert.ok(response.version, 'version is defined');
- assert.end();
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
-
-it('should be able to parse urls', function(assert) {
- const baseUrl = 'http://someurl.com';
+'use strict'
+
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const nano = harness.locals.nano
+const Nano = helpers.Nano
+
+const it = harness.it
+
+it('should serve the root when no path is specified', function (assert) {
+ const p = nano.dinosaur('', function (err, response) {
+ assert.equal(err, null, 'failed to get root')
+ assert.ok(response.version, 'version is defined')
+ nano.relax(function (err, response) {
+ assert.equal(err, null, 'relax')
+ assert.ok(response.version, 'had version')
+ })
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (response) {
+ assert.ok(true, 'Promise is resolved')
+ assert.ok(response.version, 'version is defined')
+ assert.end()
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
+
+it('should be able to parse urls', function (assert) {
+ const baseUrl = 'http://someurl.com'
assert.equal(
Nano(baseUrl).config.url,
baseUrl,
- 'simple url');
+ 'simple url')
assert.equal(
Nano(baseUrl + '/').config.url,
baseUrl + '/',
- 'simple with trailing');
+ 'simple with trailing')
assert.equal(
Nano('http://a:b@someurl.com:5984').config.url,
'http://a:b@someurl.com:5984',
- 'with authentication');
+ 'with authentication')
assert.equal(
Nano('http://a:b%20c%3F@someurl.com:5984/mydb').config.url,
'http://a:b%20c%3F@someurl.com:5984',
- 'with escaped auth');
+ 'with escaped auth')
assert.equal(
Nano('http://a:b%20c%3F@someurl.com:5984/my%2Fdb').config.url,
'http://a:b%20c%3F@someurl.com:5984',
- 'with dbname containing encoded slash');
+ 'with dbname containing encoded slash')
assert.equal(
Nano('http://mydb-a:b%20c%3F@someurl.com:5984/mydb').config.url,
'http://mydb-a:b%20c%3F@someurl.com:5984',
- 'with repeating dbname');
+ 'with repeating dbname')
assert.equal(
Nano('http://a:b%20c%3F@someurl.com:5984/prefix/mydb').config.url,
'http://a:b%20c%3F@someurl.com:5984/prefix',
- 'with subdir');
+ 'with subdir')
assert.equal(
Nano(baseUrl + ':5984/a').config.url,
baseUrl + ':5984',
- 'with port');
+ 'with port')
assert.equal(
Nano(baseUrl + '/a').config.url,
baseUrl,
- '`a` database');
+ '`a` database')
- assert.end();
-});
+ assert.end()
+})
-it('should not parse urls when parseURL flag set to false', function(assert) {
- const url = 'http://someurl.com/path';
+it('should not parse urls when parseURL flag set to false', function (assert) {
+ const url = 'http://someurl.com/path'
assert.equal(
Nano({
@@ -97,51 +97,51 @@ it('should not parse urls when parseURL flag set to false', function(assert) {
parseUrl: false
}).config.url,
url,
- 'the untouched url');
+ 'the untouched url')
- assert.end();
-});
+ assert.end()
+})
-it('should accept and handle customer http headers', function(assert) {
+it('should accept and handle customer http headers', function (assert) {
const nanoWithDefaultHeaders = Nano({
url: helpers.couch,
defaultHeaders: {
'x-custom-header': 'custom',
'x-second-header': 'second'
}
- });
+ })
- const req = nanoWithDefaultHeaders.db.listAsStream(function(err) {
- assert.equal(err, null, 'should list');
- assert.end();
- });
+ const req = nanoWithDefaultHeaders.db.listAsStream(function (err) {
+ assert.equal(err, null, 'should list')
+ assert.end()
+ })
assert.equal(
req.headers['x-custom-header'],
'custom',
- 'header `x-second-header` honored');
+ 'header `x-second-header` honored')
assert.equal(
req.headers['x-second-header'],
'second',
- 'headers `x-second-header` honored');
-});
+ 'headers `x-second-header` honored')
+})
-it('should prevent shallow object copies', function(assert) {
+it('should prevent shallow object copies', function (assert) {
const config = {
url: 'http://someurl.com'
- };
+ }
assert.equal(
Nano(config).config.url,
config.url,
- 'simple url');
+ 'simple url')
assert.ok(
Nano(config).config.requestDefaults,
- '`requestDefaults` should be set');
+ '`requestDefaults` should be set')
assert.ok(!config.requestDefaults,
- 'should not be re-using the same object');
+ 'should not be re-using the same object')
- assert.end();
-});
+ assert.end()
+})
diff --git a/tests/integration/shared/cookie.js b/tests/integration/shared/cookie.js
index 15c2bac..4934f6e 100644
--- a/tests/integration/shared/cookie.js
+++ b/tests/integration/shared/cookie.js
@@ -10,20 +10,20 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const nano = harness.locals.nano;
-const Nano = helpers.Nano;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const nano = harness.locals.nano
+const Nano = helpers.Nano
+const it = harness.it
-let cookie;
-let server;
+let cookie
+let server
-it('should be able to create a user', function(assert) {
+it('should be able to create a user', function (assert) {
nano.relax({
- method : 'POST',
+ method: 'POST',
path: '_users',
body: {
_id: 'org.couchdb.user:' + helpers.username,
@@ -32,48 +32,47 @@ it('should be able to create a user', function(assert) {
roles: ['admin'],
password: helpers.password
}
- }, function(err) {
- assert.equal(err, null, 'should create admin');
- nano.auth(helpers.username, helpers.password, function(err, _, headers) {
- assert.equal(err, null, 'should have logged in successfully');
+ }, function (err) {
+ assert.equal(err, null, 'should create admin')
+ nano.auth(helpers.username, helpers.password, function (err, _, headers) {
+ assert.equal(err, null, 'should have logged in successfully')
if (helpers.unmocked) {
assert.ok(headers['set-cookie'],
- 'response should have a set-cookie header');
+ 'response should have a set-cookie header')
}
- cookie = headers['set-cookie'];
- assert.end();
- });
- });
-});
+ cookie = headers['set-cookie']
+ assert.end()
+ })
+ })
+})
-it('should be able to insert with a cookie', function(assert) {
+it('should be able to insert with a cookie', function (assert) {
server = Nano({
url: helpers.couch,
cookie: cookie
- });
- const db = server.use('shared_cookie');
+ })
+ const db = server.use('shared_cookie')
- const p = db.insert({'foo': 'baz'}, null, function(error, response) {
- assert.equal(error, null, 'should have stored value');
- assert.equal(response.ok, true, 'response should be ok');
- assert.ok(response.rev, 'response should have rev');
- assert.end();
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(response) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(response.ok, true, 'response should be ok');
- assert.ok(response.rev, 'response should have rev');
- }).catch(function() {
- assert.ok(false, 'Promise is rejected');
- });
-});
-
-it('should be able to get the session', function(assert) {
- server.session(function(error, session) {
- assert.equal(error, null, 'should have gotten the session');
- assert.equal(session.userCtx.name, helpers.username);
- assert.end();
- });
-});
+ const p = db.insert({'foo': 'baz'}, null, function (error, response) {
+ assert.equal(error, null, 'should have stored value')
+ assert.equal(response.ok, true, 'response should be ok')
+ assert.ok(response.rev, 'response should have rev')
+ assert.end()
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (response) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(response.ok, true, 'response should be ok')
+ assert.ok(response.rev, 'response should have rev')
+ }).catch(function () {
+ assert.ok(false, 'Promise is rejected')
+ })
+})
+it('should be able to get the session', function (assert) {
+ server.session(function (error, session) {
+ assert.equal(error, null, 'should have gotten the session')
+ assert.equal(session.userCtx.name, helpers.username)
+ assert.end()
+ })
+})
diff --git a/tests/integration/shared/error.js b/tests/integration/shared/error.js
index d9a1a87..0789956 100644
--- a/tests/integration/shared/error.js
+++ b/tests/integration/shared/error.js
@@ -10,50 +10,50 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const nano = harness.locals.nano;
-const Nano = helpers.Nano;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const nano = harness.locals.nano
+const Nano = helpers.Nano
+const it = harness.it
-it('should throw when initialize fails', function(assert) {
+it('should throw when initialize fails', function (assert) {
try {
- Nano('Not a url');
+ Nano('Not a url')
} catch (err) {
- assert.ok(err, 'should have throw');
- assert.ok(err.message, 'with a description');
+ assert.ok(err, 'should have throw')
+ assert.ok(err.message, 'with a description')
}
try {
- Nano({});
+ Nano({})
} catch (err2) {
- assert.ok(err2, 'should have throw');
- assert.ok(err2.message, 'with a message');
+ assert.ok(err2, 'should have throw')
+ assert.ok(err2.message, 'with a message')
}
- assert.end();
-});
+ assert.end()
+})
-it('should be able to stream the simplest request', function(assert) {
- const root = nano.request({stream: true});
- root.on('end', function() {
- assert.pass('request worked');
- assert.end();
- });
-});
+it('should be able to stream the simplest request', function (assert) {
+ const root = nano.request({stream: true})
+ root.on('end', function () {
+ assert.pass('request worked')
+ assert.end()
+ })
+})
-it('should error when destroying a db that does not exist', function(assert) {
- const p = nano.db.destroy('say_wat_wat', function(error) {
- assert.ok(error, 'an error');
- assert.ok(error.message, 'a note');
- assert.equal(error.message, 'Database does not exist.', 'is missing');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function() {
- assert.ok(false, 'Promise is resolved');
- }).catch(function(error) {
- assert.ok(true, 'Promise is rejected');
- assert.equal(error.message, 'Database does not exist.', 'is missing');
- assert.end();
- });
-});
+it('should error when destroying a db that does not exist', function (assert) {
+ const p = nano.db.destroy('say_wat_wat', function (error) {
+ assert.ok(error, 'an error')
+ assert.ok(error.message, 'a note')
+ assert.equal(error.message, 'Database does not exist.', 'is missing')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function () {
+ assert.ok(false, 'Promise is resolved')
+ }).catch(function (error) {
+ assert.ok(true, 'Promise is rejected')
+ assert.equal(error.message, 'Database does not exist.', 'is missing')
+ assert.end()
+ })
+})
diff --git a/tests/integration/shared/headers.js b/tests/integration/shared/headers.js
index 1a9880c..ba4daf6 100644
--- a/tests/integration/shared/headers.js
+++ b/tests/integration/shared/headers.js
@@ -10,36 +10,36 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const nano = harness.locals.nano;
-const db = harness.locals.db;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const nano = harness.locals.nano
+const db = harness.locals.db
+const it = harness.it
-it('should get headers', function(assert) {
+it('should get headers', function (assert) {
db.attachment.insert('new', 'att', 'Hello', 'text/plain',
- function(error, hello) {
- assert.equal(error, null, 'should store hello');
- assert.equal(hello.ok, true, 'response should be ok');
- assert.ok(hello.rev, 'should have a revision number');
- nano.request({
- db: 'shared_headers',
- doc: 'new',
- headers: {'If-None-Match': JSON.stringify(hello.rev)}
- }, function(error, helloWorld, rh) {
- assert.equal(error, null, 'should get the hello');
- assert.equal(rh['statusCode'], 304, 'status is not modified');
+ function (error, hello) {
+ assert.equal(error, null, 'should store hello')
+ assert.equal(hello.ok, true, 'response should be ok')
+ assert.ok(hello.rev, 'should have a revision number')
nano.request({
db: 'shared_headers',
doc: 'new',
- att: 'att'
- }, function(error, helloWorld, rh) {
- assert.equal(error, null, 'should get the hello');
- assert.equal(rh['statusCode'], 200, 'status is `ok`');
- assert.end();
- });
- });
- });
-});
+ headers: {'If-None-Match': JSON.stringify(hello.rev)}
+ }, function (error, helloWorld, rh) {
+ assert.equal(error, null, 'should get the hello')
+ assert.equal(rh['statusCode'], 304, 'status is not modified')
+ nano.request({
+ db: 'shared_headers',
+ doc: 'new',
+ att: 'att'
+ }, function (error, helloWorld, rh) {
+ assert.equal(error, null, 'should get the hello')
+ assert.equal(rh['statusCode'], 200, 'status is `ok`')
+ assert.end()
+ })
+ })
+ })
+})
diff --git a/tests/integration/shared/log.js b/tests/integration/shared/log.js
index f1d07f7..4f89df6 100644
--- a/tests/integration/shared/log.js
+++ b/tests/integration/shared/log.js
@@ -10,20 +10,20 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const logger = require('../../../lib/logger');
-const helpers = require('../../helpers');
-const harness = helpers.harness(__filename);
-const it = harness.it;
+const logger = require('../../../lib/logger')
+const helpers = require('../../helpers')
+const harness = helpers.harness(__filename)
+const it = harness.it
-it('should be able to instantiate a log', function(assert) {
+it('should be able to instantiate a log', function (assert) {
const log = logger({
- log: function(id, msg) {
- assert.equal(typeof id, 'string', 'id is set `' + id + '`');
- assert.equal(msg[0], 'testing 1234');
- assert.end();
+ log: function (id, msg) {
+ assert.equal(typeof id, 'string', 'id is set `' + id + '`')
+ assert.equal(msg[0], 'testing 1234')
+ assert.end()
}
- })();
- log('testing 1234');
-});
+ })()
+ log('testing 1234')
+})
diff --git a/tests/integration/util/uuid.js b/tests/integration/util/uuid.js
index 0aca172..76c42d7 100644
--- a/tests/integration/util/uuid.js
+++ b/tests/integration/util/uuid.js
@@ -10,47 +10,47 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const nano = helpers.nano;
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const nano = helpers.nano
+const it = harness.it
-it('should generate three uuids', function(assert) {
- const p = nano.uuids(3, function(error, data) {
- assert.equal(error, null, 'should generate uuids');
- assert.ok(data, 'got response');
- assert.ok(data.uuids, 'got uuids');
- assert.equal(data.uuids.length, 3, 'got 3');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.ok(data, 'got response');
- assert.ok(data.uuids, 'got uuids');
- assert.equal(data.uuids.length, 3, 'got 3');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should generate three uuids', function (assert) {
+ const p = nano.uuids(3, function (error, data) {
+ assert.equal(error, null, 'should generate uuids')
+ assert.ok(data, 'got response')
+ assert.ok(data.uuids, 'got uuids')
+ assert.equal(data.uuids.length, 3, 'got 3')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.ok(data, 'got response')
+ assert.ok(data.uuids, 'got uuids')
+ assert.equal(data.uuids.length, 3, 'got 3')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should generate one uuid', function(assert) {
- const p = nano.uuids(function(error, data) {
- assert.equal(error, null, 'should generate uuids');
- assert.ok(data, 'got response');
- assert.ok(data.uuids, 'got uuid');
- assert.equal(data.uuids.length, 1, 'got 1');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.ok(data, 'got response');
- assert.ok(data.uuids, 'got uuid');
- assert.equal(data.uuids.length, 1, 'got 1');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should generate one uuid', function (assert) {
+ const p = nano.uuids(function (error, data) {
+ assert.equal(error, null, 'should generate uuids')
+ assert.ok(data, 'got response')
+ assert.ok(data.uuids, 'got uuid')
+ assert.equal(data.uuids.length, 1, 'got 1')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.ok(data, 'got response')
+ assert.ok(data.uuids, 'got uuid')
+ assert.equal(data.uuids.length, 1, 'got 1')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
diff --git a/tests/intercept/design/search.js b/tests/intercept/design/search.js
index f853b48..79da954 100644
--- a/tests/intercept/design/search.js
+++ b/tests/intercept/design/search.js
@@ -10,306 +10,306 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/integration');
-const harness = helpers.harness(__filename);
-const it = harness.it;
+const helpers = require('../../helpers/integration')
+const harness = helpers.harness(__filename)
+const it = harness.it
-const nano = require('../../../lib/nano.js');
-const fakeRequest = function(r, callback) {
- callback(null, { statusCode: 200 }, r);
-};
+const nano = require('../../../lib/nano.js')
+const fakeRequest = function (r, callback) {
+ callback(null, { statusCode: 200 }, r)
+}
// by passing in a fake Request object, we can intercept the request
// and see how Nano is pre-processing the parameters
-const n = nano({url: 'http://localhost:5984', request: fakeRequest});
-const db = n.db.use('fake');
+const n = nano({url: 'http://localhost:5984', request: fakeRequest})
+const db = n.db.use('fake')
-it('should allow custom request object to be supplied', function(assert) {
- const p = db.info(function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should allow custom request object to be supplied', function (assert) {
+ const p = db.info(function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should encode array counts parameter', function(assert) {
- const p = db.search('fake', 'fake', { counts: ['brand','colour'] }, function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.equal(data.qs.counts, JSON.stringify(['brand','colour']));
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should encode array counts parameter', function (assert) {
+ const p = db.search('fake', 'fake', { counts: ['brand', 'colour'] }, function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.equal(data.qs.counts, JSON.stringify(['brand', 'colour']))
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should not encode string counts parameter', function(assert) {
- const p = db.search('fake', 'fake',
- { counts: JSON.stringify(['brand','colour']) },
- function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.equal(data.qs.counts, JSON.stringify(['brand','colour']));
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should not encode string counts parameter', function (assert) {
+ const p = db.search('fake', 'fake',
+ { counts: JSON.stringify(['brand', 'colour']) },
+ function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.equal(data.qs.counts, JSON.stringify(['brand', 'colour']))
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should encode array drilldown parameter', function(assert) {
- const p = db.search('fake', 'fake', { drilldown: ['colour','red'] }, function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.equal(data.qs.drilldown, JSON.stringify(['colour','red']));
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should encode array drilldown parameter', function (assert) {
+ const p = db.search('fake', 'fake', { drilldown: ['colour', 'red'] }, function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.equal(data.qs.drilldown, JSON.stringify(['colour', 'red']))
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should not encode string drilldown parameter', function(assert) {
- const p = db.search('fake', 'fake',
- { drilldown: JSON.stringify(['colour','red']) },
- function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.equal(data.qs.drilldown, JSON.stringify(['colour','red']));
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should not encode string drilldown parameter', function (assert) {
+ const p = db.search('fake', 'fake',
+ { drilldown: JSON.stringify(['colour', 'red']) },
+ function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.equal(data.qs.drilldown, JSON.stringify(['colour', 'red']))
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should encode array group_sort parameter', function(assert) {
- const p = db.search('fake', 'fake',
- { group_sort: ['-foo<number>','bar<string>'] },
- function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.equal(data.qs.group_sort, JSON.stringify(['-foo<number>','bar<string>']));
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should encode array group_sort parameter', function (assert) {
+ const p = db.search('fake', 'fake',
+ { group_sort: ['-foo<number>', 'bar<string>'] },
+ function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.equal(data.qs.group_sort, JSON.stringify(['-foo<number>', 'bar<string>']))
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should not encode string group_sort parameter', function(assert) {
- const p = db.search('fake', 'fake',
- { group_sort: JSON.stringify(['-foo<number>','bar<string>']) },
- function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.equal(data.qs.group_sort, JSON.stringify(['-foo<number>','bar<string>']));
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should not encode string group_sort parameter', function (assert) {
+ const p = db.search('fake', 'fake',
+ { group_sort: JSON.stringify(['-foo<number>', 'bar<string>']) },
+ function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.equal(data.qs.group_sort, JSON.stringify(['-foo<number>', 'bar<string>']))
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should encode object ranges parameter', function(assert) {
- const p = db.search('fake', 'fake',
- { ranges: {'price':'[0 TO 10]'} },
- function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.equal(data.qs.ranges, JSON.stringify({'price':'[0 TO 10]'}));
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should encode object ranges parameter', function (assert) {
+ const p = db.search('fake', 'fake',
+ { ranges: {'price': '[0 TO 10]'} },
+ function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.equal(data.qs.ranges, JSON.stringify({'price': '[0 TO 10]'}))
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should not encode string ranges parameter', function(assert) {
- const p = db.search('fake', 'fake',
- { ranges: JSON.stringify({'price':'[0 TO 10]'}) },
- function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.equal(data.qs.ranges, JSON.stringify({'price':'[0 TO 10]'}));
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should not encode string ranges parameter', function (assert) {
+ const p = db.search('fake', 'fake',
+ { ranges: JSON.stringify({'price': '[0 TO 10]'}) },
+ function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.equal(data.qs.ranges, JSON.stringify({'price': '[0 TO 10]'}))
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should encode array sort parameter', function(assert) {
- const p = db.search('fake', 'fake',
- { sort: ['-foo<number>','bar<string>'] },
- function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.equal(data.qs.sort, JSON.stringify(['-foo<number>','bar<string>']));
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should encode array sort parameter', function (assert) {
+ const p = db.search('fake', 'fake',
+ { sort: ['-foo<number>', 'bar<string>'] },
+ function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.equal(data.qs.sort, JSON.stringify(['-foo<number>', 'bar<string>']))
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should not encode string sort parameter', function(assert) {
- const p = db.search('fake', 'fake',
- { sort: JSON.stringify(['-foo<number>','bar<string>']) },
- function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.equal(data.qs.sort, JSON.stringify(['-foo<number>','bar<string>']));
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should not encode string sort parameter', function (assert) {
+ const p = db.search('fake', 'fake',
+ { sort: JSON.stringify(['-foo<number>', 'bar<string>']) },
+ function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.equal(data.qs.sort, JSON.stringify(['-foo<number>', 'bar<string>']))
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should encode unencoded sort parameter', function(assert) {
- const p = db.search('fake', 'fake',
- { sort: '-foo<number>' },
- function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.equal(data.qs.sort, JSON.stringify('-foo<number>'));
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should encode unencoded sort parameter', function (assert) {
+ const p = db.search('fake', 'fake',
+ { sort: '-foo<number>' },
+ function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.equal(data.qs.sort, JSON.stringify('-foo<number>'))
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should not encode encoded string sort parameter', function(assert) {
- const p = db.search('fake', 'fake',
- { sort: JSON.stringify('-foo<number>') },
- function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.equal(data.qs.sort, JSON.stringify('-foo<number>'));
- });
- assert.ok(helpers.isPromise(p), 'returns Promise');
- p.then(function(data) {
- assert.ok(true, 'Promise is resolved');
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.end();
- }).catch(function() {
- assert.ok(true, 'Promise is rejected');
- });
-});
+it('should not encode encoded string sort parameter', function (assert) {
+ const p = db.search('fake', 'fake',
+ { sort: JSON.stringify('-foo<number>') },
+ function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.equal(data.qs.sort, JSON.stringify('-foo<number>'))
+ })
+ assert.ok(helpers.isPromise(p), 'returns Promise')
+ p.then(function (data) {
+ assert.ok(true, 'Promise is resolved')
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.end()
+ }).catch(function () {
+ assert.ok(true, 'Promise is rejected')
+ })
+})
-it('should allow search results to be streamed', function(assert) {
- db.searchAsStream('fake', 'fake',
- { q: 'foo:bar' },
- function(err, data) {
- assert.equal(err, null);
- assert.equal(data.method, 'GET');
- assert.equal(typeof data.headers, 'object');
- assert.equal(typeof data.qs, 'object');
- assert.equal(data.qs.q, 'foo:bar');
- assert.end();
- });
-});
+it('should allow search results to be streamed', function (assert) {
+ db.searchAsStream('fake', 'fake',
+ { q: 'foo:bar' },
+ function (err, data) {
+ assert.equal(err, null)
+ assert.equal(data.method, 'GET')
+ assert.equal(typeof data.headers, 'object')
+ assert.equal(typeof data.qs, 'object')
+ assert.equal(data.qs.q, 'foo:bar')
+ assert.end()
+ })
+})
diff --git a/tests/unit/attachment/destroy.js b/tests/unit/attachment/destroy.js
index 084950f..43f8535 100644
--- a/tests/unit/attachment/destroy.js
+++ b/tests/unit/attachment/destroy.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const destroyAttachment = require('../../helpers/unit').unit([
'attachment',
'destroy'
-]);
+])
destroyAttachment('airplane-design', 'wings.pdf', {rev: '3'}, {
headers: {
@@ -25,4 +25,4 @@ destroyAttachment('airplane-design', 'wings.pdf', {rev: '3'}, {
method: 'DELETE',
qs: {rev: '3'},
uri: '/mock/airplane-design/wings.pdf'
-});
+})
diff --git a/tests/unit/attachment/get.js b/tests/unit/attachment/get.js
index 1972363..52eb997 100644
--- a/tests/unit/attachment/get.js
+++ b/tests/unit/attachment/get.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const getAttachment = require('../../helpers/unit').unit([
'attachment',
'get'
-]);
+])
getAttachment('airplane-design', 'wings.pdf', {rev: 'rev-3'}, {
encoding: null,
@@ -23,11 +23,11 @@ getAttachment('airplane-design', 'wings.pdf', {rev: 'rev-3'}, {
method: 'GET',
qs: {rev: 'rev-3'},
uri: '/mock/airplane-design/wings.pdf'
-});
+})
getAttachment('airplane-design', 'wings.pdf', {
encoding: null,
headers: {},
method: 'GET',
uri: '/mock/airplane-design/wings.pdf'
-});
+})
diff --git a/tests/unit/attachment/insert.js b/tests/unit/attachment/insert.js
index 0ed455f..88f26cc 100644
--- a/tests/unit/attachment/insert.js
+++ b/tests/unit/attachment/insert.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/unit');
-const insertAttachment = helpers.unit(['attachment', 'insert']);
+const helpers = require('../../helpers/unit')
+const insertAttachment = helpers.unit(['attachment', 'insert'])
-const buffer = new Buffer(helpers.pixel, 'base64');
+const buffer = Buffer.from(helpers.pixel, 'base64')
insertAttachment('pixels', 'pixel.bmp', buffer, 'image/bmp', {
body: buffer,
@@ -24,7 +24,7 @@ insertAttachment('pixels', 'pixel.bmp', buffer, 'image/bmp', {
},
method: 'PUT',
uri: '/mock/pixels/pixel.bmp'
-});
+})
insertAttachment('pixels', 'meta.txt', 'brown', 'text/plain', {
body: 'brown',
@@ -33,7 +33,7 @@ insertAttachment('pixels', 'meta.txt', 'brown', 'text/plain', {
},
method: 'PUT',
uri: '/mock/pixels/meta.txt'
-});
+})
insertAttachment('pixels', 'meta.txt', 'white', 'text/plain', {rev: '2'}, {
body: 'white',
@@ -43,4 +43,4 @@ insertAttachment('pixels', 'meta.txt', 'white', 'text/plain', {rev: '2'}, {
method: 'PUT',
uri: '/mock/pixels/meta.txt',
qs: {rev: '2'}
-});
+})
diff --git a/tests/unit/database/changes.js b/tests/unit/database/changes.js
index 8b017eb..7cbed00 100644
--- a/tests/unit/database/changes.js
+++ b/tests/unit/database/changes.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const changesDatabase = require('../../helpers/unit').unit([
'database',
'changes'
-]);
+])
changesDatabase('mock', {since: '10'}, {
headers: {
@@ -25,7 +25,7 @@ changesDatabase('mock', {since: '10'}, {
method: 'GET',
qs: {since: '10'},
uri: '/mock/_changes'
-});
+})
changesDatabase('mock', {
headers: {
@@ -34,4 +34,4 @@ changesDatabase('mock', {
},
method: 'GET',
uri: '/mock/_changes'
-});
+})
diff --git a/tests/unit/database/compact.js b/tests/unit/database/compact.js
index 0f36ba8..20f2b1b 100644
--- a/tests/unit/database/compact.js
+++ b/tests/unit/database/compact.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const compactDatabase = require('../../helpers/unit').unit([
'database',
'compact'
-]);
+])
compactDatabase('mock', {
headers: {
@@ -24,4 +24,4 @@ compactDatabase('mock', {
},
method: 'POST',
uri: '/mock/_compact'
-});
+})
diff --git a/tests/unit/database/create.js b/tests/unit/database/create.js
index 674f702..ff0d1f7 100644
--- a/tests/unit/database/create.js
+++ b/tests/unit/database/create.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const createDatabase = require('../../helpers/unit').unit([
'database',
'create'
-]);
+])
createDatabase('mock', {
headers: {
@@ -24,7 +24,7 @@ createDatabase('mock', {
},
method: 'PUT',
uri: '/mock'
-});
+})
createDatabase('az09_$()+-/', {
headers: {
@@ -33,4 +33,4 @@ createDatabase('az09_$()+-/', {
},
method: 'PUT',
uri: '/az09_%24()%2B-%2F'
-});
+})
diff --git a/tests/unit/database/destroy.js b/tests/unit/database/destroy.js
index 6378d8b..af36d02 100644
--- a/tests/unit/database/destroy.js
+++ b/tests/unit/database/destroy.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const destroyDatabase = require('../../helpers/unit').unit([
'database',
'destroy'
-]);
+])
destroyDatabase('mock', {
headers: {
@@ -24,4 +24,4 @@ destroyDatabase('mock', {
},
method: 'DELETE',
uri: '/mock'
-});
+})
diff --git a/tests/unit/database/follow.js b/tests/unit/database/follow.js
index 92d5cb1..48fd74e 100644
--- a/tests/unit/database/follow.js
+++ b/tests/unit/database/follow.js
@@ -10,11 +10,11 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const followDatabase = require('../../helpers/unit').unit([
'database',
'follow'
-]);
+])
-followDatabase('space', {db: '/space'});
+followDatabase('space', {db: '/space'})
diff --git a/tests/unit/database/get.js b/tests/unit/database/get.js
index 3cbae19..e478772 100644
--- a/tests/unit/database/get.js
+++ b/tests/unit/database/get.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const getDatabase = require('../../helpers/unit').unit([
'database',
'get'
-]);
+])
getDatabase('space', {
headers: {
@@ -24,4 +24,4 @@ getDatabase('space', {
},
method: 'GET',
uri: '/space'
-});
+})
diff --git a/tests/unit/database/list.js b/tests/unit/database/list.js
index 2d4e928..b5bf435 100644
--- a/tests/unit/database/list.js
+++ b/tests/unit/database/list.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const listDatabases = require('../../helpers/unit').unit([
'database',
'list'
-]);
+])
listDatabases({
headers: {
@@ -24,4 +24,4 @@ listDatabases({
},
method: 'GET',
uri: '/_all_dbs'
-});
+})
diff --git a/tests/unit/database/replicate.js b/tests/unit/database/replicate.js
index a55c08d..6ad47a1 100644
--- a/tests/unit/database/replicate.js
+++ b/tests/unit/database/replicate.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const replicateDatabase = require('../../helpers/unit').unit([
'database',
'replicate'
-]);
+])
replicateDatabase('baa', 'baashep', {
body: '{"source":"baa","target":"baashep"}',
@@ -25,7 +25,7 @@ replicateDatabase('baa', 'baashep', {
},
method: 'POST',
uri: '/_replicate'
-});
+})
replicateDatabase('molly', 'anne', {some: 'params'}, {
body: '{"some":"params","source":"molly","target":"anne"}',
@@ -35,4 +35,4 @@ replicateDatabase('molly', 'anne', {some: 'params'}, {
},
method: 'POST',
uri: '/_replicate'
-});
+})
diff --git a/tests/unit/database/replicator.js b/tests/unit/database/replicator.js
index 126df42..3c1da62 100644
--- a/tests/unit/database/replicator.js
+++ b/tests/unit/database/replicator.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const replicator = require('../../helpers/unit').unit([
'database',
'replicator'
-]);
+])
replicator('baa', 'baashep', {
body: '{"source":"baa","target":"baashep"}',
@@ -25,7 +25,7 @@ replicator('baa', 'baashep', {
},
method: 'POST',
uri: '/_replicator'
-});
+})
replicator('molly', 'anne', {some: 'params'}, {
body: '{"some":"params","source":"molly","target":"anne"}',
@@ -35,4 +35,4 @@ replicator('molly', 'anne', {some: 'params'}, {
},
method: 'POST',
uri: '/_replicator'
-});
+})
diff --git a/tests/unit/database/updates.js b/tests/unit/database/updates.js
index 6690018..43eb5d8 100644
--- a/tests/unit/database/updates.js
+++ b/tests/unit/database/updates.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const updatesDatabase = require('../../helpers/unit').unit([
'database',
'updates'
-]);
+])
updatesDatabase({
headers: {
@@ -24,7 +24,7 @@ updatesDatabase({
},
method: 'GET',
uri: '/_db_updates'
-});
+})
updatesDatabase({since: 1}, {
headers: {
@@ -34,4 +34,4 @@ updatesDatabase({since: 1}, {
method: 'GET',
qs: {since: 1},
uri: '/_db_updates'
-});
+})
diff --git a/tests/unit/design/atomic.js b/tests/unit/design/atomic.js
index a52d98e..1c926cc 100644
--- a/tests/unit/design/atomic.js
+++ b/tests/unit/design/atomic.js
@@ -10,17 +10,17 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const atomicDesign = require('../../helpers/unit').unit([
'view',
'atomic'
-]);
+])
atomicDesign('update', 'inplace', 'foobar', {
- field: 'foo',
- value: 'bar'
- }, {
+ field: 'foo',
+ value: 'bar'
+}, {
body: '{"field":"foo","value":"bar"}',
headers: {
accept: 'application/json',
@@ -28,4 +28,4 @@ atomicDesign('update', 'inplace', 'foobar', {
},
method: 'PUT',
uri: '/mock/_design/update/_update/inplace/foobar'
-});
+})
diff --git a/tests/unit/design/compact.js b/tests/unit/design/compact.js
index 1239193..aa08009 100644
--- a/tests/unit/design/compact.js
+++ b/tests/unit/design/compact.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const compactDesign = require('../../helpers/unit').unit([
'view',
'compact'
-]);
+])
compactDesign('alice', {
headers: {
@@ -24,4 +24,4 @@ compactDesign('alice', {
},
method: 'POST',
uri: '/mock/_compact/alice'
-});
+})
diff --git a/tests/unit/design/find.js b/tests/unit/design/find.js
index b8c6767..c3afe38 100644
--- a/tests/unit/design/find.js
+++ b/tests/unit/design/find.js
@@ -10,11 +10,11 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const findDesign = require('../../helpers/unit').unit([
'find',
'find'
-]);
+])
findDesign({
selector: {
@@ -28,4 +28,4 @@ findDesign({
},
method: 'POST',
uri: '/mock/_find'
-});
+})
diff --git a/tests/unit/design/list.js b/tests/unit/design/list.js
index e37fdfa..991830a 100644
--- a/tests/unit/design/list.js
+++ b/tests/unit/design/list.js
@@ -10,19 +10,19 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const listDesign = require('../../helpers/unit').unit([
'view',
'viewWithList'
-]);
+])
listDesign('people', 'by_name_and_city', 'my_list', {
- key: [
- 'Derek',
- 'San Francisco'
- ]
- }, {
+ key: [
+ 'Derek',
+ 'San Francisco'
+ ]
+}, {
headers: {
accept: 'application/json',
'content-type': 'application/json'
@@ -32,4 +32,4 @@ listDesign('people', 'by_name_and_city', 'my_list', {
'key': '["Derek","San Francisco"]'
},
uri: '/mock/_design/people/_list/my_list/by_name_and_city'
-});
+})
diff --git a/tests/unit/design/search.js b/tests/unit/design/search.js
index a7b6336..cfea4a9 100644
--- a/tests/unit/design/search.js
+++ b/tests/unit/design/search.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const searchDesign = require('../../helpers/unit').unit([
'view',
'search'
-]);
+])
searchDesign('alice', 'by_id', {
keys: 'dawg'
@@ -27,4 +27,4 @@ searchDesign('alice', 'by_id', {
},
method: 'POST',
uri: '/mock/_design/alice/_search/by_id'
-});
+})
diff --git a/tests/unit/design/show.js b/tests/unit/design/show.js
index 9b99dee..e435d2a 100644
--- a/tests/unit/design/show.js
+++ b/tests/unit/design/show.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const showDesign = require('../../helpers/unit').unit([
'view',
'show'
-]);
+])
showDesign('people', 'singleDoc', 'p_clemens', {
headers: {
@@ -24,4 +24,4 @@ showDesign('people', 'singleDoc', 'p_clemens', {
},
method: 'GET',
uri: '/mock/_design/people/_show/singleDoc/p_clemens'
-});
+})
diff --git a/tests/unit/design/spatial.js b/tests/unit/design/spatial.js
index d3ce830..da02d1b 100644
--- a/tests/unit/design/spatial.js
+++ b/tests/unit/design/spatial.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const geoDesign = require('../../helpers/unit').unit([
'view',
'spatial'
-]);
+])
geoDesign('people', 'byArea', {x: '1'}, {
headers: {
@@ -25,4 +25,4 @@ geoDesign('people', 'byArea', {x: '1'}, {
method: 'GET',
qs: {x: '1'},
uri: '/mock/_design/people/_spatial/byArea'
-});
+})
diff --git a/tests/unit/design/view.js b/tests/unit/design/view.js
index a9c8c14..da40d79 100644
--- a/tests/unit/design/view.js
+++ b/tests/unit/design/view.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const viewDesign = require('../../helpers/unit').unit([
'view',
'view'
-]);
+])
viewDesign('alice', 'by_id', {
keys: ['foobar', 'barfoo'],
@@ -31,4 +31,4 @@ viewDesign('alice', 'by_id', {
'include_docs': true
},
uri: '/mock/_design/alice/_view/by_id'
-});
+})
diff --git a/tests/unit/document/bulk.js b/tests/unit/document/bulk.js
index 9f874b7..ae6f8e3 100644
--- a/tests/unit/document/bulk.js
+++ b/tests/unit/document/bulk.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const bulkDocument = require('../../helpers/unit').unit([
'document',
'bulk'
-]);
+])
bulkDocument({
docs: [
@@ -30,7 +30,7 @@ bulkDocument({
},
method: 'POST',
uri: '/mock/_bulk_docs'
-});
+})
bulkDocument({
docs: []
@@ -43,4 +43,4 @@ bulkDocument({
method: 'POST',
qs: {wat: 'izlove'},
uri: '/mock/_bulk_docs'
-});
+})
diff --git a/tests/unit/document/copy.js b/tests/unit/document/copy.js
index 3722d13..b23732f 100644
--- a/tests/unit/document/copy.js
+++ b/tests/unit/document/copy.js
@@ -10,17 +10,17 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const copyDocument = require('../../helpers/unit').unit([
'document',
'copy'
-]);
+])
const copyDocumentFail = require('../../helpers/unit').unit([
'document',
'copy'
-], new Error('OMG This sucks'));
+], new Error('OMG This sucks'))
copyDocument('excel', 'numbers', {
headers: {
@@ -30,8 +30,8 @@ copyDocument('excel', 'numbers', {
},
method: 'COPY',
uri: '/mock/excel'
-});
+})
copyDocumentFail('excel', 'numbers', {overwrite: 'yes'}, {
-});
+})
diff --git a/tests/unit/document/get.js b/tests/unit/document/get.js
index cccb5bf..8f93a24 100644
--- a/tests/unit/document/get.js
+++ b/tests/unit/document/get.js
@@ -10,32 +10,32 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/unit');
-const test = require('tape');
-const debug = require('debug')('nano/tests/unit/shared/error');
+const helpers = require('../../helpers/unit')
+const test = require('tape')
+const debug = require('debug')('nano/tests/unit/shared/error')
-const cli = helpers.mockClientDb(debug);
-const db = cli.use('foo');
+const cli = helpers.mockClientDb(debug)
+const db = cli.use('foo')
-test('it should not return db info if docName undefined', function(assert) {
- db.get(undefined, function(err) {
- assert.equal(err, 'Invalid doc id');
- assert.end();
- });
-});
+test('it should not return db info if docName undefined', function (assert) {
+ db.get(undefined, function (err) {
+ assert.equal(err, 'Invalid doc id')
+ assert.end()
+ })
+})
-test('it should not return db info if docName null', function(assert) {
- db.get(null, function(err) {
- assert.equal(err, 'Invalid doc id');
- assert.end();
- });
-});
+test('it should not return db info if docName null', function (assert) {
+ db.get(null, function (err) {
+ assert.equal(err, 'Invalid doc id')
+ assert.end()
+ })
+})
-test('it should not return db info if docName empty string', function(assert) {
- db.get('', function(err) {
- assert.equal(err, 'Invalid doc id');
- assert.end();
- });
-});
\ No newline at end of file
+test('it should not return db info if docName empty string', function (assert) {
+ db.get('', function (err) {
+ assert.equal(err, 'Invalid doc id')
+ assert.end()
+ })
+})
diff --git a/tests/unit/multipart/get.js b/tests/unit/multipart/get.js
index ea9b6a7..a23fad9 100644
--- a/tests/unit/multipart/get.js
+++ b/tests/unit/multipart/get.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const getMultipart = require('../../helpers/unit').unit([
'multipart',
'get'
-]);
+])
getMultipart('space', {extra: 'stuff'}, {
encoding: null,
@@ -23,4 +23,4 @@ getMultipart('space', {extra: 'stuff'}, {
method: 'GET',
qs: {attachments: true, extra: 'stuff'},
uri: '/mock/space'
-});
+})
diff --git a/tests/unit/multipart/insert.js b/tests/unit/multipart/insert.js
index a3cccb4..e7c3ed6 100644
--- a/tests/unit/multipart/insert.js
+++ b/tests/unit/multipart/insert.js
@@ -10,18 +10,18 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const insertMultipart = require('../../helpers/unit').unit([
'multipart',
'insert'
-]);
+])
insertMultipart({hey: 1}, [{
- name: 'att',
- data: 'some',
- 'content_type': 'text/plain'
- }], {extra: 'stuff'}, {
+ name: 'att',
+ data: 'some',
+ 'content_type': 'text/plain'
+}], {extra: 'stuff'}, {
headers: {
'content-type': 'multipart/related'
},
@@ -38,4 +38,4 @@ insertMultipart({hey: 1}, [{
],
qs: {extra: 'stuff'},
uri: '/mock'
-});
+})
diff --git a/tests/unit/shared/error.js b/tests/unit/shared/error.js
index ff1dc8c..2fdac66 100644
--- a/tests/unit/shared/error.js
+++ b/tests/unit/shared/error.js
@@ -10,48 +10,48 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/unit');
-const test = require('tape');
-const debug = require('debug')('nano/tests/unit/shared/error');
+const helpers = require('../../helpers/unit')
+const test = require('tape')
+const debug = require('debug')('nano/tests/unit/shared/error')
-const cli = helpers.mockClientFail(debug);
-const cli2 = helpers.mockClientUnparsedError(debug);
+const cli = helpers.mockClientFail(debug)
+const cli2 = helpers.mockClientUnparsedError(debug)
const cli3 = helpers.mockClientUnparsedError(debug, JSON.stringify({
error: 'not a reason'
-}));
+}))
const cli4 = helpers.mockClientUnparsedError(debug, JSON.stringify({
stack: new Error('foo').stack
-}));
-
-test('it should be able to set a jar box', function(assert) {
- cli.relax({}, function(err) {
- assert.equal(err.message, 'error happened in your connection');
- assert.end();
- });
-});
-
-test('should be able to deal with html errors bad couches', function(assert) {
- cli2.relax({}, function(err) {
- assert.equal(err.message, '<b> Error happened </b>');
- assert.end();
- });
-});
-
-test('should be capable of using `error`', function(assert) {
- cli3.relax({}, function(err) {
- assert.equal(err.message, 'not a reason');
- assert.end();
- });
-});
-
-test('should remove cloudant stacktraces', function(assert) {
- cli4.relax({}, function(err) {
- const msg = err.stack.split('\n')[0];
- assert.notEqual(msg, 'Error: foo');
- assert.equal(msg, 'Error: Unspecified error');
- assert.end();
- });
-});
+}))
+
+test('it should be able to set a jar box', function (assert) {
+ cli.relax({}, function (err) {
+ assert.equal(err.message, 'error happened in your connection')
+ assert.end()
+ })
+})
+
+test('should be able to deal with html errors bad couches', function (assert) {
+ cli2.relax({}, function (err) {
+ assert.equal(err.message, '<b> Error happened </b>')
+ assert.end()
+ })
+})
+
+test('should be capable of using `error`', function (assert) {
+ cli3.relax({}, function (err) {
+ assert.equal(err.message, 'not a reason')
+ assert.end()
+ })
+})
+
+test('should remove cloudant stacktraces', function (assert) {
+ cli4.relax({}, function (err) {
+ const msg = err.stack.split('\n')[0]
+ assert.notEqual(msg, 'Error: foo')
+ assert.equal(msg, 'Error: Unspecified error')
+ assert.end()
+ })
+})
diff --git a/tests/unit/shared/follow-updates.js b/tests/unit/shared/follow-updates.js
index 78bc537..be10afa 100644
--- a/tests/unit/shared/follow-updates.js
+++ b/tests/unit/shared/follow-updates.js
@@ -10,12 +10,12 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
const followUpdates = require('../../helpers/unit').unit([
'server',
'followUpdates'
-]);
+])
-followUpdates({db: '/_db_updates'});
-followUpdates({since: 1}, {db: '/_db_updates', since: 1});
+followUpdates({db: '/_db_updates'})
+followUpdates({since: 1}, {db: '/_db_updates', since: 1})
diff --git a/tests/unit/shared/jar.js b/tests/unit/shared/jar.js
index aa901bf..29ff8fc 100644
--- a/tests/unit/shared/jar.js
+++ b/tests/unit/shared/jar.js
@@ -10,21 +10,21 @@
// License for the specific language governing permissions and limitations under
// the License.
-'use strict';
+'use strict'
-const helpers = require('../../helpers/unit');
-const test = require('tape');
-const debug = require('debug')('nano/tests/unit/shared/jar');
+const helpers = require('../../helpers/unit')
+const test = require('tape')
+const debug = require('debug')('nano/tests/unit/shared/jar')
-const cli = helpers.mockClientJar(debug);
+const cli = helpers.mockClientJar(debug)
-test('it should be able to set a jar box', function(assert) {
- assert.equal(cli.config.jar, 'is set');
- cli.relax({}, function(_, req) {
- assert.equal(req.jar, 'is set');
- cli.relax({jar: 'changed'}, function(_, req) {
- assert.equal(req.jar, 'changed');
- assert.end();
- });
- });
-});
+test('it should be able to set a jar box', function (assert) {
+ assert.equal(cli.config.jar, 'is set')
+ cli.relax({}, function (_, req) {
+ assert.equal(req.jar, 'is set')
+ cli.relax({jar: 'changed'}, function (_, req) {
+ assert.equal(req.jar, 'changed')
+ assert.end()
+ })
+ })
+})