@@ -608,14 +608,19 @@ describe('UserRepo', () => {
608608 } ) ;
609609
610610 const setupFind = async ( ) => {
611- const query = {
611+ let query = {
612612 schoolId : undefined ,
613613 isOutdated : undefined ,
614614 lastLoginSystemChangeSmallerThan : undefined ,
615615 outdatedSince : undefined ,
616616 lastLoginSystemChangeBetweenEnd : undefined ,
617617 lastLoginSystemChangeBetweenStart : undefined ,
618618 } ;
619+ const deletedFilter = {
620+ $or : [ { deletedAt : { $exists : false } } , { deletedAt : null } , { deletedAt : { $gte : expect . any ( Date ) } } ] ,
621+ } ;
622+
623+ query = { ...query , ...deletedFilter } ;
619624
620625 const options : IFindOptions < UserDo > = { } ;
621626
@@ -630,12 +635,12 @@ describe('UserRepo', () => {
630635
631636 const emFindAndCountSpy = jest . spyOn ( em , 'findAndCount' ) ;
632637
633- return { query, options, users, emFindAndCountSpy } ;
638+ return { query, options, users, emFindAndCountSpy, deletedFilter } ;
634639 } ;
635640
636641 describe ( 'sorting' , ( ) => {
637642 it ( 'should create queryOrderMap with options.order' , async ( ) => {
638- const { query, options, emFindAndCountSpy } = await setupFind ( ) ;
643+ const { query, options, emFindAndCountSpy, deletedFilter } = await setupFind ( ) ;
639644 options . order = {
640645 id : SortOrder . asc ,
641646 } ;
@@ -644,22 +649,22 @@ describe('UserRepo', () => {
644649
645650 expect ( emFindAndCountSpy ) . toHaveBeenCalledWith (
646651 User ,
647- { } ,
652+ deletedFilter ,
648653 expect . objectContaining < FindOptions < User > > ( {
649654 orderBy : expect . objectContaining < QueryOrderMap < User > > ( { _id : options . order . id } ) as QueryOrderMap < User > ,
650655 } )
651656 ) ;
652657 } ) ;
653658
654659 it ( 'should create queryOrderMap with an empty object' , async ( ) => {
655- const { query, options, emFindAndCountSpy } = await setupFind ( ) ;
660+ const { query, options, emFindAndCountSpy, deletedFilter } = await setupFind ( ) ;
656661 options . order = undefined ;
657662
658663 await repo . find ( query , options ) ;
659664
660665 expect ( emFindAndCountSpy ) . toHaveBeenCalledWith (
661666 User ,
662- { } ,
667+ deletedFilter ,
663668 expect . objectContaining < FindOptions < User > > ( {
664669 orderBy : expect . objectContaining < QueryOrderMap < User > > ( { } ) as QueryOrderMap < User > ,
665670 } )
@@ -740,6 +745,9 @@ describe('UserRepo', () => {
740745 lastLoginSystemChangeBetweenStart : new Date ( ) ,
741746 lastLoginSystemChangeBetweenEnd : new Date ( ) ,
742747 } ;
748+ const deletedFilter = {
749+ $or : [ { deletedAt : { $exists : false } } , { deletedAt : null } , { deletedAt : { $gte : expect . any ( Date ) } } ] ,
750+ } ;
743751
744752 const options : IFindOptions < UserDo > = { } ;
745753
@@ -799,6 +807,13 @@ describe('UserRepo', () => {
799807 $eq : query . outdatedSince ,
800808 } ,
801809 } ,
810+ {
811+ $or : [
812+ { deletedAt : { $exists : false } } ,
813+ { deletedAt : null } ,
814+ { deletedAt : { $gte : expect . any ( Date ) } } ,
815+ ] ,
816+ } ,
802817 ] ,
803818 } ,
804819 expect . objectContaining < FindOptions < User > > ( {
0 commit comments