Skip to content

Commit

Permalink
test: remove unnecessary test re: #14435
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Mar 21, 2024
1 parent 1ce7a72 commit e6970bb
Showing 1 changed file with 0 additions and 54 deletions.
54 changes: 0 additions & 54 deletions test/document.populate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -994,58 +994,4 @@ describe('document.populate', function() {
assert.deepStrictEqual(codeUser.extras[0].config.paymentConfiguration.paymentMethods[0]._id, code._id);
assert.strictEqual(codeUser.extras[0].config.paymentConfiguration.paymentMethods[0].code, 'test code');
});

it('works when populating a nested document not inside an array parent (gh-14435)', async function() {
const CodeSchema = new Schema({
code: String
});

const UserSchema = new Schema({
username: String,
extras: new Schema({
config: new Schema({
paymentConfiguration: {
paymentMethods: [
{
type: Schema.Types.ObjectId,
ref: 'Code'
}
]
}
})
})
});

const Code = db.model('Code', CodeSchema);
const CodeUser = db.model('CodeUser', UserSchema);

const code = await Code.create({
code: 'test code'
});

await CodeUser.create({
username: 'TestUser',
extras: {
config: {
paymentConfiguration: {
paymentMethods: [code._id]
}
}
}
});

const codeUser = await CodeUser.findOne({ username: 'TestUser' }).populate(
'extras.config.paymentConfiguration.paymentMethods'
);

assert.ok(codeUser.username);
assert.strictEqual(codeUser.username, 'TestUser');
assert.ok(codeUser.extras);
assert.ok(codeUser.extras.config);
assert.ok(codeUser.extras.config.paymentConfiguration);
assert.ok(codeUser.extras.config.paymentConfiguration.paymentMethods);
assert.strictEqual(codeUser.extras.config.paymentConfiguration.paymentMethods.length, 1);
assert.deepStrictEqual(codeUser.extras.config.paymentConfiguration.paymentMethods[0]._id, code._id);
assert.strictEqual(codeUser.extras.config.paymentConfiguration.paymentMethods[0].code, 'test code');
});
});

0 comments on commit e6970bb

Please sign in to comment.