Skip to content

Commit

Permalink
test: remove unnecessary test
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Nov 28, 2022
1 parent b393f87 commit f60b59a
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions test/helpers/common.test.js
Expand Up @@ -9,39 +9,14 @@ const { Schema } = mongoose;


describe('modifiedPaths, bad update value which has circular reference field', () => {

it('update value can be null', function() {
modifiedPaths(null, 'path', null);
});

it('values with obvious error', function() {
it('values with obvious error on circular reference', function() {
const objA = {};
objA.a = objA;

assert.throws(() => modifiedPaths(objA, 'path', null), /circular reference/);
});

it('original error i made', async function() {
await mongoose.connect(start.uri);

const test1Schema = new Schema({
v: Number,
n: String
});

const Test1Model = mongoose.model('Test1', test1Schema);

const test2Schema = new Schema({
v: Number
});

const Test2Model = mongoose.model('Test2', test2Schema);

for (let i = 0; i < 5; i++) {
const doc = new Test2Model({ v: i });
await doc.save();
}

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

0 comments on commit f60b59a

Please sign in to comment.