@@ -539,3 +539,27 @@ test("checkDiskUsage succeeds and produces positive numbers", async (t) => {
539539 t . true ( diskUsage . numTotalBytes > 0 ) ;
540540 }
541541} ) ;
542+
543+ test ( "joinAtMost - behaves like join if limit is <= 0" , ( t ) => {
544+ const sep = ", " ;
545+ const array : string [ ] = new Array ( 10 ) . fill ( "test" ) ;
546+ t . is ( util . joinAtMost ( array , sep , 0 ) , array . join ( sep ) ) ;
547+ t . is ( util . joinAtMost ( array , sep , - 1 ) , array . join ( sep ) ) ;
548+ } ) ;
549+
550+ test ( "joinAtMost - behaves like join if limit is >= the size of the array" , ( t ) => {
551+ const sep = ", " ;
552+ const array : string [ ] = new Array ( 10 ) . fill ( "test" ) ;
553+ t . is ( util . joinAtMost ( array , sep , 10 ) , array . join ( sep ) ) ;
554+ t . is ( util . joinAtMost ( array , sep , 11 ) , array . join ( sep ) ) ;
555+ } ) ;
556+
557+ test ( "joinAtMost - truncates list if array is > than limit" , ( t ) => {
558+ const sep = ", " ;
559+ const array : string [ ] = Array . from ( new Array ( 10 ) , ( _ , i ) => `test${ i + 1 } ` ) ;
560+ const result = util . joinAtMost ( array , sep , 5 ) ;
561+ t . not ( result , array . join ( sep ) ) ;
562+ t . assert ( result . endsWith ( ", ..." ) ) ;
563+ t . assert ( result . includes ( "test5" ) ) ;
564+ t . false ( result . includes ( "test6" ) ) ;
565+ } ) ;
0 commit comments