Skip to content

Commit ebf5056

Browse files
committed
fix refactor
1 parent e3014a2 commit ebf5056

2 files changed

Lines changed: 50 additions & 51 deletions

File tree

tests/integration/test.bulk_docs.js

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -334,54 +334,55 @@ adapters.forEach((adapter) => {
334334

335335
it('#2935 new_edits=false with single unauthorized', async () => {
336336

337-
const isCouchDB = await testUtils.isCouchDB();
338-
if (adapter !== 'http' || !isCouchDB) {
339-
return;
340-
}
337+
testUtils.isCouchDB(async (isCouchDB) => {
338+
if (adapter !== 'http' || !isCouchDB) {
339+
return;
340+
}
341341

342-
const ddoc = {
343-
"_id": "_design/validate",
344-
"validate_doc_update": function (newDoc) {
345-
if (newDoc.foo === undefined) {
346-
throw {unauthorized: 'Document must have a foo.'};
347-
}
348-
}.toString()
349-
};
342+
const ddoc = {
343+
"_id": "_design/validate",
344+
"validate_doc_update": function (newDoc) {
345+
if (newDoc.foo === undefined) {
346+
throw {unauthorized: 'Document must have a foo.'};
347+
}
348+
}.toString()
349+
};
350350

351-
const db = new PouchDB(dbs.name);
351+
const db = new PouchDB(dbs.name);
352352

353-
await db.put(ddoc);
354-
const res = await db.bulkDocs({
355-
docs: [
356-
{
357-
'_id': 'doc0',
358-
'_rev': '1-x',
359-
'foo': 'bar',
360-
'_revisions': {
361-
'start': 1,
362-
'ids': ['x']
363-
}
364-
}, {
365-
'_id': 'doc1',
366-
'_rev': '1-x',
367-
'_revisions': {
368-
'start': 1,
369-
'ids': ['x']
353+
await db.put(ddoc);
354+
const res = await db.bulkDocs({
355+
docs: [
356+
{
357+
'_id': 'doc0',
358+
'_rev': '1-x',
359+
'foo': 'bar',
360+
'_revisions': {
361+
'start': 1,
362+
'ids': ['x']
363+
}
364+
}, {
365+
'_id': 'doc1',
366+
'_rev': '1-x',
367+
'_revisions': {
368+
'start': 1,
369+
'ids': ['x']
370+
}
371+
}, {
372+
'_id': 'doc2',
373+
'_rev': '1-x',
374+
'foo': 'bar',
375+
'_revisions': {
376+
'start': 1,
377+
'ids': ['x']
378+
}
370379
}
371-
}, {
372-
'_id': 'doc2',
373-
'_rev': '1-x',
374-
'foo': 'bar',
375-
'_revisions': {
376-
'start': 1,
377-
'ids': ['x']
378-
}
379-
}
380-
]
381-
}, {new_edits: false});
382-
res.should.have.length(1);
383-
should.exist(res[0].error);
384-
res[0].id.should.equal('doc1');
380+
]
381+
}, {new_edits: false});
382+
res.should.have.length(1);
383+
should.exist(res[0].error);
384+
res[0].id.should.equal('doc1');
385+
});
385386
});
386387

387388
it('Deleting _local docs with bulkDocs' , async () => {

tests/integration/utils.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,11 @@ const parseHostWithCreds = (host) => {
167167

168168
testUtils.isCouchDB = async (cb) => {
169169
const {url, options} = parseHostWithCreds(testUtils.couchHost());
170-
const response = await PouchDB.fetch(url, options);
171-
const res = await response.json();
172-
const result = 'couchdb' in res || 'express-pouchdb' in res;
173-
if (cb) {
174-
cb(result);
175-
}
176-
return result;
170+
PouchDB.fetch(url, options).then(function (response) {
171+
return response.json();
172+
}).then(function (res) {
173+
cb('couchdb' in res || 'express-pouchdb' in res);
174+
});
177175
};
178176

179177
testUtils.getServerType = async () => {

0 commit comments

Comments
 (0)