File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ function _sanitize(target, options) {
8787 } ;
8888}
8989
90- function sanitize ( target , options ) {
90+ function sanitize ( target , options = { } ) {
9191 return _sanitize ( target , options ) . target ;
9292}
9393
Original file line number Diff line number Diff line change @@ -979,4 +979,30 @@ describe('Express Mongo Sanitize', function () {
979979 ) ;
980980 } ) ;
981981 } ) ;
982+
983+ describe ( 'sanitize' , function ( ) {
984+ it ( 'should not throw a NPE when options is not passed into the function' , function ( ) {
985+ const req = {
986+ body : {
987+ hello : 'world' ,
988+ } ,
989+ } ;
990+
991+ const resp = sanitize . sanitize ( req . body ) ;
992+
993+ expect ( resp ) . to . deep . equal ( req . body ) ;
994+ } ) ;
995+
996+ it ( 'should return successfully with option passed in' , function ( ) {
997+ const req = {
998+ body : {
999+ hello : 'world' ,
1000+ } ,
1001+ } ;
1002+
1003+ const resp = sanitize . sanitize ( req . body , { dryRun : true } ) ;
1004+
1005+ expect ( resp ) . to . deep . equal ( req . body ) ;
1006+ } ) ;
1007+ } ) ;
9821008} ) ;
You can’t perform that action at this time.
0 commit comments