Skip to content

Commit 0de9867

Browse files
committed
test(query): repro #1698
1 parent f46e033 commit 0de9867

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

test/query.test.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ describe('Query', function() {
547547
assert.ok(!threw);
548548
done();
549549
});
550+
550551
it('works with overwriting previous object args (1176)', function(done) {
551552
var q = new Query({}, {}, null, p1.collection);
552553
assert.doesNotThrow(function() {
@@ -1862,11 +1863,11 @@ describe('Query', function() {
18621863

18631864
var MyModel = db.model('gh4378', schema);
18641865

1865-
assert.throws(function() {
1866-
MyModel.findOne('');
1867-
}, /Invalid argument to findOne()/);
1868-
1869-
done();
1866+
MyModel.findOne('', function(error) {
1867+
assert.ok(error);
1868+
assert.equal(error.name, 'ObjectParameterError');
1869+
done();
1870+
});
18701871
});
18711872

18721873
it('handles geoWithin with $center and mongoose object (gh-4419)', function(done) {
@@ -2251,6 +2252,19 @@ describe('Query', function() {
22512252
});
22522253
});
22532254

2255+
it('with non-object args (gh-1698)', function(done) {
2256+
var schema = new mongoose.Schema({
2257+
email: String
2258+
});
2259+
var M = db.model('gh1698', schema);
2260+
2261+
M.find(42, function(error) {
2262+
assert.ok(error);
2263+
assert.equal(error.name, 'ObjectParameterError');
2264+
done();
2265+
});
2266+
});
2267+
22542268
it('queries with BSON overflow (gh-5812)', function(done) {
22552269
this.timeout(10000);
22562270

0 commit comments

Comments
 (0)