@@ -766,29 +766,32 @@ apiDescribe.skip(
766766 } ) ;
767767
768768 it ( 'performs sum that overflows max int using getAggregationFromServer' , ( ) => {
769+ // A large value that will be represented as a Long on the server, but
770+ // doubling (2x) this value must overflow Long and force the result to be
771+ // represented as a Double type on the server.
772+ const maxLong = Math . pow ( 2 , 63 ) - 1 ;
773+
769774 const testDocs = {
770775 a : {
771776 author : 'authorA' ,
772777 title : 'titleA' ,
773778 pages : 100 ,
774779 year : 1980 ,
775- rating : Number . MAX_SAFE_INTEGER
780+ rating : maxLong
776781 } ,
777782 b : {
778783 author : 'authorB' ,
779784 title : 'titleB' ,
780785 pages : 50 ,
781786 year : 2020 ,
782- rating : Number . MAX_SAFE_INTEGER
787+ rating : maxLong
783788 }
784789 } ;
785790 return withTestCollection ( persistence , testDocs , async coll => {
786791 const snapshot = await getAggregateFromServer ( coll , {
787792 totalRating : sum ( 'rating' )
788793 } ) ;
789- expect ( snapshot . data ( ) . totalRating ) . to . equal (
790- Number . MAX_SAFE_INTEGER + Number . MAX_SAFE_INTEGER
791- ) ;
794+ expect ( snapshot . data ( ) . totalRating ) . to . equal ( maxLong + maxLong ) ;
792795 } ) ;
793796 } ) ;
794797
@@ -1296,7 +1299,10 @@ apiDescribe.skip(
12961299 const snapshot = await getAggregateFromServer ( coll , {
12971300 averageRating : average ( 'rating' )
12981301 } ) ;
1299- expect ( snapshot . data ( ) . averageRating ) . to . equal ( 9.2 ) ;
1302+ expect ( snapshot . data ( ) . averageRating ) . to . be . approximately (
1303+ 9.2 ,
1304+ 0.0000001
1305+ ) ;
13001306 } ) ;
13011307 } ) ;
13021308
@@ -1368,7 +1374,7 @@ apiDescribe.skip(
13681374 } ) ;
13691375 } ) ;
13701376
1371- it ( 'performs average that could overflow IEEE754 during accumulation using getAggregationFromServer' , ( ) => {
1377+ it ( 'performs average that overflows IEEE754 during accumulation using getAggregationFromServer' , ( ) => {
13721378 const testDocs = {
13731379 a : {
13741380 author : 'authorA' ,
@@ -1389,7 +1395,9 @@ apiDescribe.skip(
13891395 const snapshot = await getAggregateFromServer ( coll , {
13901396 averageRating : average ( 'rating' )
13911397 } ) ;
1392- expect ( snapshot . data ( ) . averageRating ) . to . equal ( Number . MAX_VALUE ) ;
1398+ expect ( snapshot . data ( ) . averageRating ) . to . equal (
1399+ Number . POSITIVE_INFINITY
1400+ ) ;
13931401 } ) ;
13941402 } ) ;
13951403
0 commit comments