This is an automated email from the ASF dual-hosted git repository. glynnbird pushed a commit to branch issue98 in repository https://gitbox.apache.org/repos/asf/couchdb-nano.git
commit dc7687db32e25d97811813182e1549ccfbff72dc Author: Glynn Bird <[email protected]> AuthorDate: Wed Jul 18 11:28:09 2018 +0100 swap out var for const/let in the core code and tests --- lib/logger.js | 8 +-- lib/nano.js | 78 ++++++++++++------------ tests/helpers/index.js | 16 ++--- tests/helpers/integration.js | 58 +++++++++--------- tests/helpers/unit.js | 24 ++++---- tests/integration/attachment/destroy.js | 12 ++-- tests/integration/attachment/get.js | 12 ++-- tests/integration/attachment/insert.js | 10 +-- tests/integration/attachment/pipe.js | 28 ++++----- tests/integration/attachment/update.js | 17 +++--- tests/integration/database/changes.js | 14 ++--- tests/integration/database/compact.js | 12 ++-- tests/integration/database/create-and-destroy.js | 12 ++-- tests/integration/database/follow.js | 12 ++-- tests/integration/database/get.js | 14 ++--- tests/integration/database/list.js | 12 ++-- tests/integration/database/replicate.js | 20 +++--- tests/integration/database/replicator.js | 18 +++--- tests/integration/design/atomic.js | 20 +++--- tests/integration/design/compact.js | 36 ++--------- tests/integration/design/list.js | 10 +-- tests/integration/design/multiple.js | 14 ++--- tests/integration/design/query.js | 14 ++--- tests/integration/design/search.js | 14 ++--- tests/integration/design/show.js | 12 ++-- tests/integration/document/bulk.js | 10 +-- tests/integration/document/copy.js | 14 ++--- tests/integration/document/create_index.js | 10 +-- tests/integration/document/destroy.js | 14 ++--- tests/integration/document/fetch.js | 14 ++--- tests/integration/document/fetch_revs.js | 14 ++--- tests/integration/document/find.js | 12 ++-- tests/integration/document/get.js | 10 +-- tests/integration/document/head.js | 10 +-- tests/integration/document/insert.js | 18 +++--- tests/integration/document/list.js | 24 ++++---- tests/integration/document/update.js | 15 ++--- tests/integration/multipart/get.js | 16 ++--- tests/integration/multipart/insert.js | 20 +++--- tests/integration/shared/config.js | 30 ++++----- tests/integration/shared/cookie.js | 18 +++--- tests/integration/shared/error.js | 14 ++--- tests/integration/shared/headers.js | 10 +-- tests/integration/shared/log.js | 11 ++-- tests/integration/util/uuid.js | 12 ++-- tests/intercept/design/search.js | 40 ++++++------ tests/unit/attachment/destroy.js | 2 +- tests/unit/attachment/get.js | 2 +- tests/unit/attachment/insert.js | 6 +- tests/unit/database/changes.js | 2 +- tests/unit/database/compact.js | 2 +- tests/unit/database/create.js | 2 +- tests/unit/database/destroy.js | 2 +- tests/unit/database/follow.js | 2 +- tests/unit/database/get.js | 2 +- tests/unit/database/list.js | 2 +- tests/unit/database/replicate.js | 2 +- tests/unit/database/replicator.js | 2 +- tests/unit/database/updates.js | 2 +- tests/unit/design/atomic.js | 2 +- tests/unit/design/compact.js | 2 +- tests/unit/design/find.js | 2 +- tests/unit/design/list.js | 2 +- tests/unit/design/search.js | 2 +- tests/unit/design/show.js | 2 +- tests/unit/design/spatial.js | 2 +- tests/unit/design/view.js | 2 +- tests/unit/document/bulk.js | 2 +- tests/unit/document/copy.js | 4 +- tests/unit/document/get.js | 10 +-- tests/unit/multipart/get.js | 2 +- tests/unit/multipart/insert.js | 2 +- tests/unit/shared/error.js | 16 ++--- tests/unit/shared/follow-updates.js | 2 +- tests/unit/shared/jar.js | 8 +-- 75 files changed, 446 insertions(+), 479 deletions(-) diff --git a/lib/logger.js b/lib/logger.js index 4d02fc3..8d74bb0 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -12,14 +12,14 @@ 'use strict'; -var debug = require('debug')('nano/logger'); +const debug = require('debug')('nano/logger'); module.exports = function logging(cfg) { - var log = cfg && cfg.log; - var logStrategy = typeof log === 'function' ? log : debug; + const log = cfg && cfg.log; + const logStrategy = typeof log === 'function' ? log : debug; return function logEvent(prefix) { - var eventId = (prefix ? prefix + '-' : '') + + const eventId = (prefix ? prefix + '-' : '') + (~~(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 6f54aa3..fe72b73 100644 --- a/lib/nano.js +++ b/lib/nano.js @@ -12,19 +12,19 @@ 'use strict'; -var u = require('url'); -var assert = require('assert'); -var querystring = require('querystring'); -var request = require('request'); -var errs = require('errs'); -var isEmpty = require('lodash.isempty'); -var follow = require('cloudant-follow'); -var logger = require('./logger'); +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'); -var nano; +let nano; module.exports = exports = nano = function dbScope(cfg) { - var serverScope = {}; + let serverScope = {}; if (typeof cfg === 'string') { cfg = {url: cfg}; @@ -39,21 +39,21 @@ module.exports = exports = nano = function dbScope(cfg) { serverScope.config = cfg; cfg.requestDefaults = cfg.requestDefaults || {jar: false}; - var httpAgent = (typeof cfg.request === 'function') ? cfg.request : + const httpAgent = (typeof cfg.request === 'function') ? cfg.request : request.defaults(cfg.requestDefaults); - var followAgent = (typeof cfg.follow === 'function') ? cfg.follow : follow; - var log = typeof cfg.log === 'function' ? cfg.log : logger(cfg); - var parseUrl = 'parseUrl' in cfg ? cfg.parseUrl : true; + 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() { if (!parseUrl) { return; } - var path = u.parse(cfg.url); - var pathArray = path.pathname.split('/').filter(function(e) { return e; }); - var db = pathArray.pop(); - var 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(/\/?$/, ''); @@ -67,16 +67,16 @@ module.exports = exports = nano = function dbScope(cfg) { } return str; } - var responseHandler = function(req, opts, resolve, reject, callback) { + const responseHandler = function(req, opts, resolve, reject, callback) { return function(e, h, b) { - var parsed; - var rh = h && h.headers || {}; + let parsed; + const rh = h && h.headers || {}; rh.statusCode = h && h.statusCode || 500; rh.uri = req.uri; if (e) { log({err: 'socket', body: b, headers: rh}); - var ret_e = errs.merge(e, { + const ret_e = errs.merge(e, { message: 'error happened in your connection', scope: 'socket', errid: 'request' @@ -131,7 +131,7 @@ module.exports = exports = nano = function dbScope(cfg) { req.headers.cookie = "XXXXXXX"; } - var errors = errs.merge({ + let errors = errs.merge({ message: 'couch returned ' + rh.statusCode, scope: 'couch', statusCode: rh.statusCode, @@ -166,21 +166,21 @@ module.exports = exports = nano = function dbScope(cfg) { callback = null; } - var qs = Object.assign({}, opts.qs); + const qs = Object.assign({}, opts.qs); - var headers = { + const headers = { 'content-type': 'application/json', accept: 'application/json' }; - var req = { + const req = { method: (opts.method || 'GET'), headers: headers, uri: cfg.url }; // https://github.com/mikeal/request#requestjar - var isJar = opts.jar || cfg.jar; + const isJar = opts.jar || cfg.jar; if (isJar) { req.jar = isJar; @@ -446,13 +446,13 @@ module.exports = exports = nano = function dbScope(cfg) { } function docModule(dbName) { - var docScope = {}; + 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, qs, callback) { - var opts = {db: dbName, body: doc, method: 'POST'}; + const opts = {db: dbName, body: doc, method: 'POST'}; if (typeof qs === 'function') { callback = qs; @@ -479,7 +479,7 @@ module.exports = exports = nano = function dbScope(cfg) { function destroyDoc(docName, rev, callback) { if(!docName) { if(callback) { - var msg = "Invalid doc id"; + const msg = 'Invalid doc id'; callback(msg, null); return new Promise(function(resolve, reject) { reject(msg); @@ -544,7 +544,7 @@ module.exports = exports = nano = function dbScope(cfg) { opts = {}; } - var qs = { + const qs = { db: dbName, doc: docSrc, method: 'COPY', @@ -631,13 +631,13 @@ module.exports = exports = nano = function dbScope(cfg) { } // prevent mutation of the client qs object by using a clone - var qs1 = Object.assign({}, qs); + const qs1 = Object.assign({}, qs); - var 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. - var paramsToEncode = ['counts', 'drilldown', 'group_sort', 'ranges', 'sort']; + const paramsToEncode = ['counts', 'drilldown', 'group_sort', 'ranges', 'sort']; paramsToEncode.forEach(function(param) { if (param in qs1) { if (typeof qs1[param] !== 'string') { @@ -656,7 +656,7 @@ module.exports = exports = nano = function dbScope(cfg) { if (qs1 && qs1.keys) { - var body = {keys: qs1.keys}; + const body = {keys: qs1.keys}; delete qs1.keys; return relax({ db: dbName, @@ -667,7 +667,7 @@ module.exports = exports = nano = function dbScope(cfg) { stream: meta.stream }, callback); } else { - var req = { + const req = { db: dbName, method: meta.method || 'GET', path: viewPath, @@ -756,12 +756,12 @@ module.exports = exports = nano = function dbScope(cfg) { } qs = qs || {}; - var docName = qs.docName; + const docName = qs.docName; delete qs.docName; doc = Object.assign({_attachments: {}}, doc); - var multipart = []; + const multipart = []; attachments.forEach(function(att) { doc._attachments[att.name] = { @@ -1026,7 +1026,7 @@ module.exports = exports = nano = function dbScope(cfg) { uuids: uuids }); - var db = maybeExtractDatabaseComponent(); + const db = maybeExtractDatabaseComponent(); return db ? docModule(db) : serverScope; }; diff --git a/tests/helpers/index.js b/tests/helpers/index.js index eb6a5d0..8cbebdc 100644 --- a/tests/helpers/index.js +++ b/tests/helpers/index.js @@ -12,14 +12,14 @@ 'use strict'; -var path = require('path'); -var fs = require('fs'); -var url = require('url'); -var nano = require('../../lib/nano'); +const path = require('path'); +const fs = require('fs'); +const url = require('url'); +const nano = require('../../lib/nano'); -var helpers = exports; -var cfg = helpers.cfg = require('../fixtures/cfg'); -var 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; @@ -34,7 +34,7 @@ helpers.username = auth[0]; helpers.password = auth[1]; helpers.loadFixture = function helpersLoadFixture(filename, json) { - var contents = fs.readFileSync( + const contents = fs.readFileSync( 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 d146e71..340c72f 100644 --- a/tests/helpers/integration.js +++ b/tests/helpers/integration.js @@ -12,18 +12,18 @@ 'use strict'; -var async = require('async'); -var debug = require('debug'); -var path = require('path'); -var harness = require('tape-it'); -var endsWith = require('endswith'); -var cfg = require('../fixtures/cfg'); -var nano = require('../../lib/nano'); -var helpers = require('./'); +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() { - var self = this; - var args = Array.prototype.slice.call(arguments); + const self = this; + const args = Array.prototype.slice.call(arguments); return function(assert) { args.push(function(err) { @@ -36,8 +36,8 @@ helpers.setup = function() { }; helpers.teardown = function() { - var self = this; - var args = Array.prototype.slice.call(arguments); + const self = this; + const args = Array.prototype.slice.call(arguments); return function(assert) { args.push(function(err) { @@ -51,21 +51,21 @@ helpers.teardown = function() { }; helpers.harness = function(name, setup, teardown) { - var parent = name || module.parent.filename; - var fileName = path.basename(parent).split('.')[0]; - var parentDir = path.dirname(parent) + const parent = name || module.parent.filename; + const fileName = path.basename(parent).split('.')[0]; + const parentDir = path.dirname(parent) .split(path.sep).reverse()[0]; - var shortPath = path.join(parentDir, fileName); - var log = debug(path.join('nano', 'tests', 'integration', shortPath)); - var dbName = shortPath.replace('/', '_'); - var nanoLog = nano({ + 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 }); - var mock = helpers.nock(helpers.couch, shortPath, log); - var db = nanoLog.use(dbName); - var locals = { + const mock = helpers.nock(helpers.couch, shortPath, log); + const db = nanoLog.use(dbName); + const locals = { mock: mock, db: db, nano: nanoLog @@ -82,15 +82,15 @@ helpers.harness = function(name, setup, teardown) { }; helpers.nock = function helpersNock(url, fixture, log) { - var nock = require('nock'); - var nockDefs = require('../fixtures/' + fixture + '.json'); + const nock = require('nock'); + const nockDefs = require('../fixtures/' + fixture + '.json'); nockDefs.forEach(function(n) { - var headers = n.headers || {}; - var response = n.buffer ? endsWith(n.buffer, '.png') ? + let headers = n.headers || {}; + const response = n.buffer ? endsWith(n.buffer, '.png') ? helpers.loadFixture(n.buffer) : new Buffer(n.buffer, 'base64') : n.response || ''; - var body = n.base64 ? new Buffer(n.base64, 'base64').toString() : + const body = n.base64 ? new Buffer(n.base64, 'base64').toString() : n.body || ''; if (typeof headers === 'string' && endsWith(headers, '.json')) { @@ -166,7 +166,7 @@ helpers.viewDerek = function viewDerek(db, assert, opts, next, method) { }; helpers.insertOne = function insertThree(assert) { - var db = this.db; + const db = this.db; db.insert({'foo': 'baz'}, 'foobaz', function(err) { assert.equal(err, null, 'should store docs'); assert.end(); @@ -174,7 +174,7 @@ helpers.insertOne = function insertThree(assert) { }; helpers.insertThree = function insertThree(assert) { - var db = this.db; + const db = this.db; async.parallel([ function(cb) { db.insert({'foo': 'bar'}, 'foobar', cb); }, function(cb) { db.insert({'bar': 'foo'}, 'barfoo', cb); }, diff --git a/tests/helpers/unit.js b/tests/helpers/unit.js index 52cd7e6..a15dfc6 100644 --- a/tests/helpers/unit.js +++ b/tests/helpers/unit.js @@ -12,20 +12,20 @@ 'use strict'; -var helpers = require('./'); -var Client = require('../../lib/nano'); -var test = require('tape'); -var _ = require('underscore'); +const helpers = require('./'); +const Client = require('../../lib/nano'); +const test = require('tape'); +const _ = require('underscore'); helpers.unit = function(method, error) { - var unitName = 'nano/tests/unit/' + method.join('/'); - var debug = require('debug')(unitName); + const unitName = 'nano/tests/unit/' + method.join('/'); + const debug = require('debug')(unitName); function log(data) { debug({ got: data.body }); } - var cli = helpers.mockClientOk(log, error); + let cli = helpers.mockClientOk(log, error); // // allow database creation and other server stuff @@ -40,15 +40,15 @@ helpers.unit = function(method, error) { cli.server = helpers.mockClientDb(log, error); } - var testNr = 1; + let testNr = 1; return function() { - var args = Array.prototype.slice.call(arguments); - var stub = args.pop(); + const args = Array.prototype.slice.call(arguments); + const stub = args.pop(); test(unitName + ':' + testNr++, function(assert) { - var f; + let f; assert.ok(typeof stub, 'object'); // @@ -101,7 +101,7 @@ helpers.unit = function(method, error) { function mockClient(code, path, extra) { return function(debug, error) { extra = extra || {}; - var opts = _.extend(extra, { + const opts = _.extend(extra, { url: helpers.couch + path, log: debug, request: function(req, cb) { diff --git a/tests/integration/attachment/destroy.js b/tests/integration/attachment/destroy.js index 9b5b7e6..cae9552 100644 --- a/tests/integration/attachment/destroy.js +++ b/tests/integration/attachment/destroy.js @@ -12,13 +12,13 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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) { - var p = db.attachment.insert('new', + 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'); @@ -42,7 +42,7 @@ it('should be able to insert a new plain text attachment', function(assert) { }); it('should fail destroying with a bad filename', function(assert) { - var p = db.attachment.destroy('new', false, true, function(error, response) { + 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'); diff --git a/tests/integration/attachment/get.js b/tests/integration/attachment/get.js index ad180d8..12c20ba 100644 --- a/tests/integration/attachment/get.js +++ b/tests/integration/attachment/get.js @@ -12,10 +12,10 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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) { db.attachment.insert('new_string', 'att', 'Hello', 'text/plain', @@ -23,7 +23,7 @@ it('should be able to fetch an attachment', function(assert) { assert.equal(error, null, 'should store `hello`'); assert.equal(hello.ok, true, 'response ok'); assert.ok(hello.rev, 'should have a revision number'); - var p = db.attachment.get('new_string', 'att', + 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'); @@ -45,7 +45,7 @@ it('should insert and fetch a binary file', function(assert) { assert.equal(error, null, 'should store `123`'); assert.equal(hello.ok, true, 'response ok'); assert.ok(hello.rev, 'should have a revision number'); - var p = db.attachment.get('new_binary', 'att', + 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'); diff --git a/tests/integration/attachment/insert.js b/tests/integration/attachment/insert.js index 821fb40..6389592 100644 --- a/tests/integration/attachment/insert.js +++ b/tests/integration/attachment/insert.js @@ -12,13 +12,13 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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) { - var p = db.attachment.insert('new', 'att', 'Hello World!', 'text/plain', + 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'); diff --git a/tests/integration/attachment/pipe.js b/tests/integration/attachment/pipe.js index 3470c61..e81ff08 100644 --- a/tests/integration/attachment/pipe.js +++ b/tests/integration/attachment/pipe.js @@ -12,18 +12,18 @@ 'use strict'; -var fs = require('fs'); -var path = require('path'); -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var it = harness.it; -var 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) { - var buffer = new Buffer(pixel, 'base64'); - var filename = path.join(__dirname, '.temp.bmp'); - var ws = fs.createWriteStream(filename); + const buffer = new Buffer(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); @@ -39,7 +39,7 @@ it('should be able to pipe to a writeStream', function(assert) { }); it('should be able to pipe to a writeStream', function(assert) { - var ws = fs.createWriteStream('/dev/null'); + const ws = fs.createWriteStream('/dev/null'); db.attachment.getAsStream('new', 'att', function() {}) .pipe(ws) .on('end', function() { @@ -48,9 +48,9 @@ it('should be able to pipe to a writeStream', function(assert) { }); it('should be able to pipe from a readStream', function(assert) { - var logo = path.join(__dirname, '..', '..', 'fixtures', 'logo.png'); - var rs = fs.createReadStream(logo); - var is = db.attachment.insertAsStream('nodejs', 'logo.png', null, 'image/png', function() { + 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() { diff --git a/tests/integration/attachment/update.js b/tests/integration/attachment/update.js index 11d1b22..7d3bae8 100644 --- a/tests/integration/attachment/update.js +++ b/tests/integration/attachment/update.js @@ -12,21 +12,22 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var pixel = helpers.pixel; -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var it = harness.it; -var rev; +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; it('should be able to insert and update attachments', function(assert) { - var buffer = new Buffer(pixel, 'base64'); + const buffer = new Buffer(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'); - var p = db.attachment.insert('new', 'att', buffer, 'image/bmp', + 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'); diff --git a/tests/integration/database/changes.js b/tests/integration/database/changes.js index d13493d..b223f9b 100644 --- a/tests/integration/database/changes.js +++ b/tests/integration/database/changes.js @@ -12,15 +12,15 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var 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 receive changes since seq:0', function(assert) { - var p = db.changes({since:0}, function(error, response) { + 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'); }); @@ -35,7 +35,7 @@ it('should be able to receive changes since seq:0', function(assert) { }); it('should be able to receive changes since seq:0 as stream', function(assert) { - var p = db.changesAsStream({since:0}, function(error, response) { + 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(); @@ -45,7 +45,7 @@ it('should be able to receive changes since seq:0 as stream', function(assert) { }); it('should be able to receive changes - no params - stream', function(assert) { - var p = db.changesAsStream(function(error) { + const p = db.changesAsStream(function(error) { assert.equal(error, null, 'gets response from changes'); assert.end(); }); diff --git a/tests/integration/database/compact.js b/tests/integration/database/compact.js index 50ed454..ef6137f 100644 --- a/tests/integration/database/compact.js +++ b/tests/integration/database/compact.js @@ -12,10 +12,10 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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) { @@ -30,7 +30,7 @@ it('should store and delete `goofy`', function(assert) { }); it('should have run the compaction', function(assert) { - var p = db.compact(function(error) { + 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'); @@ -64,5 +64,5 @@ it('should finish compaction before ending', function(assert) { }); } - var 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 94d082b..af8259c 100644 --- a/tests/integration/database/create-and-destroy.js +++ b/tests/integration/database/create-and-destroy.js @@ -12,11 +12,11 @@ 'use strict'; -var async = require('async'); -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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) { @@ -27,7 +27,7 @@ it('should be able to create `az09_$()+-/` database', function(assert) { it('should be able to use config from a nano object to create a db', function(assert) { - var config = helpers.Nano( + 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'); diff --git a/tests/integration/database/follow.js b/tests/integration/database/follow.js index e66749c..42ce686 100644 --- a/tests/integration/database/follow.js +++ b/tests/integration/database/follow.js @@ -12,18 +12,18 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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); - var feed1; + let feed1; it('should be able to get the changes feed', function(assert) { - var i = 3; + let i = 3; feed1 = db.follow({since: '0'}); diff --git a/tests/integration/database/get.js b/tests/integration/database/get.js index ce1e61c..a01ece8 100644 --- a/tests/integration/database/get.js +++ b/tests/integration/database/get.js @@ -12,13 +12,13 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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) { - var p = nano.db.get('database_get', function(error, response) { + 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'); @@ -35,9 +35,9 @@ it('should be able to fetch the database', function(assert) { }); it('resolves db URL correctly for http://app.com/_couchdb', function(assert) { - var nano = require('../../../lib/nano'); + const nano = require('../../../lib/nano'); - var couch = nano({ + const couch = nano({ url: 'http://app.com/_couchdb/', parseUrl: false, request: function(options) { diff --git a/tests/integration/database/list.js b/tests/integration/database/list.js index f689681..aa35a47 100644 --- a/tests/integration/database/list.js +++ b/tests/integration/database/list.js @@ -12,10 +12,10 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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() { @@ -28,9 +28,9 @@ it('should ensure _replicator and _users are created', function(assert) { }); it('should list the correct databases', function(assert) { - var p = nano.db.list(function(error, list) { + const p = nano.db.list(function(error, list) { assert.equal(error, null, 'should list databases'); - var filtered = list.filter(function(e) { + const filtered = list.filter(function(e) { return e === 'database_list' || e === '_replicator' || e === '_users'; }); assert.equal(filtered.length, 3, 'should have exactly 3 dbs'); diff --git a/tests/integration/database/replicate.js b/tests/integration/database/replicate.js index 1212d0a..5ca95aa 100644 --- a/tests/integration/database/replicate.js +++ b/tests/integration/database/replicate.js @@ -12,15 +12,15 @@ 'use strict'; -var async = require('async'); -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var db = harness.locals.db; -var 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; -var replica; -var replica2; +let replica; +let replica2; it('should insert a bunch of items', helpers.insertThree); @@ -35,7 +35,7 @@ it('creates a bunch of database replicas', function(assert) { it('should be able to replicate three docs', function(assert) { replica = nano.use('database_replica'); - var p = db.replicate('database_replica', function(error) { + 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'); @@ -66,7 +66,7 @@ it('should be able to replicate to a `nano` object', function(assert) { }); it('should be able to replicate with params', function(assert) { - var p = db.replicate('database_replica', {}, function(error) { + const p = db.replicate('database_replica', {}, function(error) { assert.equal(error, null, 'replication should work'); }); assert.ok(helpers.isPromise(p), 'returns Promise'); diff --git a/tests/integration/database/replicator.js b/tests/integration/database/replicator.js index 46db4c6..0585292 100644 --- a/tests/integration/database/replicator.js +++ b/tests/integration/database/replicator.js @@ -12,16 +12,16 @@ 'use strict'; -var async = require('async'); -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var db = harness.locals.db; -var 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; -var replica; -var replica2; -var replica3; +let replica; +let replica2; +let replica3; it('should insert a bunch of items', helpers.insertThree); diff --git a/tests/integration/design/atomic.js b/tests/integration/design/atomic.js index b9d46ea..2c18848 100644 --- a/tests/integration/design/atomic.js +++ b/tests/integration/design/atomic.js @@ -12,18 +12,18 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var db = harness.locals.db; +const helpers = require('../../helpers/integration'); +const harness = helpers.harness(__filename); +const it = harness.it; +const db = harness.locals.db; -var rev; +let rev; it('should be able to insert an atomic design doc', function(assert) { - var p = db.insert({ + const p = db.insert({ updates: { inplace: function(doc, req) { - var body = JSON.parse(req.body); + const body = JSON.parse(req.body); doc[body.field] = body.value; return [doc, JSON.stringify(doc)]; }, @@ -46,7 +46,7 @@ it('should be able to insert an atomic design doc', function(assert) { }); it('should be able to insert atomically', function(assert) { - var p = db.atomic('update', 'inplace', 'foobar', { + const p = db.atomic('update', 'inplace', 'foobar', { field: 'foo', value: 'bar' }, function(error, response) { @@ -58,7 +58,7 @@ it('should be able to insert atomically', function(assert) { }); it('should be able to update atomically without a body', function (assert) { - var p = db.insert({}, 'baz', function () { + 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'); @@ -69,7 +69,7 @@ it('should be able to update atomically without a body', function (assert) { }); it('should be able to update with slashes on the id', function(assert) { - var p = db.insert({'wat': 'wat'}, 'wat/wat', function(error, foo) { + 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', { diff --git a/tests/integration/design/compact.js b/tests/integration/design/compact.js index 9628dba..fbcdfe4 100644 --- a/tests/integration/design/compact.js +++ b/tests/integration/design/compact.js @@ -12,11 +12,11 @@ 'use strict'; -var async = require('async'); -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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) { async.waterfall([ @@ -40,29 +40,3 @@ it('should insert `alice` the design doc', function(assert) { assert.end(); }); }); - -/*it('should be able to compact a view', function(assert) { - async.waterfall([ - function(next) { - db.view.compact('alice', next); - }, - function(response, _, next) { - function dbInfo() { - db.info(function(err, info) { - if (!info['compact_running']) { - clearInterval(task); - next(); - } - }); - } - var task = setInterval(dbInfo, 50); - }, - function(next) { - db.view('alice', 'by_id', next); - } - ], function(err, view) { - assert.equal(err, null, 'should be able to call the view'); - assert.equal(view['total_rows'], 0, 'and see stuff got deleted'); - assert.end(); - }); -});*/ diff --git a/tests/integration/design/list.js b/tests/integration/design/list.js index 7dcdf1a..514638c 100644 --- a/tests/integration/design/list.js +++ b/tests/integration/design/list.js @@ -12,15 +12,15 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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 get the people by running the ddoc', function(assert) { - var p = db.viewWithList('people', 'by_name_and_city', 'my_list', { + const p = db.viewWithList('people', 'by_name_and_city', 'my_list', { key: [ 'Derek', 'San Francisco' diff --git a/tests/integration/design/multiple.js b/tests/integration/design/multiple.js index 8868be2..6205638 100644 --- a/tests/integration/design/multiple.js +++ b/tests/integration/design/multiple.js @@ -12,13 +12,13 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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) { - var p = db.insert({ + const p = db.insert({ views: { 'by_id': { map: 'function(doc) { emit(doc._id, doc); }' @@ -41,7 +41,7 @@ it('should be able to insert docs and design doc', function(assert) { it('should insert a bunch of items', helpers.insertThree); it('get multiple docs with a composed key', function(assert) { - var p = db.view('alice', 'by_id', { + const p = db.view('alice', 'by_id', { keys: ['foobar', 'barfoo'], 'include_docs': true }, function(err, view) { @@ -63,7 +63,7 @@ it('get multiple docs with a composed key', function(assert) { }); it('get multiple docs with a composed key as a stream', function(assert) { - var p = db.viewAsStream('alice', 'by_id', { + const p = db.viewAsStream('alice', 'by_id', { keys: ['foobar', 'barfoo'], 'include_docs': true }, function(err, view) { diff --git a/tests/integration/design/query.js b/tests/integration/design/query.js index c2b2022..0d49a65 100644 --- a/tests/integration/design/query.js +++ b/tests/integration/design/query.js @@ -12,14 +12,14 @@ 'use strict'; -var async = require('async'); -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var db = harness.locals.db; -var 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; -var opts = {key: ['Derek', 'San Francisco']}; +const opts = {key: ['Derek', 'San Francisco']}; it('should create a ddoc and insert some docs', helpers.prepareAView); diff --git a/tests/integration/design/search.js b/tests/integration/design/search.js index ce7a439..94c37a5 100644 --- a/tests/integration/design/search.js +++ b/tests/integration/design/search.js @@ -12,19 +12,19 @@ 'use strict'; -var async = require('async'); -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var db = harness.locals.db; -var 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) { - var 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); diff --git a/tests/integration/design/show.js b/tests/integration/design/show.js index f22a8e5..174339f 100644 --- a/tests/integration/design/show.js +++ b/tests/integration/design/show.js @@ -12,11 +12,11 @@ 'use strict'; -var async = require('async'); -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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) { db.insert({ @@ -73,7 +73,7 @@ it('should insert a show ddoc', function(assert) { }); it('should show the amazing clemens in json', function(assert) { - var p = db.show('people', 'singleDoc', 'p_clemens', function(error, doc, rh) { + 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'); diff --git a/tests/integration/document/bulk.js b/tests/integration/document/bulk.js index 61b156f..65dac59 100644 --- a/tests/integration/document/bulk.js +++ b/tests/integration/document/bulk.js @@ -12,13 +12,13 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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) { - var p = db.bulk({ + const p = db.bulk({ 'docs': [ {'key':'baz', 'name':'bazzel'}, {'key':'bar', 'name':'barry'} diff --git a/tests/integration/document/copy.js b/tests/integration/document/copy.js index a49769f..3353b42 100644 --- a/tests/integration/document/copy.js +++ b/tests/integration/document/copy.js @@ -12,10 +12,10 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var 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) { @@ -32,7 +32,7 @@ it('must insert two docs before the tests start', function(assert) { }); it('should be able to copy and overwrite a document', function(assert) { - var p = db.copy('foo_src', 'foo_dest', {overwrite: true}, + 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'); @@ -49,7 +49,7 @@ it('should be able to copy and overwrite a document', function(assert) { it('copy without overwrite should return conflict for exists docs', function(assert) { - var p = db.copy('foo_src', 'foo_dest', function(error) { + 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'); @@ -62,7 +62,7 @@ function(assert) { }); it('copy to a new destination should work', function(assert) { - var p = db.copy('foo_src', 'baz_dest', function(error, response, headers) { + 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'); }); diff --git a/tests/integration/document/create_index.js b/tests/integration/document/create_index.js index 2a2570c..6f8ce3f 100644 --- a/tests/integration/document/create_index.js +++ b/tests/integration/document/create_index.js @@ -12,15 +12,15 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var 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 create one simple index', function(assert) { - var p = db.createIndex({ + const p = db.createIndex({ name: 'fooindex', index: { fields: ['foo'] } }, function(error, foo) { diff --git a/tests/integration/document/destroy.js b/tests/integration/document/destroy.js index 4bea37a..b8e3f28 100644 --- a/tests/integration/document/destroy.js +++ b/tests/integration/document/destroy.js @@ -12,12 +12,12 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; -var db = harness.locals.db; +const helpers = require('../../helpers/integration'); +const harness = helpers.harness(__filename); +const it = harness.it; +const db = harness.locals.db; -var rev; +let rev; it('should insert a document', function(assert) { db.insert({'foo': 'baz'}, 'foobaz', function(error, foo) { @@ -30,7 +30,7 @@ it('should insert a document', function(assert) { }); it('should not delete a db', function(assert) { - var p = db.destroy(undefined, undefined, function(error, response) { + const p = db.destroy(undefined, undefined, function(error, response) { assert.equal(error, 'Invalid doc id', 'validated delete parameters'); assert.equal(response, null, 'ok!'); }); @@ -44,7 +44,7 @@ it('should not delete a db', function(assert) { }); it('should delete a document', function(assert) { - var p = db.destroy('foobaz', rev, function(error, response) { + const p = db.destroy('foobaz', rev, function(error, response) { assert.equal(error, null, 'deleted foo'); assert.equal(response.ok, true, 'ok!'); }); diff --git a/tests/integration/document/fetch.js b/tests/integration/document/fetch.js index becf6a3..eaf68a8 100644 --- a/tests/integration/document/fetch.js +++ b/tests/integration/document/fetch.js @@ -12,15 +12,15 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var 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 be able to fetch with one key', function(assert) { - var p = db.fetch({keys:['foobar']}, function(error, docs) { + 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'); @@ -37,7 +37,7 @@ it('should be able to fetch with one key', function(assert) { }); it('should be able to fetch with multiple keys', function(assert) { - var p = db.fetch({keys:['foobar', 'barfoo']}, function(error, docs) { + 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'); @@ -54,7 +54,7 @@ it('should be able to fetch with multiple keys', function(assert) { }); it('should be able to fetch with params', function(assert) { - var p = db.fetch({keys:['foobar']}, {not: 'important'}, function(error, docs) { + 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'); diff --git a/tests/integration/document/fetch_revs.js b/tests/integration/document/fetch_revs.js index d30cddc..f19ba0e 100644 --- a/tests/integration/document/fetch_revs.js +++ b/tests/integration/document/fetch_revs.js @@ -12,15 +12,15 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var 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 be able to fetch with one key', function(assert) { - var p = db.fetchRevs({keys:['foobar']}, function(error, docs) { + 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'); @@ -39,7 +39,7 @@ it('should be able to fetch with one key', function(assert) { }); it('should be able to fetch with multiple keys', function(assert) { - var p = db.fetchRevs({keys:['foobar', 'barfoo']}, function(error, docs) { + 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'); @@ -60,7 +60,7 @@ it('should be able to fetch with multiple keys', function(assert) { }); it('should be able to fetch with params', function(assert) { - var p = db.fetchRevs({keys:['foobar']}, {still: 'no'}, function(error, docs) { + 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'); diff --git a/tests/integration/document/find.js b/tests/integration/document/find.js index 28d504a..4959469 100644 --- a/tests/integration/document/find.js +++ b/tests/integration/document/find.js @@ -12,15 +12,15 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var 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 be to do a mango query', function(assert) { - var p = db.find({ selector: { foo: 'baz'}}, function(error, response) { + 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'); }); @@ -35,7 +35,7 @@ it('should be to do a mango query', function(assert) { }); it('should be to do a mango query with streams', function(assert) { - var p = db.findAsStream({ selector: { foo: 'baz'}}, function(error, response) { + 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(); diff --git a/tests/integration/document/get.js b/tests/integration/document/get.js index ed6814f..b6223a4 100644 --- a/tests/integration/document/get.js +++ b/tests/integration/document/get.js @@ -12,15 +12,15 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var 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 get the document', function(assert) { - var p = db.get('foobaz', {'revs_info': true}, function(error, foobaz) { + 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'); diff --git a/tests/integration/document/head.js b/tests/integration/document/head.js index 1b98f81..4ab2647 100644 --- a/tests/integration/document/head.js +++ b/tests/integration/document/head.js @@ -12,15 +12,15 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var 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 get a status code when you do head', function(assert) { - var p = db.head('foobaz', function(error, body, headers) { + 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'); }); diff --git a/tests/integration/document/insert.js b/tests/integration/document/insert.js index fa05d37..d38ed12 100644 --- a/tests/integration/document/insert.js +++ b/tests/integration/document/insert.js @@ -12,15 +12,15 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var it = harness.it; +const helpers = require('../../helpers/integration'); +const harness = helpers.harness(__filename); +const db = harness.locals.db; +const it = harness.it; -var rev; +let rev; it('should insert one simple document', function(assert) { - var p = db.insert({'foo': 'baz'}, 'foobaz', function(error, foo) { + 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'); @@ -38,7 +38,7 @@ it('should insert one simple document', function(assert) { }); it('should fail to insert again since it already exists', function(assert) { - var p = db.insert({}, 'foobaz', function(error) { + 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'); @@ -55,7 +55,7 @@ it('should fail to insert again since it already exists', function(assert) { }); it('should be able to use custom params in insert', function(assert) { - var p = db.insert({ + const p = db.insert({ foo: 'baz', _rev: rev }, { @@ -78,7 +78,7 @@ it('should be able to use custom params in insert', function(assert) { }); it('should be able to insert functions in docs', function(assert) { - var p = db.insert({ + const p = db.insert({ fn: function() { return true; }, fn2: 'function () { return true; }' }, function(error, fns) { diff --git a/tests/integration/document/list.js b/tests/integration/document/list.js index 9b336bd..1bd580a 100644 --- a/tests/integration/document/list.js +++ b/tests/integration/document/list.js @@ -12,16 +12,16 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var nano = harness.locals.nano; -var 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 list the three documents', function(assert) { - var p = db.list(function(error, docs) { + 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'); @@ -53,7 +53,7 @@ it('should be able to list using the `relax` function', function(assert) { }); it('should be able to list with a start_key', function(assert) { - var p = db.list({start_key: 'c'}, function(error, docs) { + 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'); @@ -74,7 +74,7 @@ it('should be able to list with a start_key', function(assert) { }); it('should be able to list with a startkey', function(assert) { - var p = db.list({startkey: 'c'}, function(error, docs) { + 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'); @@ -95,7 +95,7 @@ it('should be able to list with a startkey', function(assert) { }); it('should be able to list with a endkey', function(assert) { - var p = db.list({endkey: 's'}, function(error, docs) { + 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'); @@ -116,7 +116,7 @@ it('should be able to list with a endkey', function(assert) { }); it('should be able to list with a end_key', function(assert) { - var p = db.list({end_key: 's'}, function(error, docs) { + 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'); @@ -137,7 +137,7 @@ it('should be able to list with a end_key', function(assert) { }); it('should be able to list as a stream', function(assert) { - var p = db.listAsStream(function(error) { + const p = db.listAsStream(function(error) { assert.equal(error, null, 'should work'); }); assert.ok(!helpers.isPromise(p), 'does not return Promise'); @@ -145,7 +145,7 @@ it('should be able to list as a stream', function(assert) { }); it('should be able to list with params as a stream', function(assert) { - var p = db.listAsStream({end_key: 's'}, function(error) { + const p = db.listAsStream({end_key: 's'}, function(error) { assert.equal(error, null, 'should work'); }); assert.ok(!helpers.isPromise(p), 'does not return Promise'); diff --git a/tests/integration/document/update.js b/tests/integration/document/update.js index 38630bd..7853ca0 100644 --- a/tests/integration/document/update.js +++ b/tests/integration/document/update.js @@ -12,14 +12,15 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var it = harness.it; -var rev; +const helpers = require('../../helpers/integration'); +const harness = helpers.harness(__filename); +const db = harness.locals.db; +const it = harness.it; + +let rev; it('should insert one doc', function(assert) { - var p = db.insert({'foo': 'baz'}, 'foobar', function(error, foo) { + 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'); @@ -37,7 +38,7 @@ it('should insert one doc', function(assert) { }); it('should update the document', function(assert) { - var p = db.insert({foo: 'bar', '_rev': rev}, 'foobar', function(error, response) { + 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'); }); diff --git a/tests/integration/multipart/get.js b/tests/integration/multipart/get.js index 370014f..3da281e 100644 --- a/tests/integration/multipart/get.js +++ b/tests/integration/multipart/get.js @@ -12,21 +12,21 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var it = harness.it; +const helpers = require('../../helpers/integration'); +const harness = helpers.harness(__filename); +const db = harness.locals.db; +const it = harness.it; -var rev; +let rev; it('should be able to insert a doc with att', function(assert) { - var att = { + const att = { name: 'att', data: 'Hello World!', 'content_type': 'text/plain' }; - var p = db.multipart.insert({'foo': 'baz'}, [att], 'foobaz', function(error, foo) { + 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'); @@ -46,7 +46,7 @@ it('should be able to insert a doc with att', function(assert) { }); it('should be able to get the document with the attachment', function(assert) { - var p = db.multipart.get('foobaz', function(error, foobaz, headers) { + 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'); diff --git a/tests/integration/multipart/insert.js b/tests/integration/multipart/insert.js index 44aac9d..f80d26c 100644 --- a/tests/integration/multipart/insert.js +++ b/tests/integration/multipart/insert.js @@ -12,18 +12,18 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var db = harness.locals.db; -var 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) { - var att = { + const att = { name: 'att', data: 'काचं शक्नोम्यत्तुम् । नोपहिनस्ति माम् ॥', 'content_type': 'text/plain' }; - var p = db.multipart.insert({'foo': 'bar'}, [att], 'foobar', function(error, foo) { + 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'); @@ -40,13 +40,13 @@ it('should handle crazy encodings', function(assert) { }); it('should test with presence of attachment', function(assert) { - var att = { + const att = { name: 'two', data: 'Hello World!', 'content_type': 'text/plain' }; - var p = db.attachment.insert('mydoc', 'one', 'Hello World!', '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) { @@ -64,12 +64,12 @@ it('should test with presence of attachment', function(assert) { }); it('should work with attachment as a buffer', function(assert) { - var att = { + const att = { name: 'att', data: new Buffer('foo'), 'content_type': 'text/plain' }; - var p = db.multipart.insert({'foo': 'bar'}, [att], 'otherdoc', function(error, foo) { + 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'); diff --git a/tests/integration/shared/config.js b/tests/integration/shared/config.js index 1575b65..e5d78d2 100644 --- a/tests/integration/shared/config.js +++ b/tests/integration/shared/config.js @@ -12,15 +12,15 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var nano = harness.locals.nano; -var Nano = helpers.Nano; +const helpers = require('../../helpers/integration'); +const harness = helpers.harness(__filename); +const nano = harness.locals.nano; +const Nano = helpers.Nano; -var it = harness.it; +const it = harness.it; it('should serve the root when no path is specified', function(assert) { - var p = nano.dinosaur('', function(err, response) { + 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) { @@ -39,7 +39,7 @@ it('should serve the root when no path is specified', function(assert) { }); it('should be able to parse urls', function(assert) { - var baseUrl = 'http://someurl.com'; + const baseUrl = 'http://someurl.com'; assert.equal( Nano(baseUrl).config.url, baseUrl, @@ -55,14 +55,6 @@ it('should be able to parse urls', function(assert) { 'http://a:[email protected]:5984', 'with authentication'); - //var withDb = Nano({ - // url: 'http://a:[email protected]:5984', - // db: 'foo' - //}) - - //assert.equal(withDb.config.db, 'foo', 'should create url with db'); - //assert.ok(withDb.attachment, 'should have an attachment'); - assert.equal( Nano('http://a:b%[email protected]:5984/mydb').config.url, 'http://a:b%[email protected]:5984', @@ -97,7 +89,7 @@ it('should be able to parse urls', function(assert) { }); it('should not parse urls when parseURL flag set to false', function(assert) { - var url = 'http://someurl.com/path'; + const url = 'http://someurl.com/path'; assert.equal( Nano({ @@ -111,7 +103,7 @@ it('should not parse urls when parseURL flag set to false', function(assert) { }); it('should accept and handle customer http headers', function(assert) { - var nanoWithDefaultHeaders = Nano({ + const nanoWithDefaultHeaders = Nano({ url: helpers.couch, defaultHeaders: { 'x-custom-header': 'custom', @@ -119,7 +111,7 @@ it('should accept and handle customer http headers', function(assert) { } }); - var req = nanoWithDefaultHeaders.db.listAsStream(function(err) { + const req = nanoWithDefaultHeaders.db.listAsStream(function(err) { assert.equal(err, null, 'should list'); assert.end(); }); @@ -136,7 +128,7 @@ it('should accept and handle customer http headers', function(assert) { }); it('should prevent shallow object copies', function(assert) { - var config = { + const config = { url: 'http://someurl.com' }; diff --git a/tests/integration/shared/cookie.js b/tests/integration/shared/cookie.js index 6690264..15c2bac 100644 --- a/tests/integration/shared/cookie.js +++ b/tests/integration/shared/cookie.js @@ -12,14 +12,14 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var nano = harness.locals.nano; -var Nano = helpers.Nano; -var 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; -var cookie; -var server; +let cookie; +let server; it('should be able to create a user', function(assert) { nano.relax({ @@ -51,9 +51,9 @@ it('should be able to insert with a cookie', function(assert) { url: helpers.couch, cookie: cookie }); - var db = server.use('shared_cookie'); + const db = server.use('shared_cookie'); - var p = db.insert({'foo': 'baz'}, null, function(error, response) { + 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'); diff --git a/tests/integration/shared/error.js b/tests/integration/shared/error.js index b74628e..d9a1a87 100644 --- a/tests/integration/shared/error.js +++ b/tests/integration/shared/error.js @@ -12,11 +12,11 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var nano = harness.locals.nano; -var Nano = helpers.Nano; -var 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) { try { @@ -35,7 +35,7 @@ it('should throw when initialize fails', function(assert) { }); it('should be able to stream the simplest request', function(assert) { - var root = nano.request({stream: true}); + const root = nano.request({stream: true}); root.on('end', function() { assert.pass('request worked'); assert.end(); @@ -43,7 +43,7 @@ it('should be able to stream the simplest request', function(assert) { }); it('should error when destroying a db that does not exist', function(assert) { - var p = nano.db.destroy('say_wat_wat', function(error) { + 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'); diff --git a/tests/integration/shared/headers.js b/tests/integration/shared/headers.js index b4af027..1a9880c 100644 --- a/tests/integration/shared/headers.js +++ b/tests/integration/shared/headers.js @@ -12,11 +12,11 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var nano = harness.locals.nano; -var db = harness.locals.db; -var 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) { db.attachment.insert('new', 'att', 'Hello', 'text/plain', diff --git a/tests/integration/shared/log.js b/tests/integration/shared/log.js index f94e1a1..f1d07f7 100644 --- a/tests/integration/shared/log.js +++ b/tests/integration/shared/log.js @@ -12,14 +12,13 @@ 'use strict'; -var logger = require('../../../lib/logger'); - -var helpers = require('../../helpers'); -var harness = helpers.harness(__filename); -var 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) { - var log = logger({ + const log = logger({ log: function(id, msg) { assert.equal(typeof id, 'string', 'id is set `' + id + '`'); assert.equal(msg[0], 'testing 1234'); diff --git a/tests/integration/util/uuid.js b/tests/integration/util/uuid.js index 2969090..0aca172 100644 --- a/tests/integration/util/uuid.js +++ b/tests/integration/util/uuid.js @@ -12,13 +12,13 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var nano = helpers.nano; -var 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) { - var p = nano.uuids(3, function(error, data) { + 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'); @@ -37,7 +37,7 @@ it('should generate three uuids', function(assert) { }); it('should generate one uuid', function(assert) { - var p = nano.uuids(function(error, data) { + 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'); diff --git a/tests/intercept/design/search.js b/tests/intercept/design/search.js index 3456780..f853b48 100644 --- a/tests/intercept/design/search.js +++ b/tests/intercept/design/search.js @@ -12,21 +12,21 @@ 'use strict'; -var helpers = require('../../helpers/integration'); -var harness = helpers.harness(__filename); -var it = harness.it; +const helpers = require('../../helpers/integration'); +const harness = helpers.harness(__filename); +const it = harness.it; -var nano = require('../../../lib/nano.js'); -var fakeRequest = function(r, callback) { +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 -var n = nano({url: 'http://localhost:5984', request: fakeRequest}); -var 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) { - var p = db.info(function(err, data) { + const p = db.info(function(err, data) { assert.equal(err, null); assert.equal(data.method, 'GET'); assert.equal(typeof data.headers, 'object'); @@ -43,7 +43,7 @@ it('should allow custom request object to be supplied', function(assert) { }); it('should encode array counts parameter', function(assert) { - var p = db.search('fake', 'fake', { counts: ['brand','colour'] }, function(err, data) { + 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'); @@ -62,7 +62,7 @@ it('should encode array counts parameter', function(assert) { }); it('should not encode string counts parameter', function(assert) { - var p = db.search('fake', 'fake', + const p = db.search('fake', 'fake', { counts: JSON.stringify(['brand','colour']) }, function(err, data) { assert.equal(err, null); @@ -84,7 +84,7 @@ it('should not encode string counts parameter', function(assert) { }); it('should encode array drilldown parameter', function(assert) { - var p = db.search('fake', 'fake', { drilldown: ['colour','red'] }, function(err, data) { + 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'); @@ -104,7 +104,7 @@ it('should encode array drilldown parameter', function(assert) { }); it('should not encode string drilldown parameter', function(assert) { - var p = db.search('fake', 'fake', + const p = db.search('fake', 'fake', { drilldown: JSON.stringify(['colour','red']) }, function(err, data) { assert.equal(err, null); @@ -126,7 +126,7 @@ it('should not encode string drilldown parameter', function(assert) { }); it('should encode array group_sort parameter', function(assert) { - var p = db.search('fake', 'fake', + const p = db.search('fake', 'fake', { group_sort: ['-foo<number>','bar<string>'] }, function(err, data) { assert.equal(err, null); @@ -148,7 +148,7 @@ it('should encode array group_sort parameter', function(assert) { }); it('should not encode string group_sort parameter', function(assert) { - var p = db.search('fake', 'fake', + const p = db.search('fake', 'fake', { group_sort: JSON.stringify(['-foo<number>','bar<string>']) }, function(err, data) { assert.equal(err, null); @@ -170,7 +170,7 @@ it('should not encode string group_sort parameter', function(assert) { }); it('should encode object ranges parameter', function(assert) { - var p = db.search('fake', 'fake', + const p = db.search('fake', 'fake', { ranges: {'price':'[0 TO 10]'} }, function(err, data) { assert.equal(err, null); @@ -192,7 +192,7 @@ it('should encode object ranges parameter', function(assert) { }); it('should not encode string ranges parameter', function(assert) { - var p = db.search('fake', 'fake', + const p = db.search('fake', 'fake', { ranges: JSON.stringify({'price':'[0 TO 10]'}) }, function(err, data) { assert.equal(err, null); @@ -214,7 +214,7 @@ it('should not encode string ranges parameter', function(assert) { }); it('should encode array sort parameter', function(assert) { - var p = db.search('fake', 'fake', + const p = db.search('fake', 'fake', { sort: ['-foo<number>','bar<string>'] }, function(err, data) { assert.equal(err, null); @@ -236,7 +236,7 @@ it('should encode array sort parameter', function(assert) { }); it('should not encode string sort parameter', function(assert) { - var p = db.search('fake', 'fake', + const p = db.search('fake', 'fake', { sort: JSON.stringify(['-foo<number>','bar<string>']) }, function(err, data) { assert.equal(err, null); @@ -258,7 +258,7 @@ it('should not encode string sort parameter', function(assert) { }); it('should encode unencoded sort parameter', function(assert) { - var p = db.search('fake', 'fake', + const p = db.search('fake', 'fake', { sort: '-foo<number>' }, function(err, data) { assert.equal(err, null); @@ -280,7 +280,7 @@ it('should encode unencoded sort parameter', function(assert) { }); it('should not encode encoded string sort parameter', function(assert) { - var p = db.search('fake', 'fake', + const p = db.search('fake', 'fake', { sort: JSON.stringify('-foo<number>') }, function(err, data) { assert.equal(err, null); diff --git a/tests/unit/attachment/destroy.js b/tests/unit/attachment/destroy.js index e25a772..084950f 100644 --- a/tests/unit/attachment/destroy.js +++ b/tests/unit/attachment/destroy.js @@ -12,7 +12,7 @@ 'use strict'; -var destroyAttachment = require('../../helpers/unit').unit([ +const destroyAttachment = require('../../helpers/unit').unit([ 'attachment', 'destroy' ]); diff --git a/tests/unit/attachment/get.js b/tests/unit/attachment/get.js index 2e23a25..1972363 100644 --- a/tests/unit/attachment/get.js +++ b/tests/unit/attachment/get.js @@ -12,7 +12,7 @@ 'use strict'; -var getAttachment = require('../../helpers/unit').unit([ +const getAttachment = require('../../helpers/unit').unit([ 'attachment', 'get' ]); diff --git a/tests/unit/attachment/insert.js b/tests/unit/attachment/insert.js index 0416b89..0ed455f 100644 --- a/tests/unit/attachment/insert.js +++ b/tests/unit/attachment/insert.js @@ -12,10 +12,10 @@ 'use strict'; -var helpers = require('../../helpers/unit'); -var insertAttachment = helpers.unit(['attachment', 'insert']); +const helpers = require('../../helpers/unit'); +const insertAttachment = helpers.unit(['attachment', 'insert']); -var buffer = new Buffer(helpers.pixel, 'base64'); +const buffer = new Buffer(helpers.pixel, 'base64'); insertAttachment('pixels', 'pixel.bmp', buffer, 'image/bmp', { body: buffer, diff --git a/tests/unit/database/changes.js b/tests/unit/database/changes.js index 778d0cc..8b017eb 100644 --- a/tests/unit/database/changes.js +++ b/tests/unit/database/changes.js @@ -12,7 +12,7 @@ 'use strict'; -var changesDatabase = require('../../helpers/unit').unit([ +const changesDatabase = require('../../helpers/unit').unit([ 'database', 'changes' ]); diff --git a/tests/unit/database/compact.js b/tests/unit/database/compact.js index ca6711e..0f36ba8 100644 --- a/tests/unit/database/compact.js +++ b/tests/unit/database/compact.js @@ -12,7 +12,7 @@ 'use strict'; -var compactDatabase = require('../../helpers/unit').unit([ +const compactDatabase = require('../../helpers/unit').unit([ 'database', 'compact' ]); diff --git a/tests/unit/database/create.js b/tests/unit/database/create.js index 53b5994..674f702 100644 --- a/tests/unit/database/create.js +++ b/tests/unit/database/create.js @@ -12,7 +12,7 @@ 'use strict'; -var createDatabase = require('../../helpers/unit').unit([ +const createDatabase = require('../../helpers/unit').unit([ 'database', 'create' ]); diff --git a/tests/unit/database/destroy.js b/tests/unit/database/destroy.js index b2c4f0e..6378d8b 100644 --- a/tests/unit/database/destroy.js +++ b/tests/unit/database/destroy.js @@ -12,7 +12,7 @@ 'use strict'; -var destroyDatabase = require('../../helpers/unit').unit([ +const destroyDatabase = require('../../helpers/unit').unit([ 'database', 'destroy' ]); diff --git a/tests/unit/database/follow.js b/tests/unit/database/follow.js index 99bab1b..92d5cb1 100644 --- a/tests/unit/database/follow.js +++ b/tests/unit/database/follow.js @@ -12,7 +12,7 @@ 'use strict'; -var followDatabase = require('../../helpers/unit').unit([ +const followDatabase = require('../../helpers/unit').unit([ 'database', 'follow' ]); diff --git a/tests/unit/database/get.js b/tests/unit/database/get.js index 2cdd2cc..3cbae19 100644 --- a/tests/unit/database/get.js +++ b/tests/unit/database/get.js @@ -12,7 +12,7 @@ 'use strict'; -var getDatabase = require('../../helpers/unit').unit([ +const getDatabase = require('../../helpers/unit').unit([ 'database', 'get' ]); diff --git a/tests/unit/database/list.js b/tests/unit/database/list.js index 1367d8a..2d4e928 100644 --- a/tests/unit/database/list.js +++ b/tests/unit/database/list.js @@ -12,7 +12,7 @@ 'use strict'; -var listDatabases = require('../../helpers/unit').unit([ +const listDatabases = require('../../helpers/unit').unit([ 'database', 'list' ]); diff --git a/tests/unit/database/replicate.js b/tests/unit/database/replicate.js index 21120f3..a55c08d 100644 --- a/tests/unit/database/replicate.js +++ b/tests/unit/database/replicate.js @@ -12,7 +12,7 @@ 'use strict'; -var replicateDatabase = require('../../helpers/unit').unit([ +const replicateDatabase = require('../../helpers/unit').unit([ 'database', 'replicate' ]); diff --git a/tests/unit/database/replicator.js b/tests/unit/database/replicator.js index dd4abbe..126df42 100644 --- a/tests/unit/database/replicator.js +++ b/tests/unit/database/replicator.js @@ -12,7 +12,7 @@ 'use strict'; -var replicator = require('../../helpers/unit').unit([ +const replicator = require('../../helpers/unit').unit([ 'database', 'replicator' ]); diff --git a/tests/unit/database/updates.js b/tests/unit/database/updates.js index 31f27ce..6690018 100644 --- a/tests/unit/database/updates.js +++ b/tests/unit/database/updates.js @@ -12,7 +12,7 @@ 'use strict'; -var updatesDatabase = require('../../helpers/unit').unit([ +const updatesDatabase = require('../../helpers/unit').unit([ 'database', 'updates' ]); diff --git a/tests/unit/design/atomic.js b/tests/unit/design/atomic.js index 04b1bfc..a52d98e 100644 --- a/tests/unit/design/atomic.js +++ b/tests/unit/design/atomic.js @@ -12,7 +12,7 @@ 'use strict'; -var atomicDesign = require('../../helpers/unit').unit([ +const atomicDesign = require('../../helpers/unit').unit([ 'view', 'atomic' ]); diff --git a/tests/unit/design/compact.js b/tests/unit/design/compact.js index dafc8f0..1239193 100644 --- a/tests/unit/design/compact.js +++ b/tests/unit/design/compact.js @@ -12,7 +12,7 @@ 'use strict'; -var compactDesign = require('../../helpers/unit').unit([ +const compactDesign = require('../../helpers/unit').unit([ 'view', 'compact' ]); diff --git a/tests/unit/design/find.js b/tests/unit/design/find.js index 41a4026..b8c6767 100644 --- a/tests/unit/design/find.js +++ b/tests/unit/design/find.js @@ -11,7 +11,7 @@ // the License. 'use strict'; -var findDesign = require('../../helpers/unit').unit([ +const findDesign = require('../../helpers/unit').unit([ 'find', 'find' ]); diff --git a/tests/unit/design/list.js b/tests/unit/design/list.js index d2bd430..e37fdfa 100644 --- a/tests/unit/design/list.js +++ b/tests/unit/design/list.js @@ -12,7 +12,7 @@ 'use strict'; -var listDesign = require('../../helpers/unit').unit([ +const listDesign = require('../../helpers/unit').unit([ 'view', 'viewWithList' ]); diff --git a/tests/unit/design/search.js b/tests/unit/design/search.js index 4fee871..a7b6336 100644 --- a/tests/unit/design/search.js +++ b/tests/unit/design/search.js @@ -12,7 +12,7 @@ 'use strict'; -var searchDesign = require('../../helpers/unit').unit([ +const searchDesign = require('../../helpers/unit').unit([ 'view', 'search' ]); diff --git a/tests/unit/design/show.js b/tests/unit/design/show.js index 1a98ff5..9b99dee 100644 --- a/tests/unit/design/show.js +++ b/tests/unit/design/show.js @@ -12,7 +12,7 @@ 'use strict'; -var showDesign = require('../../helpers/unit').unit([ +const showDesign = require('../../helpers/unit').unit([ 'view', 'show' ]); diff --git a/tests/unit/design/spatial.js b/tests/unit/design/spatial.js index b3aa400..d3ce830 100644 --- a/tests/unit/design/spatial.js +++ b/tests/unit/design/spatial.js @@ -12,7 +12,7 @@ 'use strict'; -var geoDesign = require('../../helpers/unit').unit([ +const geoDesign = require('../../helpers/unit').unit([ 'view', 'spatial' ]); diff --git a/tests/unit/design/view.js b/tests/unit/design/view.js index df441e3..a9c8c14 100644 --- a/tests/unit/design/view.js +++ b/tests/unit/design/view.js @@ -12,7 +12,7 @@ 'use strict'; -var viewDesign = require('../../helpers/unit').unit([ +const viewDesign = require('../../helpers/unit').unit([ 'view', 'view' ]); diff --git a/tests/unit/document/bulk.js b/tests/unit/document/bulk.js index 20db29f..9f874b7 100644 --- a/tests/unit/document/bulk.js +++ b/tests/unit/document/bulk.js @@ -12,7 +12,7 @@ 'use strict'; -var bulkDocument = require('../../helpers/unit').unit([ +const bulkDocument = require('../../helpers/unit').unit([ 'document', 'bulk' ]); diff --git a/tests/unit/document/copy.js b/tests/unit/document/copy.js index 5b34c8b..3722d13 100644 --- a/tests/unit/document/copy.js +++ b/tests/unit/document/copy.js @@ -12,12 +12,12 @@ 'use strict'; -var copyDocument = require('../../helpers/unit').unit([ +const copyDocument = require('../../helpers/unit').unit([ 'document', 'copy' ]); -var copyDocumentFail = require('../../helpers/unit').unit([ +const copyDocumentFail = require('../../helpers/unit').unit([ 'document', 'copy' ], new Error('OMG This sucks')); diff --git a/tests/unit/document/get.js b/tests/unit/document/get.js index b0d490e..cccb5bf 100644 --- a/tests/unit/document/get.js +++ b/tests/unit/document/get.js @@ -12,12 +12,12 @@ 'use strict'; -var helpers = require('../../helpers/unit'); -var test = require('tape'); -var 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'); -var cli = helpers.mockClientDb(debug); -var 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) { diff --git a/tests/unit/multipart/get.js b/tests/unit/multipart/get.js index 23755ea..ea9b6a7 100644 --- a/tests/unit/multipart/get.js +++ b/tests/unit/multipart/get.js @@ -12,7 +12,7 @@ 'use strict'; -var getMultipart = require('../../helpers/unit').unit([ +const getMultipart = require('../../helpers/unit').unit([ 'multipart', 'get' ]); diff --git a/tests/unit/multipart/insert.js b/tests/unit/multipart/insert.js index 642c88d..a3cccb4 100644 --- a/tests/unit/multipart/insert.js +++ b/tests/unit/multipart/insert.js @@ -12,7 +12,7 @@ 'use strict'; -var insertMultipart = require('../../helpers/unit').unit([ +const insertMultipart = require('../../helpers/unit').unit([ 'multipart', 'insert' ]); diff --git a/tests/unit/shared/error.js b/tests/unit/shared/error.js index 8809abd..ff1dc8c 100644 --- a/tests/unit/shared/error.js +++ b/tests/unit/shared/error.js @@ -12,17 +12,17 @@ 'use strict'; -var helpers = require('../../helpers/unit'); -var test = require('tape'); -var 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'); -var cli = helpers.mockClientFail(debug); -var cli2 = helpers.mockClientUnparsedError(debug); -var cli3 = helpers.mockClientUnparsedError(debug, JSON.stringify({ +const cli = helpers.mockClientFail(debug); +const cli2 = helpers.mockClientUnparsedError(debug); +const cli3 = helpers.mockClientUnparsedError(debug, JSON.stringify({ error: 'not a reason' })); -var cli4 = helpers.mockClientUnparsedError(debug, JSON.stringify({ +const cli4 = helpers.mockClientUnparsedError(debug, JSON.stringify({ stack: new Error('foo').stack })); @@ -49,7 +49,7 @@ test('should be capable of using `error`', function(assert) { test('should remove cloudant stacktraces', function(assert) { cli4.relax({}, function(err) { - var msg = err.stack.split('\n')[0]; + 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 bf06bce..78bc537 100644 --- a/tests/unit/shared/follow-updates.js +++ b/tests/unit/shared/follow-updates.js @@ -12,7 +12,7 @@ 'use strict'; -var followUpdates = require('../../helpers/unit').unit([ +const followUpdates = require('../../helpers/unit').unit([ 'server', 'followUpdates' ]); diff --git a/tests/unit/shared/jar.js b/tests/unit/shared/jar.js index c46d62c..aa901bf 100644 --- a/tests/unit/shared/jar.js +++ b/tests/unit/shared/jar.js @@ -12,11 +12,11 @@ 'use strict'; -var helpers = require('../../helpers/unit'); -var test = require('tape'); -var 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'); -var 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');
