@@ -328,7 +328,7 @@ describe('HashMap', () => {
328
328
} ) ;
329
329
330
330
it ( 'some() returns true if any element matches the condition' , ( ) => {
331
- expect ( hashMap . some ( ( value , key ) => key === 'key1' ) ) . toBe ( true ) ;
331
+ expect ( hashMap . some ( key => key === 'key1' ) ) . toBe ( true ) ;
332
332
} ) ;
333
333
334
334
it ( 'forEach() should execute a function for each element' , ( ) => {
@@ -338,12 +338,12 @@ describe('HashMap', () => {
338
338
} ) ;
339
339
340
340
it ( 'map() should transform each element' , ( ) => {
341
- const newHashMap = hashMap . map ( value => value . toUpperCase ( ) ) ;
341
+ const newHashMap = hashMap . map ( ( key , value ) => value . toUpperCase ( ) ) ;
342
342
expect ( newHashMap . get ( 'key1' ) ) . toBe ( 'VALUE1' ) ;
343
343
} ) ;
344
344
345
345
it ( 'filter() should remove elements that do not match the condition' , ( ) => {
346
- const filteredHashMap = hashMap . filter ( ( value , key ) => key !== 'key1' ) ;
346
+ const filteredHashMap = hashMap . filter ( ( key , value ) => key !== 'key1' ) ;
347
347
expect ( filteredHashMap . has ( 'key1' ) ) . toBe ( false ) ;
348
348
} ) ;
349
349
@@ -361,28 +361,28 @@ describe('HashMap', () => {
361
361
} ) ;
362
362
363
363
it ( 'should find' , ( ) => {
364
- const found = hashMap . find ( value => value === 'value1' ) ;
364
+ const found = hashMap . find ( ( key , value ) => value === 'value1' ) ;
365
365
expect ( found ) . toEqual ( [ 'key1' , 'value1' ] ) ;
366
366
const notFound = hashMap . find ( value => value === 'value6' ) ;
367
367
expect ( notFound ) . toEqual ( undefined ) ;
368
368
} ) ;
369
369
370
370
it ( 'should every' , ( ) => {
371
- const isEvery = hashMap . every ( value => value . substring ( 0 , 5 ) === 'value' ) ;
371
+ const isEvery = hashMap . every ( ( key , value ) => value . substring ( 0 , 5 ) === 'value' ) ;
372
372
expect ( isEvery ) . toEqual ( true ) ;
373
- const isEvery4 = hashMap . every ( value => value . substring ( 0 , 4 ) === 'value' ) ;
373
+ const isEvery4 = hashMap . every ( ( key , value ) => value . substring ( 0 , 4 ) === 'value' ) ;
374
374
expect ( isEvery4 ) . toEqual ( false ) ;
375
375
} ) ;
376
376
377
377
it ( 'should some' , ( ) => {
378
- const isSome = hashMap . some ( value => value . substring ( 5 , 6 ) === '2' ) ;
378
+ const isSome = hashMap . some ( ( key , value ) => value . substring ( 5 , 6 ) === '2' ) ;
379
379
expect ( isSome ) . toEqual ( true ) ;
380
- const isSome4 = hashMap . some ( value => value . substring ( 0 , 5 ) === 'value' ) ;
380
+ const isSome4 = hashMap . some ( ( key , value ) => value . substring ( 0 , 5 ) === 'value' ) ;
381
381
expect ( isSome4 ) . toEqual ( true ) ;
382
382
} ) ;
383
383
384
384
it ( 'should forEach' , ( ) => {
385
- hashMap . forEach ( ( value , key , index ) => expect ( value . substring ( 5 , 6 ) ) . toBe ( String ( index + 1 ) ) ) ;
385
+ hashMap . forEach ( ( key , value , index ) => expect ( value . substring ( 5 , 6 ) ) . toBe ( String ( index + 1 ) ) ) ;
386
386
} ) ;
387
387
388
388
it ( 'should entries' , ( ) => {
@@ -817,7 +817,7 @@ describe('LinkedHashMap', () => {
817
817
} ) ;
818
818
819
819
it ( 'some() returns true if any element matches the condition' , ( ) => {
820
- expect ( hashMap . some ( ( value , key ) => key === 'key1' ) ) . toBe ( true ) ;
820
+ expect ( hashMap . some ( key => key === 'key1' ) ) . toBe ( true ) ;
821
821
} ) ;
822
822
823
823
it ( 'forEach() should execute a function for each element' , ( ) => {
@@ -827,12 +827,12 @@ describe('LinkedHashMap', () => {
827
827
} ) ;
828
828
829
829
it ( 'map() should transform each element' , ( ) => {
830
- const newHashMap = hashMap . map ( value => value . toUpperCase ( ) ) ;
830
+ const newHashMap = hashMap . map ( ( key , value ) => [ key , value . toUpperCase ( ) ] ) ;
831
831
expect ( newHashMap . get ( 'key1' ) ) . toBe ( 'VALUE1' ) ;
832
832
} ) ;
833
833
834
834
it ( 'filter() should remove elements that do not match the condition' , ( ) => {
835
- const filteredHashMap = hashMap . filter ( ( value , key ) => key !== 'key1' ) ;
835
+ const filteredHashMap = hashMap . filter ( key => key !== 'key1' ) ;
836
836
expect ( filteredHashMap . has ( 'key1' ) ) . toBe ( false ) ;
837
837
} ) ;
838
838
0 commit comments