Skip to content

Commit 58818c3

Browse files
committed
es6 refactor and replace fin and promisify
1 parent 9070229 commit 58818c3

1 file changed

Lines changed: 24 additions & 23 deletions

File tree

tests/mapreduce/test.mapreduce.js

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,16 +1151,17 @@ function tests(suiteName, dbName, dbType, viewType) {
11511151
});
11521152
}
11531153

1154-
it('Query result should include _conflicts', function () {
1154+
it('Query result should include _conflicts', async function () {
11551155
const db2name = testUtils.adapterUrl(dbType, 'test2b');
1156-
const cleanup = function () {
1157-
return new PouchDB(db2name).destroy();
1158-
};
1156+
const cleanup = () => new PouchDB(db2name).destroy();
1157+
11591158
const doc1 = {_id: '1', foo: 'bar'};
11601159
const doc2 = {_id: '1', foo: 'baz'};
11611160
const db = new PouchDB(dbName);
1162-
return testUtils.fin(db.info().then(function () {
1163-
return db.put({
1161+
1162+
try {
1163+
await db.info();
1164+
await db.put({
11641165
_id: '_design/test',
11651166
views: {
11661167
test: {
@@ -1172,24 +1173,24 @@ function tests(suiteName, dbName, dbType, viewType) {
11721173
}
11731174
}
11741175
});
1175-
}).then(function () {
1176+
11761177
const remote = new PouchDB(db2name);
1177-
return remote.info().then(function () {
1178-
const replicate = testUtils.promisify(db.replicate.from, db.replicate);
1179-
return db.post(doc1).then(function () {
1180-
return remote.post(doc2);
1181-
}).then(function () {
1182-
return replicate(remote);
1183-
}).then(function () {
1184-
return db.query('test', {include_docs : true, conflicts: true});
1185-
}).then(function (res) {
1186-
should.exist(res.rows[0].doc._conflicts);
1187-
return db.get(res.rows[0].doc._id, {conflicts: true});
1188-
}).then(function (res) {
1189-
should.exist(res._conflicts);
1190-
});
1191-
});
1192-
}), cleanup);
1178+
await remote.info();
1179+
1180+
await db.post(doc1);
1181+
await remote.post(doc2);
1182+
await db.replicate.from(remote);
1183+
1184+
let res = await db.query('test', {include_docs : true, conflicts: true});
1185+
1186+
res.rows[0].doc._conflicts.should.exist;
1187+
1188+
res = await db.get(res.rows[0].doc._id, {conflicts: true});
1189+
1190+
res._conflicts.should.exist;
1191+
} finally {
1192+
await cleanup();
1193+
}
11931194
});
11941195

11951196
const icons = [

0 commit comments

Comments
 (0)