From 7e85271d718f3def01aaed68f4931fbc06dc6adb Mon Sep 17 00:00:00 2001 From: Jun Matsushita Date: Thu, 25 May 2017 18:50:42 +0200 Subject: [PATCH 1/2] Bunch of tests reproducing pouchdb/pouchdb-server#226 and pouchdb/pouchdb-server#227. --- tests/express-pouchdb/test.js | 845 ++++++++++++++++++++++++++++++---- 1 file changed, 764 insertions(+), 81 deletions(-) diff --git a/tests/express-pouchdb/test.js b/tests/express-pouchdb/test.js index f018b040..a5ee9f16 100644 --- a/tests/express-pouchdb/test.js +++ b/tests/express-pouchdb/test.js @@ -1,72 +1,92 @@ -"use strict"; +'use strict'; /*globals before */ var buildApp = require('../../packages/node_modules/express-pouchdb'), - PouchDB = require('pouchdb'), - express = require('express'), - request = require('supertest'), - Promise = require('bluebird'), - fse = Promise.promisifyAll(require('fs-extra')), - memdown = require('memdown'), - assert = require('assert'); + PouchDB = require('pouchdb'), + express = require('express'), + request = require('supertest'), + Promise = require('bluebird'), + fse = Promise.promisifyAll(require('fs-extra')), + memdown = require('memdown'), + assert = require('assert'); var TEST_DATA = __dirname + '/testdata/'; var LARGE_TIMEOUT = 5000; var expressApp, expressApp2; -var customApp = buildApp(PouchDB.defaults({ - db: memdown, - prefix: 'c' -}), { - mode: 'custom', - overrideMode: { - include: ['routes/404'] +var customApp = buildApp( + PouchDB.defaults({ + db: memdown, + prefix: 'c' + }), + { + mode: 'custom', + overrideMode: { + include: ['routes/404'] + } } -}); +); -var coreApp = buildApp(PouchDB.defaults({ - db: memdown, - prefix: 'd' -}), { - mode: 'minimumForPouchDB', - overrideMode: { - include: ['routes/fauxton'] +var coreApp = buildApp( + PouchDB.defaults({ + db: memdown, + prefix: 'd' + }), + { + mode: 'minimumForPouchDB', + overrideMode: { + include: ['routes/fauxton'] + } } -}); +); -var inMemoryConfigApp = buildApp(PouchDB.defaults({ - db: memdown, - prefix: 'e' -}), { - inMemoryConfig: true -}); +var inMemoryConfigApp = buildApp( + PouchDB.defaults({ + db: memdown, + prefix: 'e' + }), + { + inMemoryConfig: true + } +); before(function (done) { this.timeout(LARGE_TIMEOUT); - cleanUp().then(function () { - return fse.mkdirsAsync(TEST_DATA + 'a'); - }).then(function () { - return fse.mkdirsAsync(TEST_DATA + 'b'); - }).then(function () { - expressApp = buildApp(PouchDB.defaults({ - prefix: TEST_DATA + 'a/' - })); - expressApp2 = buildApp(PouchDB.defaults({ - prefix: TEST_DATA + 'b/', - }), { - configPath: TEST_DATA + 'b-config.json', - logPath: TEST_DATA + 'b-log.txt' - }); - done(); - }).catch(done); + cleanUp() + .then(function () { + return fse.mkdirsAsync(TEST_DATA + 'a'); + }) + .then(function () { + return fse.mkdirsAsync(TEST_DATA + 'b'); + }) + .then(function () { + expressApp = buildApp( + PouchDB.defaults({ + prefix: TEST_DATA + 'a/' + }) + ); + expressApp2 = buildApp( + PouchDB.defaults({ + prefix: TEST_DATA + 'b/' + }), + { + configPath: TEST_DATA + 'b-config.json', + logPath: TEST_DATA + 'b-log.txt' + } + ); + done(); + }) + .catch(done); }); after(function (done) { - cleanUp().then(function () { - done(); - }).catch(done); + cleanUp() + .then(function () { + done(); + }) + .catch(done); }); function cleanUp() { @@ -81,7 +101,7 @@ describe('config', function () { it('should not create empty config file', function (done) { fse.exists('./config.json', function (exists) { if (exists) { - return done(new Error("config.json should not have been created!")); + return done(new Error('config.json should not have been created!')); } done(); }); @@ -91,7 +111,7 @@ describe('config', function () { inMemoryConfigApp.couchConfig.set('demo', 'demo', true, function () { fse.exists('./config.json', function (exists) { if (exists) { - return done(new Error("config.json exists!")); + return done(new Error('config.json exists!')); } done(); }); @@ -136,23 +156,19 @@ describe('config', function () { .expect(200) .expect(function (res) { var a = JSON.parse(res.text).a; - if (!(typeof a === "object" && a.b === "c")) { - return "Default not shown"; + if (!(typeof a === 'object' && a.b === 'c')) { + return 'Default not shown'; } }) .end(done); }); it('should support externally getting a config value', function (done) { - request(expressApp) - .put('/_config/test/a') - .send('"b"') - .expect(200) - .end(function () { - if (expressApp.couchConfig.get('test', 'a') !== 'b') { - return done(new Error("Can't read setting that's just been set")); - } - done(); - }); + request(expressApp).put('/_config/test/a').send('"b"').expect(200).end(function () { + if (expressApp.couchConfig.get('test', 'a') !== 'b') { + return done(new Error("Can't read setting that's just been set")); + } + done(); + }); }); it('should support external listeners to a config change', function (done) { var changed = false; @@ -185,13 +201,10 @@ prefixes.forEach(function (prefix) { it('GET / should respond with adapters', function () { var app = express(); app.use(prefix, expressApp); - return request(app) - .get(prefix) - .expect(200) - .then(function (res) { - var json = JSON.parse(res.text); - assert.deepEqual(json['pouchdb-adapters'], ['leveldb']); - }); + return request(app).get(prefix).expect(200).then(function (res) { + var json = JSON.parse(res.text); + assert.deepEqual(json['pouchdb-adapters'], ['leveldb']); + }); }); }); }); @@ -215,7 +228,7 @@ describe('modes', function () { .expect(404) .expect(function (res) { if (JSON.parse(res.text).error !== 'not_found') { - return "Wrong response body"; + return 'Wrong response body'; } }) .end(done); @@ -225,38 +238,708 @@ describe('modes', function () { }); it('should throw an error when given an invalid mode', function () { assertException(function () { - buildApp(PouchDB, {mode: 'unexisting-mode'}); + buildApp(PouchDB, { mode: 'unexisting-mode' }); }, /Unknown mode: unexisting-mode/); }); it('should throw an error when a not included part is excluded', function () { assertException(function () { - buildApp(PouchDB, {overrideMode: {exclude: ['abc']}}); + buildApp(PouchDB, { overrideMode: { exclude: ['abc'] } }); }, /exclude contains the not included part 'abc'/); }); it('should throw an error when an unknown part is included', function () { assertException(function () { - buildApp(PouchDB, {overrideMode: {include: ['abc']}}); + buildApp(PouchDB, { overrideMode: { include: ['abc'] } }); }, /include contains the unknown part 'abc'/); }); }); describe('redirects', function () { it('GET /_utils should redirect to /_utils/', function (done) { - request(coreApp) - .get('/_utils') - .expect(301) - .end(done); + request(coreApp).get('/_utils').expect(301).end(done); }); it('GET /_utils/ should return fauxton', function (done) { request(coreApp) .get('/_utils/') .expect(200) .expect(function (res) { - if (!/PouchDB Server<\/title>/.test(res.text)) { + assert.equal( + true, + /<title>PouchDB Server<\/title>/.test(res.text), + "No '<title>PouchDB Server' in response" + ); + }) + .end(done); + }); +}); + +var created, destroyed; + +var destroyedListener = function (name) { + destroyed.push(name); + // console.log('destroyed: ' + destroyed.length, name); +}; + +var createdListener = function (name) { + created.push(name); + // console.log('created: ' + created.length, name); +}; + +describe('own pouch', function () { + this.timeout(LARGE_TIMEOUT); + var write, log, error, warn, err = '', out = ''; + + // restore process.stdout.write() and console.log() to their previous glory + var cleanup = function () { + process.nextTick(function () { + // console.log('cleanup!', out); + // process.stdout.write = write; + // console.log = log; + console.error = error; + // console.warn = warn; + out = ''; + }); + }; + + beforeEach(function () { + // store these functions to restore later because we are messing with them + // write = process.stdout.write; + // log = console.log; + error = console.error; + // warn = console.warn; + + // our stub will concatenate any output to a string + //process.stdout.write = console.log = + //console.warn = + console.error = function (s) { + out += s; + }; + + // do the same for console.error + // process.stderr.write = console.error = function (s) { + // err += s; + // }; + }); + + // restore after each test + afterEach(cleanup); + + it('should wrap own pouch', function (done) { + var app = express(); + app.use( + '/', + buildApp( + PouchDB.defaults({ + db: memdown + }) + ) + ); + + var myPouch = new PouchDB('foo'); + + request(app) + .get('/foo') + .expect(200) + .expect(function (res) { + assert.equal( + true, + /\"db_name\":\"foo\"/.test(res.text), + 'No \'"db_name": "foo"\' in response' + ); + // if (!/PouchDB Server<\/title>/.test(res.text)) { + // return "No 'PouchDB Server' in response"; + // } + }) + .end(done); + }); + + it('should wrap own pouch without emitter leak', function (done) { + var app = express(); + app.use( + '/', + buildApp( + PouchDB.defaults({ + db: memdown + }) + ) + ); + + var myPouch = new PouchDB('foo'); + + request(app) + .get('/foo') + .expect(200) + .expect(function (res) { + assert.equal( + true, + /\"db_name\":\"foo\"/.test(res.text), + 'No \'"db_name": "foo"\' in response' + ); + // console.log(res.text); + if (!/PouchDB Server<\/title>/.test(res.text)) { return "No 'PouchDB Server' in response"; } }) - .end(done); + .then(function () { + assert.equal(false, /EventEmitter memory leak/.test(out), 'Got emitter leak error: ' + out); + done(); + }) + .catch(done); + }); + + it('should wrap own pouch without conflict update on stdout', function (done) { + var app = express(); + app.use( + '/', + buildApp( + PouchDB.defaults({ + db: memdown + }) + ) + ); + + var myPouch = new PouchDB('foo'); + + request(app) + .get('/foo') + .expect(200) + .expect(function (res) { + assert.equal( + true, + /\"db_name\":\"foo\"/.test(res.text), + 'No \'"db_name": "foo"\' in response' + ); + // console.log(res.text); + if (!/PouchDB Server<\/title>/.test(res.text)) { + return "No 'PouchDB Server' in response"; + } + }) + .then(function () { + assert.equal(false, /conflict/.test(out), 'Got conflict update error: ' + out); + done(); + }) + .catch(done); + }); + + it('should wrap in memory own pouch without conflict update on stdout', function (done) { + var app = express(); + var InMemPouchDB = PouchDB.defaults({ + db: memdown + }); + + app.use('/', buildApp(InMemPouchDB)); + + var myPouch = new InMemPouchDB('foo'); + + request(app) + .get('/foo') + .expect(200) + .expect(function (res) { + assert.equal( + true, + /\"db_name\":\"foo\"/.test(res.text), + 'No \'"db_name": "foo"\' in response' + ); + // console.log(res.text); + if (!/PouchDB Server<\/title>/.test(res.text)) { + return "No 'PouchDB Server' in response"; + } + }) + .then(function () { + InMemPouchDB.allDbs(function (err, dbs) { + console.log('all.dbs', dbs); + }); + }) + .then(function () { + assert.equal(false, /conflict/.test(out), 'Got conflict update error: ' + out); + done(); + }) + .catch(done); + }); + + it('should wrap own pouch and emit the expected events given the daemon manager', function (done) { + var app = express(); + app.use( + '/', + buildApp( + PouchDB.defaults({ + db: memdown + }) + ) + ); + + var myPouch = new PouchDB('foo'); + + created = []; + PouchDB.on('created', createdListener); + + destroyed = []; + PouchDB.on('destroyed', destroyedListener); + + request(app) + .get('/foo') + .expect(200) + .expect(function (res) { + assert.equal( + true, + /\"db_name\":\"foo\"/.test(res.text), + 'No \'"db_name": "foo"\' in response' + ); + // console.log(res.text); + if (!/PouchDB Server<\/title>/.test(res.text)) { + return "No 'PouchDB Server' in response"; + } + }) + .then(function () { + assert.equal( + true, + created.includes('foo', '_replicator', '_users', 'pouch__all_dbs__'), + 'Missing created databases.' + ); + assert.equal( + 5, + created.length, + 'Number of expected created databases is wrong. Databases created are: ' + created + ); + }) + .then(function () { + assert.equal(false, /conflict/.test(out), 'Got conflict update error: ' + out); + PouchDB.removeListener('created', createdListener); + PouchDB.removeListener('destroyed', destroyedListener); + done(); + }) + .catch(function () { + PouchDB.removeListener('created', createdListener); + PouchDB.removeListener('destroyed', destroyedListener); + done(); + }); + }); + + it('should wrap own in memory pouch and emit the expected events given the daemon manager', function ( + done + ) { + var app = express(); + var InMemPouchDB = PouchDB.defaults({ + db: memdown + }); + + app.use('/', buildApp(InMemPouchDB)); + + var myPouch = new InMemPouchDB('foo'); + + created = []; + InMemPouchDB.on('created', createdListener); + + destroyed = []; + InMemPouchDB.on('destroyed', destroyedListener); + + request(app) + .get('/foo') + .expect(200) + .expect(function (res) { + assert.equal( + true, + /\"db_name\":\"foo\"/.test(res.text), + 'No \'"db_name": "foo"\' in response' + ); + // console.log(res.text); + if (!/PouchDB Server<\/title>/.test(res.text)) { + return "No 'PouchDB Server' in response"; + } + }) + .then(function () { + assert.equal( + true, + created.includes('foo', '_replicator', '_users', 'pouch__all_dbs__'), + 'Missing created databases.' + ); + assert.equal( + 5, + created.length, + 'Number of expected created databases is wrong. Databases created are: ' + created + ); + }) + .then(function () { + InMemPouchDB.allDbs(function (err, dbs) { + console.log('all.dbs', dbs); + }); + }) + .then(function () { + assert.equal(false, /conflict/.test(out), 'Got conflict update error: ' + out); + InMemPouchDB.removeListener('created', createdListener); + InMemPouchDB.removeListener('destroyed', destroyedListener); + done(); + }) + .catch(function () { + InMemPouchDB.removeListener('created', createdListener); + InMemPouchDB.removeListener('destroyed', destroyedListener); + done(); + }); + }); + + it('should wrap own pouch a second time and emit the expected events given the deamon manager', function ( + done + ) { + var app = express(); + app.use( + '/', + buildApp( + PouchDB.defaults({ + db: memdown + }) + ) + ); + + var myPouch = new PouchDB('foo'); + + created = []; + PouchDB.on('created', createdListener); + + destroyed = []; + PouchDB.on('destroyed', destroyedListener); + + request(app) + .get('/foo') + .expect(200) + .expect(function (res) { + assert.equal( + true, + /\"db_name\":\"foo\"/.test(res.text), + 'No \'"db_name": "foo"\' in response' + ); + // console.log(res.text); + if (!/PouchDB Server<\/title>/.test(res.text)) { + return "No 'PouchDB Server' in response"; + } + }) + .expect(function () { + assert.equal( + true, + created.includes('foo', '_replicator', '_users', 'pouch__all_dbs__'), + 'Missing created databases.' + ); + assert.equal( + 5, + created.length, + 'Number of expected created databases is wrong. Databases created are: ' + created + ); + }) + .then(function () { + PouchDB.removeListener('created', createdListener); + PouchDB.removeListener('destroyed', destroyedListener); + assert.equal(false, /conflict/.test(out), 'Got conflict update error: ' + out); + done(); + }) + .catch(function (err) { + PouchDB.removeListener('created', createdListener); + PouchDB.removeListener('destroyed', destroyedListener); + done(err); + }); + }); + + it('should wrap multiple own pouch and not emit a conflict update on stdout', function (done) { + var app = express(); + app.use( + '/', + buildApp( + PouchDB.defaults({ + db: memdown + }) + ) + ); + + var myPouch = new PouchDB('foo'); + var myPouch2 = new PouchDB('bar'); + + created = []; + PouchDB.on('created', createdListener); + + destroyed = []; + PouchDB.on('destroyed', destroyedListener); + + request(app) + .get('/foo') + .expect(200) + .expect(function (res) { + assert.equal( + true, + /\"db_name\":\"foo\"/.test(res.text), + 'No \'"db_name": "foo"\' in response' + ); + if (!/PouchDB Server<\/title>/.test(res.text)) { + return "No 'PouchDB Server' in response"; + } + }) + .then(function () { + PouchDB.removeListener('created', createdListener); + PouchDB.removeListener('destroyed', destroyedListener); + assert.equal(false, /conflict/.test(out), 'Got conflict update error: ' + out); + done(); + }) + .catch(function (err) { + PouchDB.removeListener('created', createdListener); + PouchDB.removeListener('destroyed', destroyedListener); + done(err); + }); + }); + + it('should wrap multiple own pouch and emit the expected events given the deamon manager', function ( + done + ) { + var app = express(); + app.use( + '/', + buildApp( + PouchDB.defaults({ + db: memdown + }) + ) + ); + + var myPouch = new PouchDB('foo', { + db: memdown + }); + + var myPouch2 = new PouchDB('bar', { + db: memdown + }); + + created = []; + PouchDB.on('created', createdListener); + + destroyed = []; + PouchDB.on('destroyed', destroyedListener); + + request(app) + .get('/foo') + .expect(200) + .expect(function (res) { + assert.equal( + true, + /\"db_name\":\"foo\"/.test(res.text), + 'No \'"db_name": "foo"\' in response' + ); + if (!/PouchDB Server<\/title>/.test(res.text)) { + return "No 'PouchDB Server' in response"; + } + }) + .expect(function () { + assert.equal(true, created.includes('foo'), 'Missing created databases.'); + assert.equal( + 6, + created.length, + 'Number of expected created databases is wrong. Databases created are: ' + created + ); + }) + .then(function () { + PouchDB.removeListener('created', createdListener); + PouchDB.removeListener('destroyed', destroyedListener); + done(); + }) + .catch(function (err) { + PouchDB.removeListener('created', createdListener); + PouchDB.removeListener('destroyed', destroyedListener); + done(err); + }); + }); + + it('should wrap multiple inmem own pouch and emit the expected events given the deamon manager', function ( + done + ) { + var app = express(); + var InMemPouchDB = PouchDB.defaults({ + db: memdown + }); + app.use('/', buildApp(InMemPouchDB)); + + var myPouch = new InMemPouchDB('foo'); + var myPouch2 = new InMemPouchDB('bar'); + + created = []; + InMemPouchDB.on('created', createdListener); + + destroyed = []; + InMemPouchDB.on('destroyed', destroyedListener); + + request(app) + .get('/foo') + .expect(200) + .expect(function (res) { + assert.equal( + true, + /\"db_name\":\"foo\"/.test(res.text), + 'No \'"db_name": "foo"\' in response' + ); + if (!/PouchDB Server<\/title>/.test(res.text)) { + return "No 'PouchDB Server' in response"; + } + }) + .expect(function () { + assert.equal(true, created.includes('foo'), 'Missing created databases.'); + assert.equal( + 6, + created.length, + 'Number of expected created databases is wrong. Databases created are: ' + created + ); + }) + .then(function () { + InMemPouchDB.removeListener('created', createdListener); + InMemPouchDB.removeListener('destroyed', destroyedListener); + done(); + }) + .then(function () { + InMemPouchDB.allDbs(function (err, dbs) { + console.log('all.dbs', dbs); + }); + }) + .catch(function (err) { + InMemPouchDB.removeListener('created', createdListener); + InMemPouchDB.removeListener('destroyed', destroyedListener); + done(err); + }); + }); + + it('should wrap multiple own pouch, tear them down and emit the expected events given the deamon manager', function ( + done + ) { + var app = express(); + app.use( + '/', + buildApp( + PouchDB.defaults({ + db: memdown + }) + ) + ); + + var myPouch = new PouchDB('foo'); + var myPouch2 = new PouchDB('bar'); + + created = []; + PouchDB.on('created', createdListener); + + destroyed = []; + PouchDB.on('destroyed', destroyedListener); + + request(app) + .get('/foo') + .expect(200) + .expect(function (res) { + assert.equal( + true, + /\"db_name\":\"foo\"/.test(res.text), + 'No \'"db_name": "foo"\' in response' + ); + // console.log(res.text); + if (!/PouchDB Server<\/title>/.test(res.text)) { + return "No 'PouchDB Server' in response"; + } + }) + .expect(function () { + assert.equal( + true, + created.includes('foo', 'bar', '_replicator', '_users', 'pouch__all_dbs__'), + 'Missing created databases.' + ); + assert.equal( + 6, + created.length, + 'Number of expected created databases is wrong. Databases created are: ' + created + ); + }) + .then(function () { + myPouch.destroy(); + myPouch2.destroy(); + return Promise.delay(100); + }) + .then(function () { + assert.equal( + 2, + destroyed.length, + 'Number of expected destroyed databases is wrong. Databases destroyed are: ' + destroyed + ); + PouchDB.removeListener('created', createdListener); + PouchDB.removeListener('destroyed', destroyedListener); + done(); + }) + .catch(function (err) { + PouchDB.removeListener('created', createdListener); + PouchDB.removeListener('destroyed', destroyedListener); + done(err); + }); + }); + + it('should wrap multiple own pouch, tear them down and recreate with the expected outcome', function ( + done + ) { + var app = express(); + var InMemPouchDb = PouchDB.defaults({ + db: memdown + }); + app.use('/', buildApp(InMemPouchDb)); + + var myPouch = new PouchDB('foo'); + var myPouch2 = new PouchDB('bar'); + var newPouch; + + created = []; + InMemPouchDb.on('created', createdListener); + + destroyed = []; + InMemPouchDb.on('destroyed', destroyedListener); + + request(app) + .get('/foo') + .expect(200) + .expect(function (res) { + assert.equal( + true, + /\"db_name\":\"foo\"/.test(res.text), + 'No \'"db_name": "foo"\' in response' + ); + // console.log(res.text); + if (!/PouchDB Server<\/title>/.test(res.text)) { + return "No 'PouchDB Server' in response"; + } + }) + .expect(function () { + assert.equal(true, created.includes('foo'), 'Missing created databases.'); + assert.equal(true, created.includes('bar'), 'Missing created databases.'); + assert.equal( + 6, + created.length, + 'Number of expected created databases is wrong. Databases created are: ' + created + ); + }) + .then(function () { + myPouch.destroy(); + myPouch2.destroy(); + return Promise.delay(100); + }) + .then(function () { + assert.equal( + 2, + destroyed.length, + 'Number of expected destroyed databases is wrong. Databases destroyed are: ' + destroyed + ); + }) + .then(function () { + newPouch = new InMemPouchDb('newfoo'); + return Promise.delay(1000); + }) + .then(function () { + assert.equal(true, created.includes('newfoo'), 'Missing created databases newFoo'); + done(); + }) + .then(function () { + InMemPouchDb.allDbs(function (err, dbs) { + console.log('all.dbs', dbs); + }); + }) + .catch(function (err) { + PouchDB.removeListener('created', createdListener); + PouchDB.removeListener('destroyed', destroyedListener); + done(err); + }); }); }); @@ -270,5 +953,5 @@ function assertException(func, re) { } e = err; } - throw (e || new Error('no error was thrown')); + throw e || new Error('no error was thrown'); } From ee35086f13ae192648b3f0516cd298d9d7365ffb Mon Sep 17 00:00:00 2001 From: Jun Matsushita Date: Thu, 25 May 2017 18:57:25 +0200 Subject: [PATCH 2/2] Fix linting errors --- tests/express-pouchdb/test.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/tests/express-pouchdb/test.js b/tests/express-pouchdb/test.js index a5ee9f16..298544fc 100644 --- a/tests/express-pouchdb/test.js +++ b/tests/express-pouchdb/test.js @@ -286,7 +286,7 @@ var createdListener = function (name) { describe('own pouch', function () { this.timeout(LARGE_TIMEOUT); - var write, log, error, warn, err = '', out = ''; + var error, out = ''; // restore process.stdout.write() and console.log() to their previous glory var cleanup = function () { @@ -334,7 +334,7 @@ describe('own pouch', function () { ) ); - var myPouch = new PouchDB('foo'); + new PouchDB('foo'); request(app) .get('/foo') @@ -363,7 +363,7 @@ describe('own pouch', function () { ) ); - var myPouch = new PouchDB('foo'); + new PouchDB('foo'); request(app) .get('/foo') @@ -397,7 +397,7 @@ describe('own pouch', function () { ) ); - var myPouch = new PouchDB('foo'); + new PouchDB('foo'); request(app) .get('/foo') @@ -428,7 +428,7 @@ describe('own pouch', function () { app.use('/', buildApp(InMemPouchDB)); - var myPouch = new InMemPouchDB('foo'); + new InMemPouchDB('foo'); request(app) .get('/foo') @@ -467,7 +467,7 @@ describe('own pouch', function () { ) ); - var myPouch = new PouchDB('foo'); + new PouchDB('foo'); created = []; PouchDB.on('created', createdListener); @@ -524,7 +524,7 @@ describe('own pouch', function () { app.use('/', buildApp(InMemPouchDB)); - var myPouch = new InMemPouchDB('foo'); + new InMemPouchDB('foo'); created = []; InMemPouchDB.on('created', createdListener); @@ -589,7 +589,7 @@ describe('own pouch', function () { ) ); - var myPouch = new PouchDB('foo'); + new PouchDB('foo'); created = []; PouchDB.on('created', createdListener); @@ -647,8 +647,8 @@ describe('own pouch', function () { ) ); - var myPouch = new PouchDB('foo'); - var myPouch2 = new PouchDB('bar'); + new PouchDB('foo'); + new PouchDB('bar'); created = []; PouchDB.on('created', createdListener); @@ -695,11 +695,11 @@ describe('own pouch', function () { ) ); - var myPouch = new PouchDB('foo', { + new PouchDB('foo', { db: memdown }); - var myPouch2 = new PouchDB('bar', { + new PouchDB('bar', { db: memdown }); @@ -751,8 +751,8 @@ describe('own pouch', function () { }); app.use('/', buildApp(InMemPouchDB)); - var myPouch = new InMemPouchDB('foo'); - var myPouch2 = new InMemPouchDB('bar'); + new InMemPouchDB('foo'); + new InMemPouchDB('bar'); created = []; InMemPouchDB.on('created', createdListener); @@ -879,7 +879,6 @@ describe('own pouch', function () { var myPouch = new PouchDB('foo'); var myPouch2 = new PouchDB('bar'); - var newPouch; created = []; InMemPouchDb.on('created', createdListener); @@ -923,7 +922,7 @@ describe('own pouch', function () { ); }) .then(function () { - newPouch = new InMemPouchDb('newfoo'); + new InMemPouchDb('newfoo'); return Promise.delay(1000); }) .then(function () {