Skip to content

Commit

Permalink
Fixes pubkey#830
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Sep 30, 2018
1 parent c1575b7 commit 52311c4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rx-document.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ export const basePrototype = {
* instead we keep the values and only set _deleted: true
* @return {Promise<RxDocument>}
*/
remove() {
async remove() {
if (this.deleted) {
throw RxError.newRxError('DOC13', {
document: this,
Expand Down
16 changes: 16 additions & 0 deletions test/unit/rx-document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,5 +811,21 @@ config.parallel('rx-document.test.js', () => {
// clean up afterwards
db.destroy();
});
it('#830 RxDocument.remove() rejects -doesn\'t sync throw', async () => {
const c = await humansCollection.create(5);
const doc = await c.findOne().exec();
await doc.remove();

let asyncE, syncE;
try {
await doc.remove().catch(e => (asyncE = e));
} catch(e) {
syncE = e;
}
assert.equal(syncE, undefined);
assert.equal(asyncE instanceof Error, true);

c.database.destroy();
});
});
});

0 comments on commit 52311c4

Please sign in to comment.