@@ -547,6 +547,7 @@ describe('Query', function() {
547
547
assert . ok ( ! threw ) ;
548
548
done ( ) ;
549
549
} ) ;
550
+
550
551
it ( 'works with overwriting previous object args (1176)' , function ( done ) {
551
552
var q = new Query ( { } , { } , null , p1 . collection ) ;
552
553
assert . doesNotThrow ( function ( ) {
@@ -1862,11 +1863,11 @@ describe('Query', function() {
1862
1863
1863
1864
var MyModel = db . model ( 'gh4378' , schema ) ;
1864
1865
1865
- assert . throws ( function ( ) {
1866
- MyModel . findOne ( '' ) ;
1867
- } , / I n v a l i d a r g u m e n t t o f i n d O n e ( ) / ) ;
1868
-
1869
- done ( ) ;
1866
+ MyModel . findOne ( '' , function ( error ) {
1867
+ assert . ok ( error ) ;
1868
+ assert . equal ( error . name , 'ObjectParameterError' ) ;
1869
+ done ( ) ;
1870
+ } ) ;
1870
1871
} ) ;
1871
1872
1872
1873
it ( 'handles geoWithin with $center and mongoose object (gh-4419)' , function ( done ) {
@@ -2251,6 +2252,19 @@ describe('Query', function() {
2251
2252
} ) ;
2252
2253
} ) ;
2253
2254
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
+
2254
2268
it ( 'queries with BSON overflow (gh-5812)' , function ( done ) {
2255
2269
this . timeout ( 10000 ) ;
2256
2270
0 commit comments