@@ -15,8 +15,6 @@ import {
1515 ReturnDocument
1616} from '../../mongodb' ;
1717import { type FailPoint } from '../../tools/utils' ;
18- import { assert as test } from '../shared' ;
19-
2018// instanceof cannot be use reliably to detect the new models in js due to scoping and new
2119// contexts killing class info find/distinct/count thus cannot be overloaded without breaking
2220// backwards compatibility in a fundamental way
@@ -908,18 +906,21 @@ describe('CRUD API', function () {
908906 await collection . drop ( ) ;
909907 } ) ;
910908
911- context ( 'when including an update with all undefined atomic operators' , function ( ) {
912- beforeEach ( async function ( ) {
913- client = this . configuration . newClient ( ) ;
914- } ) ;
909+ context (
910+ 'when including an update with all undefined atomic operators ignoring undefined' ,
911+ function ( ) {
912+ beforeEach ( async function ( ) {
913+ client = this . configuration . newClient ( ) ;
914+ } ) ;
915915
916- it ( 'throws an error' , async function ( ) {
917- const error = await collection
918- . updateOne ( { a : 1 } , { $set : undefined , $unset : undefined } )
919- . catch ( error => error ) ;
920- expect ( error . message ) . to . include ( 'All atomic operators provided have undefined values.' ) ;
921- } ) ;
922- } ) ;
916+ it ( 'throws an error' , async function ( ) {
917+ const error = await collection
918+ . updateOne ( { a : 1 } , { $set : undefined , $unset : undefined } , { ignoreUndefined : true } )
919+ . catch ( error => error ) ;
920+ expect ( error . message ) . to . include ( 'All atomic operators provided have undefined values.' ) ;
921+ } ) ;
922+ }
923+ ) ;
923924 } ) ;
924925
925926 describe ( '#updateMany' , function ( ) {
@@ -934,18 +935,21 @@ describe('CRUD API', function () {
934935 await collection . drop ( ) ;
935936 } ) ;
936937
937- context ( 'when including an update with all undefined atomic operators' , function ( ) {
938- beforeEach ( async function ( ) {
939- client = this . configuration . newClient ( ) ;
940- } ) ;
938+ context (
939+ 'when including an update with all undefined atomic operators ignoring undefined' ,
940+ function ( ) {
941+ beforeEach ( async function ( ) {
942+ client = this . configuration . newClient ( ) ;
943+ } ) ;
941944
942- it ( 'throws an error' , async function ( ) {
943- const error = await collection
944- . updateMany ( { a : 1 } , { $set : undefined , $unset : undefined } )
945- . catch ( error => error ) ;
946- expect ( error . message ) . to . include ( 'All atomic operators provided have undefined values.' ) ;
947- } ) ;
948- } ) ;
945+ it ( 'throws an error' , async function ( ) {
946+ const error = await collection
947+ . updateMany ( { a : 1 } , { $set : undefined , $unset : undefined } , { ignoreUndefined : true } )
948+ . catch ( error => error ) ;
949+ expect ( error . message ) . to . include ( 'All atomic operators provided have undefined values.' ) ;
950+ } ) ;
951+ }
952+ ) ;
949953 } ) ;
950954
951955 describe ( '#findOneAndUpdate' , function ( ) {
@@ -960,18 +964,21 @@ describe('CRUD API', function () {
960964 await collection . drop ( ) ;
961965 } ) ;
962966
963- context ( 'when including an update with all undefined atomic operators' , function ( ) {
964- beforeEach ( async function ( ) {
965- client = this . configuration . newClient ( ) ;
966- } ) ;
967+ context (
968+ 'when including an update with all undefined atomic operators ignoring undefined' ,
969+ function ( ) {
970+ beforeEach ( async function ( ) {
971+ client = this . configuration . newClient ( ) ;
972+ } ) ;
967973
968- it ( 'throws an error' , async function ( ) {
969- const error = await collection
970- . findOneAndUpdate ( { a : 1 } , { $set : undefined , $unset : undefined } )
971- . catch ( error => error ) ;
972- expect ( error . message ) . to . include ( 'All atomic operators provided have undefined values.' ) ;
973- } ) ;
974- } ) ;
974+ it ( 'throws an error' , async function ( ) {
975+ const error = await collection
976+ . findOneAndUpdate ( { a : 1 } , { $set : undefined , $unset : undefined } )
977+ . catch ( error => error ) ;
978+ expect ( error . message ) . to . include ( 'All atomic operators provided have undefined values.' ) ;
979+ } ) ;
980+ }
981+ ) ;
975982
976983 context ( 'when includeResultMetadata is true' , function ( ) {
977984 beforeEach ( async function ( ) {
0 commit comments