@@ -15,8 +15,6 @@ import {
15
15
ReturnDocument
16
16
} from '../../mongodb' ;
17
17
import { type FailPoint } from '../../tools/utils' ;
18
- import { assert as test } from '../shared' ;
19
-
20
18
// instanceof cannot be use reliably to detect the new models in js due to scoping and new
21
19
// contexts killing class info find/distinct/count thus cannot be overloaded without breaking
22
20
// backwards compatibility in a fundamental way
@@ -908,18 +906,21 @@ describe('CRUD API', function () {
908
906
await collection . drop ( ) ;
909
907
} ) ;
910
908
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
+ } ) ;
915
915
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
+ ) ;
923
924
} ) ;
924
925
925
926
describe ( '#updateMany' , function ( ) {
@@ -934,18 +935,21 @@ describe('CRUD API', function () {
934
935
await collection . drop ( ) ;
935
936
} ) ;
936
937
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
+ } ) ;
941
944
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
+ ) ;
949
953
} ) ;
950
954
951
955
describe ( '#findOneAndUpdate' , function ( ) {
@@ -960,18 +964,21 @@ describe('CRUD API', function () {
960
964
await collection . drop ( ) ;
961
965
} ) ;
962
966
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
+ } ) ;
967
973
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
+ ) ;
975
982
976
983
context ( 'when includeResultMetadata is true' , function ( ) {
977
984
beforeEach ( async function ( ) {
0 commit comments