@@ -138,6 +138,12 @@ describe('each() tests', () => {
138138 expectInvalidFunctionError ( ( ) => coll . each ( 123 ) , 123 ) ;
139139 } ) ;
140140
141+ test ( 'binds the thisArg' , ( ) => {
142+ coll . each ( function each ( ) {
143+ expect ( this ) . toBeNull ( ) ;
144+ } , null ) ;
145+ } ) ;
146+
141147 test ( 'iterate over each item' , ( ) => {
142148 const coll = createTestCollection ( ) ;
143149 const a : [ string , number ] [ ] = [ ] ;
@@ -964,6 +970,10 @@ describe('findLast() tests', () => {
964970 expect ( coll . findLast ( ( value ) => value % 2 === 1 ) ) . toStrictEqual ( 3 ) ;
965971 } ) ;
966972
973+ test ( 'returns undefined if no item matches' , ( ) => {
974+ expect ( coll . findLast ( ( value ) => value === 10 ) ) . toBeUndefined ( ) ;
975+ } ) ;
976+
967977 test ( 'throws if fn is not a function' , ( ) => {
968978 // @ts -expect-error: Invalid function
969979 expectInvalidFunctionError ( ( ) => createCollection ( ) . findLast ( ) ) ;
@@ -985,6 +995,10 @@ describe('findLastKey() tests', () => {
985995 expect ( coll . findLastKey ( ( value ) => value % 2 === 1 ) ) . toStrictEqual ( 'c' ) ;
986996 } ) ;
987997
998+ test ( 'returns undefined if no item matches' , ( ) => {
999+ expect ( coll . findLastKey ( ( value ) => value === 10 ) ) . toBeUndefined ( ) ;
1000+ } ) ;
1001+
9881002 test ( 'throws if fn is not a function' , ( ) => {
9891003 // @ts -expect-error: Invalid function
9901004 expectInvalidFunctionError ( ( ) => createCollection ( ) . findLastKey ( ) ) ;
0 commit comments