Skip to content

Commit

Permalink
test: make tests for #12719 more durable instead of relying on consol…
Browse files Browse the repository at this point in the history
…e log
  • Loading branch information
vkarpov15 committed Nov 28, 2022
1 parent 23d44e4 commit f899973
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions test/helpers/common.test.js
Expand Up @@ -17,11 +17,7 @@ describe('modifiedPaths, bad update value which has circular reference field', (
const objA = {};
objA.a = objA;

try {
modifiedPaths(objA, 'path', null);
} catch (e) {
console.log(e);
}
assert.throws(() => modifiedPaths(objA, 'path', null), /circular reference/);
});

it('original error i made', async function() {
Expand All @@ -44,12 +40,7 @@ describe('modifiedPaths, bad update value which has circular reference field', (
const doc = new Test2Model({ v: i });
await doc.save();
}

try {
// miss an `await` before `Test2Model.countDocuments()`
await Test1Model.updateOne({ n: 'x' }, { v: Test2Model.countDocuments() }, { upsert: true });
} catch (e) {
console.log(e);
}

assert.rejects(() => Test1Model.updateOne({ n: 'x' }, { v: Test2Model.countDocuments() }, { upsert: true }), /circular reference/);
});
});

0 comments on commit f899973

Please sign in to comment.