@@ -2458,25 +2458,43 @@ describe("Room", function() {
24582458 }
24592459 } ) ;
24602460
2461- it ( "should compare correctly by timestamp" , ( ) => {
2462- for ( let i = 1 ; i <= 3 ; i ++ ) {
2461+ describe ( "correctly compares by timestamp" , ( ) => {
2462+ it ( "should correctly compare, if we have all receipts" , ( ) => {
2463+ for ( let i = 1 ; i <= 3 ; i ++ ) {
2464+ room . getUnfilteredTimelineSet = ( ) => ( {
2465+ compareEventOrdering : ( _1 , _2 ) => null ,
2466+ } as EventTimelineSet ) ;
2467+ room . getReadReceiptForUserId = ( userId , ignore , receiptType ) => {
2468+ if ( receiptType === ReceiptType . ReadPrivate ) {
2469+ return { eventId : "eventId1" , data : { ts : i === 1 ? 1 : 0 } } as IWrappedReceipt ;
2470+ }
2471+ if ( receiptType === ReceiptType . UnstableReadPrivate ) {
2472+ return { eventId : "eventId2" , data : { ts : i === 2 ? 1 : 0 } } as IWrappedReceipt ;
2473+ }
2474+ if ( receiptType === ReceiptType . Read ) {
2475+ return { eventId : "eventId3" , data : { ts : i === 3 ? 1 : 0 } } as IWrappedReceipt ;
2476+ }
2477+ } ;
2478+
2479+ expect ( room . getEventReadUpTo ( userA ) ) . toEqual ( `eventId${ i } ` ) ;
2480+ }
2481+ } ) ;
2482+
2483+ it ( "should correctly compare, if private read receipt is missing" , ( ) => {
24632484 room . getUnfilteredTimelineSet = ( ) => ( {
24642485 compareEventOrdering : ( _1 , _2 ) => null ,
24652486 } as EventTimelineSet ) ;
24662487 room . getReadReceiptForUserId = ( userId , ignore , receiptType ) => {
2467- if ( receiptType === ReceiptType . ReadPrivate ) {
2468- return { eventId : "eventId1" , data : { ts : i === 1 ? 1 : 0 } } as IWrappedReceipt ;
2469- }
24702488 if ( receiptType === ReceiptType . UnstableReadPrivate ) {
2471- return { eventId : "eventId2 " , data : { ts : i === 2 ? 1 : 0 } } as IWrappedReceipt ;
2489+ return { eventId : "eventId1 " , data : { ts : 0 } } as IWrappedReceipt ;
24722490 }
24732491 if ( receiptType === ReceiptType . Read ) {
2474- return { eventId : "eventId3 " , data : { ts : i === 3 ? 1 : 0 } } as IWrappedReceipt ;
2492+ return { eventId : "eventId2 " , data : { ts : 1 } } as IWrappedReceipt ;
24752493 }
24762494 } ;
24772495
2478- expect ( room . getEventReadUpTo ( userA ) ) . toEqual ( `eventId ${ i } ` ) ;
2479- }
2496+ expect ( room . getEventReadUpTo ( userA ) ) . toEqual ( `eventId2 ` ) ;
2497+ } ) ;
24802498 } ) ;
24812499
24822500 describe ( "fallback precedence" , ( ) => {
0 commit comments