@@ -11,6 +11,9 @@ import {
1111 _filterObject ,
1212 _filterUndefinedValues ,
1313 _findKeyByValue ,
14+ _firstEntry ,
15+ _firstKey ,
16+ _firstValue ,
1417 _get ,
1518 _has ,
1619 _hasProp ,
@@ -683,6 +686,29 @@ test('_findKeyByValue', () => {
683686 expect ( char ) . toBe ( CHAR . B )
684687} )
685688
689+ test ( '_firstKey' , ( ) => {
690+ expect ( _firstKey ( { a : 1 , b : 2 } ) ) . toBe ( 'a' )
691+ expect ( _firstKey ( { x : 1 } ) ) . toBe ( 'x' )
692+ expect ( _firstKey ( { } ) ) . toBeUndefined ( )
693+ // V8 sorts integer-like keys ascending first, then string keys in insertion order
694+ expect ( _firstKey ( { 2 : 'b' , 1 : 'a' } ) ) . toBe ( '1' )
695+ expect ( _firstKey ( { b : 1 , 1 : 'a' } ) ) . toBe ( '1' )
696+ } )
697+
698+ test ( '_firstValue' , ( ) => {
699+ expect ( _firstValue ( { a : 1 , b : 2 } ) ) . toBe ( 1 )
700+ expect ( _firstValue ( { x : 'only' } ) ) . toBe ( 'only' )
701+ expect ( _firstValue ( { } ) ) . toBeUndefined ( )
702+ expect ( _firstValue ( { 2 : 'b' , 1 : 'a' } ) ) . toBe ( 'a' )
703+ } )
704+
705+ test ( '_firstEntry' , ( ) => {
706+ expect ( _firstEntry ( { a : 1 , b : 2 } ) ) . toEqual ( [ 'a' , 1 ] )
707+ expect ( _firstEntry ( { x : 'only' } ) ) . toEqual ( [ 'x' , 'only' ] )
708+ expect ( _firstEntry ( { } ) ) . toBeUndefined ( )
709+ expect ( _firstEntry ( { 2 : 'b' , 1 : 'a' } ) ) . toEqual ( [ '1' , 'a' ] )
710+ } )
711+
686712test ( '_deepFreeze' , ( ) => {
687713 const o = {
688714 a : {
0 commit comments