@@ -6780,7 +6780,7 @@ describe('Model', function() {
6780
6780
await users [ 2 ] . save ( ) ;
6781
6781
users [ 2 ] . name = 'I am the updated third name' ;
6782
6782
6783
- const writeOperations = await User . buildBulkWriteOperations ( users ) ;
6783
+ const writeOperations = User . buildBulkWriteOperations ( users ) ;
6784
6784
6785
6785
const desiredWriteOperations = [
6786
6786
{ insertOne : { document : users [ 0 ] } } ,
@@ -6795,7 +6795,7 @@ describe('Model', function() {
6795
6795
6796
6796
} ) ;
6797
6797
6798
- it ( 'throws an error when one document is invalid' , async ( ) => {
6798
+ it ( 'throws an error when one document is invalid' , ( ) => {
6799
6799
const userSchema = new Schema ( {
6800
6800
name : { type : String , minLength : 5 }
6801
6801
} ) ;
@@ -6808,14 +6808,10 @@ describe('Model', function() {
6808
6808
new User ( { name : 'b' } )
6809
6809
] ;
6810
6810
6811
- let err ;
6812
- try {
6813
- await User . buildBulkWriteOperations ( users ) ;
6814
- } catch ( error ) {
6815
- err = error ;
6816
- }
6817
-
6818
- assert . ok ( err ) ;
6811
+ assert . throws (
6812
+ ( ) => User . buildBulkWriteOperations ( users ) ,
6813
+ / n a m e : P a t h ` n a m e ` \( ` a ` \) i s s h o r t e r t h a n t h e m i n i m u m a l l o w e d l e n g t h /
6814
+ ) ;
6819
6815
} ) ;
6820
6816
6821
6817
it ( 'throws an error if documents is not an array' , function ( ) {
@@ -6826,8 +6822,8 @@ describe('Model', function() {
6826
6822
const User = db . model ( 'User' , userSchema ) ;
6827
6823
6828
6824
6829
- assert . rejects (
6830
- User . buildBulkWriteOperations ( null ) ,
6825
+ assert . throws (
6826
+ ( ) => User . buildBulkWriteOperations ( null ) ,
6831
6827
/ b u l k S a v e e x p e c t s a n a r r a y o f d o c u m e n t s t o b e p a s s e d /
6832
6828
) ;
6833
6829
} ) ;
@@ -6838,16 +6834,15 @@ describe('Model', function() {
6838
6834
6839
6835
const User = db . model ( 'User' , userSchema ) ;
6840
6836
6841
-
6842
- assert . rejects (
6843
- User . buildBulkWriteOperations ( [
6837
+ assert . throws (
6838
+ ( ) => User . buildBulkWriteOperations ( [
6844
6839
new User ( { name : 'Hafez' } ) ,
6845
6840
{ name : 'I am not a document' }
6846
6841
] ) ,
6847
6842
/ d o c u m e n t s \. 1 w a s n o t a m o n g o o s e d o c u m e n t /
6848
6843
) ;
6849
6844
} ) ;
6850
- it ( 'skips validation when given `skipValidation` true' , async ( ) => {
6845
+ it ( 'skips validation when given `skipValidation` true' , ( ) => {
6851
6846
const userSchema = new Schema ( {
6852
6847
name : { type : String , minLength : 5 }
6853
6848
} ) ;
@@ -6860,7 +6855,7 @@ describe('Model', function() {
6860
6855
new User ( { name : 'b' } )
6861
6856
] ;
6862
6857
6863
- const writeOperations = await User . buildBulkWriteOperations ( users , { skipValidation : true } ) ;
6858
+ const writeOperations = User . buildBulkWriteOperations ( users , { skipValidation : true } ) ;
6864
6859
6865
6860
assert . equal ( writeOperations . length , 3 ) ;
6866
6861
} ) ;
0 commit comments