Skip to content

Commit

Permalink
Update model.hydrate.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
IslandRhythms committed Feb 12, 2024
1 parent 47fad95 commit 491be54
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/model.hydrate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,23 @@ describe('model', function() {
assert.equal(hydrated.test, 'test');
assert.deepEqual(hydrated.schema.tree, C.schema.tree);
});
it('should deeply hydrate the document with the `hydratedPopulatedDocs` option (gh-4727)', async function() {
const userSchema = new Schema({
name: String
});
const companySchema = new Schema({
name: String,
users: [{ ref: 'User', type: Schema.Types.ObjectId }]
});

const User = db.model('UserTestHydrate', userSchema);

Check failure on line 111 in test/model.hydrate.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

'User' is assigned a value but never used
const Company = db.model('CompanyTestHyrdrate', companySchema);

const users = [{ _id: new Schema.ObjectId(), name: 'Val'}];

Check failure on line 114 in test/model.hydrate.test.js

View workflow job for this annotation

GitHub Actions / Lint JS-Files

A space is required before '}'
const company = { _id: new Schema.ObjectId(), name: 'Booster', users: [users[0]] };

const C = Company.hydrate(company, null, { hydratedPopulatedDocs: true });
assert.equal(C.users[0].name, 'Val');
});
});
});

0 comments on commit 491be54

Please sign in to comment.