Skip to content

Commit b8a2985

Browse files
authored
tests: remove commonUtils.Promise (#8776)
* simplifies code * avoids including the `pouchdb-for-coverage` module unless it's explicitly required elsewhere - e.g. halves the LoC of `performance-bundle.js`
1 parent d9ee8e0 commit b8a2985

30 files changed

+152
-188
lines changed

packages/node_modules/pouchdb-for-coverage/src/utils.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export default {
5252
parseUri,
5353
uuid,
5454
rev,
55-
Promise,
5655
atob,
5756
btoa,
5857
binaryStringToBlobOrBuffer,

tests/common-utils.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ commonUtils.loadPouchDBForBrowser = function (plugins) {
124124

125125
// Thanks to http://engineeredweb.com/blog/simple-async-javascript-loader/
126126
commonUtils.asyncLoadScript = function (url) {
127-
return new commonUtils.Promise(function (resolve, reject) {
127+
return new Promise(function (resolve, reject) {
128128
// Create a new script and setup the basics.
129129
var script = document.createElement("script");
130130

@@ -174,8 +174,4 @@ commonUtils.createDocId = function (i) {
174174
return 'doc_' + i.toString().padStart(10, '0');
175175
};
176176

177-
var PouchForCoverage = require('../packages/node_modules/pouchdb-for-coverage');
178-
var pouchUtils = PouchForCoverage.utils;
179-
commonUtils.Promise = pouchUtils.Promise;
180-
181177
module.exports = commonUtils;

tests/find/test-suite-1/test.basic.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use strict';
22

33
describe('test.basic.js', function () {
4-
var Promise = testUtils.Promise;
5-
64
it('should create an index', function () {
75
var db = context.db;
86
var index = {

tests/find/test-suite-1/test.callbacks.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use strict';
22

33
describe('test.callbacks.js', function () {
4-
var Promise = testUtils.Promise;
5-
64
it('should create an index', function () {
75
var db = context.db;
86
var index = {

tests/find/test-suite-1/test.explain.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use strict';
22

33
describe('test.explain.js', function () {
4-
var Promise = testUtils.Promise;
5-
64
beforeEach(function () {
75
var db = context.db;
86
return db.bulkDocs([

tests/find/test-suite-2/test.kitchen-sink-2.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ describe('pouchdb-find: test.kitchen-sink-2.js', function () {
1818
}
1919

2020
var dbName = testUtils.adapterUrl(testUtils.adapterType(), 'testdb');
21-
var Promise = testUtils.Promise;
2221

2322
this.timeout(100000);
2423

tests/find/test-suite-2/test.kitchen-sink.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/fuzzy/test.fuzzy.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,9 @@ function arrayRandom(arr) {
102102

103103
describe('chaos-monkey', function () {
104104

105-
var Promise;
106105
var a, b;
107106

108107
beforeEach(function (done) {
109-
Promise = testUtils.Promise;
110108
var aname = testUtils.adapterUrl('local', 'testdb');
111109
var bname = testUtils.adapterUrl('http', 'test_repl_remote');
112110
testUtils.cleanup([aname, bname], function () {

tests/integration/browser.migration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('migration', function () {
5151
return Promise.all(scenarios.map(function ({ scenario }) {
5252
var match = scenario.match(/PouchDB v([.\d]+)/);
5353
if (!match) {
54-
return testUtils.Promise.resolve();
54+
return Promise.resolve();
5555
}
5656

5757
const loader = testUtils.asyncLoadScript('deps/pouchdb-' + match[1] + '-postfixed.js');
@@ -923,7 +923,7 @@ describe('migration', function () {
923923

924924
var oldPouch = new dbs.first.pouch(
925925
dbs.first.local, dbs.first.localOpts);
926-
var chain = testUtils.Promise.resolve();
926+
var chain = Promise.resolve();
927927
tree.forEach(function (docs) {
928928
chain = chain.then(function () {
929929
return oldPouch.bulkDocs(docs, {new_edits: false});

tests/integration/browser.worker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe.skip('browser.worker.js', function () {
9292
}
9393

9494
// both threads agree the count is 0
95-
return testUtils.Promise.all([
95+
return Promise.all([
9696
db.allDocs().then(function (res) {
9797
res.total_rows.should.equal(0);
9898
}),
@@ -104,7 +104,7 @@ describe.skip('browser.worker.js', function () {
104104
return db.post({});
105105
}).then(function () {
106106
// both threads agree the count is 1
107-
return testUtils.Promise.all([
107+
return Promise.all([
108108
db.allDocs().then(function (res) {
109109
res.total_rows.should.equal(1);
110110
}),

0 commit comments

Comments
 (0)