11import test from 'ava'
22
3- import List from '../src/list'
3+ import List from '../src/list.js '
44
55interface IPackage {
66 Company : string
@@ -561,13 +561,11 @@ test('LastOrDefault', t => {
561561 t . is ( new List < string > ( ) . LastOrDefault ( 'default' ) , 'default' )
562562} )
563563
564-
565564test ( 'Max' , t => {
566565 const people = new List < IPerson > ( [
567566 { Age : 50 , Name : 'Bob' } ,
568567 { Age : 15 , Name : 'Cathy' } ,
569568 { Age : 25 , Name : 'Alice' }
570-
571569 ] )
572570 t . is (
573571 people . Max ( x => x . Age ?? 0 ) ,
@@ -587,8 +585,8 @@ test('Max_invalid_function_provided', t => {
587585 ] )
588586
589587 // Provide an invalid selector (wrong type) to trigger the error
590- let invalidFn = ( ) => 0 ;
591-
588+ let invalidFn = ( ) => 0
589+
592590 t . throws ( ( ) => people . Max ( invalidFn ) , {
593591 message : / I n v a l i d O p e r a t i o n E x c e p t i o n : I n v a l i d c o m p a r e r o r s e l e c t o r f u n c t i o n p r o v i d e d ./
594592 } )
@@ -609,10 +607,7 @@ test('Max_undefinedComparer', t => {
609607test ( 'Max_emptyElements' , t => {
610608 const people = new List < IPerson > ( [ ] )
611609
612- t . is (
613- people . Max ( ) ,
614- undefined
615- )
610+ t . is ( people . Max ( ) , undefined )
616611} )
617612
618613test ( 'Max_comparer' , t => {
@@ -622,58 +617,31 @@ test('Max_comparer', t => {
622617 { Age : 50 , Name : 'Bob' }
623618 ] )
624619
625- let comparer = ( ( a : IPerson , b : IPerson ) => ( a . Age ?? 0 ) - ( b . Age ?? 0 ) ) ;
626-
627- t . is (
628- people . Max ( comparer ) ,
629- people . Last ( )
630- ) ;
620+ let comparer = ( a : IPerson , b : IPerson ) => ( a . Age ?? 0 ) - ( b . Age ?? 0 )
621+
622+ t . is ( people . Max ( comparer ) , people . Last ( ) )
631623} )
632624
633625test ( 'Max_number' , t => {
634- const nums = new List < number > ( [
635- 5 ,
636- 10 ,
637- - 5
638- ] )
639- t . is (
640- nums . Max ( ) ,
641- 10
642- )
626+ const nums = new List < number > ( [ 5 , 10 , - 5 ] )
627+ t . is ( nums . Max ( ) , 10 )
643628} )
644629
645630test ( 'Max_string' , t => {
646- const people = new List < string > ( [
647- 'Cathy' ,
648- 'Alice' ,
649- 'Bob'
650- ] )
651- t . is (
652- people . Max ( ) ,
653- 'Cathy'
654- )
631+ const people = new List < string > ( [ 'Cathy' , 'Alice' , 'Bob' ] )
632+ t . is ( people . Max ( ) , 'Cathy' )
655633} )
656634
657635test ( 'Max_boolean' , t => {
658- const bools = new List < boolean > ( [
659- true ,
660- false ,
661- true ,
662- false
663- ] )
664- t . is (
665- bools . Max ( ) ,
666- true
667- )
636+ const bools = new List < boolean > ( [ true , false , true , false ] )
637+ t . is ( bools . Max ( ) , true )
668638} )
669639
670-
671640test ( 'Min' , t => {
672641 const people = new List < IPerson > ( [
673642 { Age : 50 , Name : 'Bob' } ,
674643 { Age : 15 , Name : 'Cathy' } ,
675644 { Age : 25 , Name : 'Alice' }
676-
677645 ] )
678646 t . is (
679647 people . Min ( x => x . Age ?? 0 ) ,
@@ -693,8 +661,8 @@ test('Min_invalid_function_provided', t => {
693661 ] )
694662
695663 // Provide an invalid selector (wrong type) to trigger the error
696- let invalidFn = ( ) => 0 ;
697-
664+ let invalidFn = ( ) => 0
665+
698666 t . throws ( ( ) => people . Min ( invalidFn ) , {
699667 message : / I n v a l i d O p e r a t i o n E x c e p t i o n : I n v a l i d c o m p a r e r o r s e l e c t o r f u n c t i o n p r o v i d e d ./
700668 } )
@@ -719,58 +687,30 @@ test('Min_comparer', t => {
719687 { Age : 50 , Name : 'Bob' }
720688 ] )
721689
722- let comparer = ( ( a : IPerson , b : IPerson ) => ( a . Age ?? 0 ) - ( b . Age ?? 0 ) ) ;
723-
724- t . is (
725- people . Min ( comparer ) ,
726- people . First ( )
727- ) ;
690+ let comparer = ( a : IPerson , b : IPerson ) => ( a . Age ?? 0 ) - ( b . Age ?? 0 )
691+
692+ t . is ( people . Min ( comparer ) , people . First ( ) )
728693} )
729694
730695test ( 'Min_emptyElements' , t => {
731696 const people = new List < IPerson > ( [ ] )
732697
733- t . is (
734- people . Min ( ) ,
735- undefined
736- )
698+ t . is ( people . Min ( ) , undefined )
737699} )
738700
739701test ( 'Min_number' , t => {
740- const nums = new List < number > ( [
741- 10 ,
742- 5 ,
743- - 5
744- ] )
745- t . is (
746- nums . Min ( ) ,
747- - 5
748- )
702+ const nums = new List < number > ( [ 10 , 5 , - 5 ] )
703+ t . is ( nums . Min ( ) , - 5 )
749704} )
750705
751706test ( 'Min_string' , t => {
752- const people = new List < string > ( [
753- 'Cathy' ,
754- 'Alice' ,
755- 'Bob'
756- ] )
757- t . is (
758- people . Min ( ) ,
759- 'Alice'
760- )
707+ const people = new List < string > ( [ 'Cathy' , 'Alice' , 'Bob' ] )
708+ t . is ( people . Min ( ) , 'Alice' )
761709} )
762710
763711test ( 'Min_boolean' , t => {
764- const bools = new List < boolean > ( [
765- true ,
766- false ,
767- true ,
768- false
769- ] )
770- t . is (
771- bools . Min ( ) ,
772- false
773- )
712+ const bools = new List < boolean > ( [ true , false , true , false ] )
713+ t . is ( bools . Min ( ) , false )
774714} )
775715
776716test ( 'OfType' , t => {
0 commit comments